mirror of
https://github.com/hugomods/docker.git
synced 2025-04-26 05:00:50 +03:00
Improve build for Nginx images (#84)
This commit is contained in:
parent
f722746145
commit
85a0dbc587
3 changed files with 39 additions and 3 deletions
4
.github/workflows/build.yml
vendored
4
.github/workflows/build.yml
vendored
|
@ -7,8 +7,8 @@ on:
|
||||||
types: [created]
|
types: [created]
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
push:
|
push:
|
||||||
branches:
|
paths:
|
||||||
- '*'
|
- 'docker/hugo/**'
|
||||||
|
|
||||||
concurrency:
|
concurrency:
|
||||||
group: "docker"
|
group: "docker"
|
||||||
|
|
35
.github/workflows/nginx.yml
vendored
35
.github/workflows/nginx.yml
vendored
|
@ -1,6 +1,9 @@
|
||||||
name: build Nginx image
|
name: build Nginx image
|
||||||
|
|
||||||
on:
|
on:
|
||||||
|
push:
|
||||||
|
paths:
|
||||||
|
- 'docker/nginx/**'
|
||||||
schedule:
|
schedule:
|
||||||
- cron: '0 0 * * 0'
|
- cron: '0 0 * * 0'
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
@ -17,23 +20,42 @@ jobs:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Fetch Latest Tag
|
||||||
|
id: latest-tag
|
||||||
|
run: |
|
||||||
|
NGINX_VERSION=$(curl -s "https://api.github.com/repos/nginx/nginx/tags" | jq -r '.[0].name')
|
||||||
|
echo "name=${NGINX_VERSION#"release-"}" >> $GITHUB_OUTPUT
|
||||||
|
echo "name=${NGINX_VERSION#"release-"}"
|
||||||
|
|
||||||
|
- name: Check if Image Tag Exists
|
||||||
|
id: check
|
||||||
|
uses: razonyang/github-action-docker-image-tag-exists@v1
|
||||||
|
with:
|
||||||
|
owner: ${{ env.IMAGE_OWNER }}
|
||||||
|
name: ${{ env.IMAGE_NAME }}
|
||||||
|
tag: 'nginx-${{ steps.latest-tag.outputs.name }}'
|
||||||
|
|
||||||
- name: Set up QEMU
|
- name: Set up QEMU
|
||||||
|
if: ${{ steps.check.outputs.exists != true }}
|
||||||
uses: docker/setup-qemu-action@v3
|
uses: docker/setup-qemu-action@v3
|
||||||
with:
|
with:
|
||||||
platforms: ${{ env.PLATFORMS }}
|
platforms: ${{ env.PLATFORMS }}
|
||||||
|
|
||||||
- name: Set up Docker Buildx
|
- name: Set up Docker Buildx
|
||||||
|
if: ${{ steps.check.outputs.exists != true }}
|
||||||
uses: docker/setup-buildx-action@v3
|
uses: docker/setup-buildx-action@v3
|
||||||
with:
|
with:
|
||||||
platforms: ${{ env.PLATFORMS }}
|
platforms: ${{ env.PLATFORMS }}
|
||||||
|
|
||||||
- name: Login to Docker Hub
|
- name: Login to Docker Hub
|
||||||
|
if: ${{ steps.check.outputs.exists != true }}
|
||||||
uses: docker/login-action@v3
|
uses: docker/login-action@v3
|
||||||
with:
|
with:
|
||||||
username: ${{ env.IMAGE_OWNER }}
|
username: ${{ env.IMAGE_OWNER }}
|
||||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||||
|
|
||||||
- name: Login to GitHub Container Registry
|
- name: Login to GitHub Container Registry
|
||||||
|
if: ${{ steps.check.outputs.exists != true }}
|
||||||
uses: docker/login-action@v3
|
uses: docker/login-action@v3
|
||||||
with:
|
with:
|
||||||
registry: ghcr.io
|
registry: ghcr.io
|
||||||
|
@ -41,6 +63,7 @@ jobs:
|
||||||
password: ${{ secrets.GITHUB_TOKEN }}
|
password: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
- name: Build and export to Docker
|
- name: Build and export to Docker
|
||||||
|
if: ${{ steps.check.outputs.exists != true }}
|
||||||
uses: docker/build-push-action@v5
|
uses: docker/build-push-action@v5
|
||||||
with:
|
with:
|
||||||
load: true
|
load: true
|
||||||
|
@ -48,12 +71,22 @@ jobs:
|
||||||
tags: hugomods/hugo:nginx-test
|
tags: hugomods/hugo:nginx-test
|
||||||
cache-from: type=gha
|
cache-from: type=gha
|
||||||
cache-to: type=gha,mode=max
|
cache-to: type=gha,mode=max
|
||||||
|
build-args: |
|
||||||
|
NGINX_VERSION=${{ steps.latest-tag.outputs.name }}
|
||||||
|
|
||||||
- name: Test
|
- name: Test
|
||||||
|
if: ${{ steps.check.outputs.exists != true }}
|
||||||
run: |
|
run: |
|
||||||
docker run --rm -v $PWD/site:/src hugomods/hugo:nginx-test nginx -t
|
docker run --rm -v $PWD/site:/src hugomods/hugo:nginx-test nginx -t
|
||||||
|
|
||||||
|
- name: Check Nginx Version
|
||||||
|
if: ${{ steps.check.outputs.exists != true }}
|
||||||
|
run: |
|
||||||
|
DOCKER_NGINX_VERSION=$(docker run --rm -v $PWD/site:/src hugomods/hugo:nginx-test nginx -v 2>&1)
|
||||||
|
if [[ $DOCKER_NGINX_VERSION != *"${{ steps.latest-tag.outputs.name }}"* ]]; then echo "Expected version "${{ steps.latest-tag.outputs.name }}", got "$DOCKER_NGINX_VERSION"." && exit 1; fi
|
||||||
|
|
||||||
- name: Build and push
|
- name: Build and push
|
||||||
|
if: ${{ steps.check.outputs.exists != true && env.BRANCH_NAME == 'main' }}
|
||||||
uses: docker/build-push-action@v5
|
uses: docker/build-push-action@v5
|
||||||
with:
|
with:
|
||||||
push: true
|
push: true
|
||||||
|
@ -64,3 +97,5 @@ jobs:
|
||||||
ghcr.io/${{ env.IMAGE_OWNER }}/${{ env.IMAGE_NAME }}:nginx
|
ghcr.io/${{ env.IMAGE_OWNER }}/${{ env.IMAGE_NAME }}:nginx
|
||||||
cache-from: type=gha
|
cache-from: type=gha
|
||||||
cache-to: type=gha,mode=max
|
cache-to: type=gha,mode=max
|
||||||
|
build-args: |
|
||||||
|
NGINX_VERSION=${{ steps.latest-tag.outputs.name }}
|
||||||
|
|
|
@ -1,2 +1,3 @@
|
||||||
FROM nginx
|
ARG NGINX_VERSION
|
||||||
|
FROM nginx:$NGINX_VERSION
|
||||||
COPY conf.d/default.conf /etc/nginx/conf.d/default.conf
|
COPY conf.d/default.conf /etc/nginx/conf.d/default.conf
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue