From 888de149c02abd57dc831c1c1903cd10ae58ae94 Mon Sep 17 00:00:00 2001 From: Nicolas Duchon Date: Mon, 8 May 2023 17:02:45 +0200 Subject: [PATCH 1/5] ci: better use build matrix --- .github/workflows/build-publish.yml | 64 +++++++---------------------- Dockerfile => Dockerfile.alpine | 0 2 files changed, 15 insertions(+), 49 deletions(-) rename Dockerfile => Dockerfile.alpine (100%) diff --git a/.github/workflows/build-publish.yml b/.github/workflows/build-publish.yml index e962d8f3..a5ea453b 100644 --- a/.github/workflows/build-publish.yml +++ b/.github/workflows/build-publish.yml @@ -35,9 +35,8 @@ jobs: - name: Retrieve version run: echo "GIT_DESCRIBE=$(git describe --tags)" >> $GITHUB_ENV - - name: Get Docker tags for Alpine based image - if: ${{ matrix.base == 'alpine' }} - id: docker_meta_alpine + - name: Get Docker tags + id: docker_meta uses: docker/metadata-action@v4 with: images: | @@ -45,31 +44,16 @@ jobs: nginxproxy/docker-gen jwilder/docker-gen tags: | - type=semver,pattern={{version}} - type=semver,pattern={{major}}.{{minor}} - type=raw,value=latest,enable={{is_default_branch}} + type=semver,pattern={{version}},enable=${{ matrix.base == 'alpine' }} + type=semver,pattern={{major}}.{{minor}},enable=${{ matrix.base == 'alpine' }} + type=semver,suffix=-debian,pattern={{version}},enable=${{ matrix.base == 'debian' }} + type=semver,suffix=-debian,pattern={{major}}.{{minor}},enable=${{ matrix.base == 'debian' }} + type=raw,value=latest,enable=${{ github.ref == 'refs/heads/main' && matrix.base == 'alpine' }} + type=raw,value=debian,enable=${{ github.ref == 'refs/heads/main' && matrix.base == 'debian' }} labels: | org.opencontainers.image.authors=Nicolas Duchon (@buchdag), Jason Wilder org.opencontainers.image.version=${{ env.GIT_DESCRIBE }} - - name: Get Docker tags for Debian based image - if: ${{ matrix.base == 'debian' }} - id: docker_meta_debian - uses: docker/metadata-action@v4 - with: - images: | - ghcr.io/nginx-proxy/docker-gen - nginxproxy/docker-gen - jwilder/docker-gen - tags: | - type=semver,suffix=-debian,pattern={{version}} - type=semver,suffix=-debian,pattern={{major}}.{{minor}} - type=raw,value=debian,enable={{is_default_branch}} - labels: | - org.opencontainers.image.authors=Nicolas Duchon (@buchdag), Jason Wilder - org.opencontainers.image.version=${{ env.GIT_DESCRIBE }} - flavor: latest=false - - name: Set up QEMU uses: docker/setup-qemu-action@v2 @@ -89,35 +73,17 @@ jobs: username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - - name: Build and push the Alpine based image - if: ${{ matrix.base == 'alpine' }} - id: docker_build_alpine + - name: Build and push the image + id: docker_build uses: docker/build-push-action@v4 with: context: . build-args: DOCKER_GEN_VERSION=${{ env.GIT_DESCRIBE }} platforms: linux/amd64,linux/arm64,linux/arm/v7 + file: Dockerfile.${{ matrix.base }} push: true - tags: ${{ steps.docker_meta_alpine.outputs.tags }} - labels: ${{ steps.docker_meta_alpine.outputs.labels }} - - - name: Build and push the Debian based image - if: ${{ matrix.base == 'debian' }} - id: docker_build_debian - uses: docker/build-push-action@v4 - with: - context: . - build-args: DOCKER_GEN_VERSION=${{ env.GIT_DESCRIBE }} - file: Dockerfile.debian - platforms: linux/amd64,linux/arm64,linux/arm/v7 - push: true - tags: ${{ steps.docker_meta_debian.outputs.tags }} - labels: ${{ steps.docker_meta_debian.outputs.labels }} - - - name: Alpine based image digest - if: ${{ matrix.base == 'alpine' }} - run: echo ${{ steps.docker_build_alpine.outputs.digest }} + tags: ${{ steps.docker_meta.outputs.tags }} + labels: ${{ steps.docker_meta.outputs.labels }} - - name: Debian based image digest - if: ${{ matrix.base == 'debian' }} - run: echo ${{ steps.docker_build_debian.outputs.digest }} + - name: Docker image digest + run: echo ${{ steps.docker_build.outputs.digest }} diff --git a/Dockerfile b/Dockerfile.alpine similarity index 100% rename from Dockerfile rename to Dockerfile.alpine From 89cc03621aa76d80ae2f8e6aa9c1e098a898f3d2 Mon Sep 17 00:00:00 2001 From: Nicolas Duchon Date: Mon, 8 May 2023 17:04:49 +0200 Subject: [PATCH 2/5] ci: use step outputs rather than env --- .github/workflows/build-publish.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build-publish.yml b/.github/workflows/build-publish.yml index a5ea453b..cbb42ee7 100644 --- a/.github/workflows/build-publish.yml +++ b/.github/workflows/build-publish.yml @@ -33,7 +33,8 @@ jobs: fetch-depth: 0 - name: Retrieve version - run: echo "GIT_DESCRIBE=$(git describe --tags)" >> $GITHUB_ENV + id: docker-gen_version + run: echo "VERSION=$(git describe --tags)" >> "$GITHUB_OUTPUT" - name: Get Docker tags id: docker_meta @@ -52,7 +53,7 @@ jobs: type=raw,value=debian,enable=${{ github.ref == 'refs/heads/main' && matrix.base == 'debian' }} labels: | org.opencontainers.image.authors=Nicolas Duchon (@buchdag), Jason Wilder - org.opencontainers.image.version=${{ env.GIT_DESCRIBE }} + org.opencontainers.image.version=${{ steps.docker-gen_version.outputs.VERSION }} - name: Set up QEMU uses: docker/setup-qemu-action@v2 @@ -78,7 +79,7 @@ jobs: uses: docker/build-push-action@v4 with: context: . - build-args: DOCKER_GEN_VERSION=${{ env.GIT_DESCRIBE }} + build-args: DOCKER_GEN_VERSION=${{ steps.docker-gen_version.outputs.VERSION }} platforms: linux/amd64,linux/arm64,linux/arm/v7 file: Dockerfile.${{ matrix.base }} push: true From 9e5eaadd354b6c36fed9e7afd19e750a669308e2 Mon Sep 17 00:00:00 2001 From: Nicolas Duchon Date: Mon, 8 May 2023 17:06:13 +0200 Subject: [PATCH 3/5] ci: enable gha caching on docker/build-push-action --- .github/workflows/build-publish.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/build-publish.yml b/.github/workflows/build-publish.yml index cbb42ee7..e6d0c7a3 100644 --- a/.github/workflows/build-publish.yml +++ b/.github/workflows/build-publish.yml @@ -85,6 +85,8 @@ jobs: push: true tags: ${{ steps.docker_meta.outputs.tags }} labels: ${{ steps.docker_meta.outputs.labels }} + cache-from: type=gha + cache-to: type=gha,mode=max - name: Docker image digest run: echo ${{ steps.docker_build.outputs.digest }} From 90151af39ac00a3e48548d17082e5d4555c4f263 Mon Sep 17 00:00:00 2001 From: Nicolas Duchon Date: Mon, 8 May 2023 17:08:23 +0200 Subject: [PATCH 4/5] ci: build Docker image for more plaforms --- .github/workflows/build-publish.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-publish.yml b/.github/workflows/build-publish.yml index e6d0c7a3..ff81796b 100644 --- a/.github/workflows/build-publish.yml +++ b/.github/workflows/build-publish.yml @@ -80,7 +80,7 @@ jobs: with: context: . build-args: DOCKER_GEN_VERSION=${{ steps.docker-gen_version.outputs.VERSION }} - platforms: linux/amd64,linux/arm64,linux/arm/v7 + platforms: linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/ppc64le,linux/s390x file: Dockerfile.${{ matrix.base }} push: true tags: ${{ steps.docker_meta.outputs.tags }} From b21526ecb7875da67598bd9de86734b7b214b4f2 Mon Sep 17 00:00:00 2001 From: Nicolas Duchon Date: Mon, 8 May 2023 17:46:29 +0200 Subject: [PATCH 5/5] ci: disable automatic latest tag handling --- .github/workflows/build-publish.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/build-publish.yml b/.github/workflows/build-publish.yml index ff81796b..cdb39e48 100644 --- a/.github/workflows/build-publish.yml +++ b/.github/workflows/build-publish.yml @@ -54,6 +54,8 @@ jobs: labels: | org.opencontainers.image.authors=Nicolas Duchon (@buchdag), Jason Wilder org.opencontainers.image.version=${{ steps.docker-gen_version.outputs.VERSION }} + flavor: | + latest=false - name: Set up QEMU uses: docker/setup-qemu-action@v2