From a6a732e1304fb0002ce96cf03fd8661600fd3078 Mon Sep 17 00:00:00 2001 From: Bob Tanner Date: Sat, 10 May 2025 19:05:18 -0500 Subject: [PATCH 01/38] First commit to build docker images via GitHub actions --- .github/actions/build-action/acton.yml | 33 ++++++++ .../actions/docker-login-action/action.yml | 22 ++++++ .github/actions/manifest-action/action.yml | 36 +++++++++ .github/workflows/docker-build.yml | 78 +++++++++++++++++++ .github/workflows/main.yml | 2 +- .gitignore | 1 + 6 files changed, 171 insertions(+), 1 deletion(-) create mode 100644 .github/actions/build-action/acton.yml create mode 100644 .github/actions/docker-login-action/action.yml create mode 100644 .github/actions/manifest-action/action.yml create mode 100644 .github/workflows/docker-build.yml diff --git a/.github/actions/build-action/acton.yml b/.github/actions/build-action/acton.yml new file mode 100644 index 00000000..e2d7efe9 --- /dev/null +++ b/.github/actions/build-action/acton.yml @@ -0,0 +1,33 @@ +name: Build Docker Images + +description: | + This action builds Docker images for multiple platforms using docker buildx. + +inputs: + platform: + description: 'Target platform for build (e.g., linux/amd64, linux/arm64)' + required: true + commit_id: + description: 'Git commit hash to tag the image' + required: true + tag_ns: + description: 'DockerHub namespace (e.g., your-dockerhub-username)' + required: true + dockerfile_path: + description: 'Path to the Dockerfile' + required: true + build_dir: + description: 'Directory of the build context' + required: true + +runs: + using: 'bash' + steps: + - name: Build Docker image for ${{ inputs.platform }} + run: | + docker buildx build \ + --platform ${{ inputs.platform }} \ + --label version.git_commit=${{ inputs.commit_id }} \ + -t ${{ inputs.tag_ns }}/mailman-core:rolling-${{ inputs.platform }} \ + -f ${{ inputs.dockerfile_path }} ${{ inputs.build_dir }} \ + --push diff --git a/.github/actions/docker-login-action/action.yml b/.github/actions/docker-login-action/action.yml new file mode 100644 index 00000000..406be9ec --- /dev/null +++ b/.github/actions/docker-login-action/action.yml @@ -0,0 +1,22 @@ +name: DockerHub Login + +description: | + This action logs in to DockerHub using GitHub secrets for username and token. + +inputs: + username: + description: 'DockerHub username' + required: true + password: + description: 'DockerHub token' + required: true + +runs: + using: 'docker' + image: 'docker://docker.io/docker:latest' + steps: + - name: Log in to DockerHub + uses: docker/login-action@v3 + with: + username: ${{ inputs.username }} + password: ${{ inputs.password }} diff --git a/.github/actions/manifest-action/action.yml b/.github/actions/manifest-action/action.yml new file mode 100644 index 00000000..39c9df51 --- /dev/null +++ b/.github/actions/manifest-action/action.yml @@ -0,0 +1,36 @@ +name: Push Multi-Arch Docker Manifests + +description: | + This action creates and pushes multi-architecture Docker image manifests. + +inputs: + tag_ns: + description: 'DockerHub namespace (e.g., your-dockerhub-username)' + required: true + commit_id: + description: 'Git commit hash to tag the image' + required: true + +runs: + using: 'bash' + steps: + - name: Push multi-arch manifests for mailman-core + run: | + docker manifest create ${{ inputs.tag_ns }}/mailman-core:rolling \ + --amend ${{ inputs.tag_ns }}/mailman-core:rolling-linux/amd64 \ + --amend ${{ inputs.tag_ns }}/mailman-core:rolling-linux/arm64 + docker manifest push ${{ inputs.tag_ns }}/mailman-core:rolling + + - name: Push multi-arch manifests for mailman-web + run: | + docker manifest create ${{ inputs.tag_ns }}/mailman-web:rolling \ + --amend ${{ inputs.tag_ns }}/mailman-web:rolling-linux/amd64 \ + --amend ${{ inputs.tag_ns }}/mailman-web:rolling-linux/arm64 + docker manifest push ${{ inputs.tag_ns }}/mailman-web:rolling + + - name: Push multi-arch manifests for postorius + run: | + docker manifest create ${{ inputs.tag_ns }}/postorius:rolling \ + --amend ${{ inputs.tag_ns }}/postorius:rolling-linux/amd64 \ + --amend ${{ inputs.tag_ns }}/postorius:rolling-linux/arm64 + docker manifest push ${{ inputs.tag_ns }}/postorius:rolling diff --git a/.github/workflows/docker-build.yml b/.github/workflows/docker-build.yml new file mode 100644 index 00000000..71058658 --- /dev/null +++ b/.github/workflows/docker-build.yml @@ -0,0 +1,78 @@ +name: Docker Multi-Arch Build + +on: + workflow_dispatch: + inputs: + build_rolling: + description: 'Build rolling images?' + required: false + default: 'no' + +env: + DOCKER_BUILDKIT: 1 + TAG_NS: your-dockerhub-username + PUSH: yes + +jobs: + build: + runs-on: ubuntu-latest + strategy: + matrix: + platform: [linux/amd64, linux/arm64] + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up QEMU for multi-platform builds + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Log in to DockerHub + uses: ./.github/actions/docker-login-action + + - name: Set COMMIT_ID + run: echo "COMMIT_ID=$(git rev-parse --short HEAD)" >> $GITHUB_ENV + + - name: Build mailman-core for ${{ matrix.platform }} + uses: ./.github/actions/build-action + with: + platform: ${{ matrix.platform }} + commit_id: ${{ env.COMMIT_ID }} + tag_ns: ${{ env.TAG_NS }} + dockerfile_path: core/Dockerfile.dev + build_dir: core/ + + - name: Build mailman-web for ${{ matrix.platform }} + uses: ./.github/actions/build-action + with: + platform: ${{ matrix.platform }} + commit_id: ${{ env.COMMIT_ID }} + tag_ns: ${{ env.TAG_NS }} + dockerfile_path: web/Dockerfile.dev + build_dir: web/ + + - name: Build postorius for ${{ matrix.platform }} + uses: ./.github/actions/build-action + with: + platform: ${{ matrix.platform }} + commit_id: ${{ env.COMMIT_ID }} + tag_ns: ${{ env.TAG_NS }} + dockerfile_path: postorius/Dockerfile.dev + build_dir: postorius/ + + # Optional: Combine the architectures into multi-arch manifests + manifest: + needs: build + runs-on: ubuntu-latest + steps: + - name: Log in to DockerHub + uses: ./.github/actions/docker-login-action + + - name: Create and Push Multi-Arch Manifests + uses: ./.github/actions/manifest-action + with: + tag_ns: ${{ env.TAG_NS }} + commit_id: ${{ env.COMMIT_ID }} diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index d123643a..b831156c 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -2,7 +2,7 @@ name: CI -# Controls when the action will run. +# Controls when the action will run. on: # Triggers the workflow on push or pull request events but only for the master branch push: diff --git a/.gitignore b/.gitignore index feb8f08d..e3dea0e0 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ /web/mailman-web/settings_local.py pythonenv3.8/* .venv/* +zzz.diff From 9eb4c8ee7986298034ee1c8805e13bdde2f9ec8e Mon Sep 17 00:00:00 2001 From: Bob Tanner Date: Sat, 10 May 2025 19:09:51 -0500 Subject: [PATCH 02/38] Allow actions from GitHub UI Allow action on push to main and issue-731 branches --- .github/workflows/docker-build.yml | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/.github/workflows/docker-build.yml b/.github/workflows/docker-build.yml index 71058658..10ec6cda 100644 --- a/.github/workflows/docker-build.yml +++ b/.github/workflows/docker-build.yml @@ -1,12 +1,18 @@ name: Docker Multi-Arch Build on: + # Manual trigger from GitHub UI workflow_dispatch: inputs: build_rolling: description: 'Build rolling images?' required: false default: 'no' + # Auto-trigger on push to these branches + push: + branches: + - main + - issue-731 env: DOCKER_BUILDKIT: 1 @@ -21,21 +27,26 @@ jobs: platform: [linux/amd64, linux/arm64] steps: + # https://github.com/actions/checkout - name: Checkout code uses: actions/checkout@v4 + # https://github.com/docker/setup-qemu-action - name: Set up QEMU for multi-platform builds uses: docker/setup-qemu-action@v3 + # https://github.com/docker/setup-buildx-action - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 - - name: Log in to DockerHub + # Log in to DockerHub using your composite action + - name: DockerHub Login uses: ./.github/actions/docker-login-action - name: Set COMMIT_ID run: echo "COMMIT_ID=$(git rev-parse --short HEAD)" >> $GITHUB_ENV + # Build mailman-core - name: Build mailman-core for ${{ matrix.platform }} uses: ./.github/actions/build-action with: @@ -45,6 +56,7 @@ jobs: dockerfile_path: core/Dockerfile.dev build_dir: core/ + # Build mailman-web - name: Build mailman-web for ${{ matrix.platform }} uses: ./.github/actions/build-action with: @@ -54,6 +66,7 @@ jobs: dockerfile_path: web/Dockerfile.dev build_dir: web/ + # Build postorius - name: Build postorius for ${{ matrix.platform }} uses: ./.github/actions/build-action with: @@ -63,14 +76,15 @@ jobs: dockerfile_path: postorius/Dockerfile.dev build_dir: postorius/ - # Optional: Combine the architectures into multi-arch manifests manifest: needs: build runs-on: ubuntu-latest steps: - - name: Log in to DockerHub + # Log in to DockerHub again (separate job) + - name: DockerHub Login uses: ./.github/actions/docker-login-action + # Push multi-arch manifests - name: Create and Push Multi-Arch Manifests uses: ./.github/actions/manifest-action with: From 45c78dc7a9f3359d8304246e9e0068975e771ad4 Mon Sep 17 00:00:00 2001 From: Bob Tanner Date: Sat, 10 May 2025 19:14:52 -0500 Subject: [PATCH 03/38] chore: convert docker-login-action to composite and fix secret wiring - Refactor docker-login-action from Docker-based to composite to support step usage - Update docker-build.yml to provide DOCKERHUB_USERNAME and DOCKERHUB_TOKEN secrets to the login action --- .github/actions/docker-login-action/action.yml | 3 +-- .github/workflows/docker-build.yml | 4 ++++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/actions/docker-login-action/action.yml b/.github/actions/docker-login-action/action.yml index 406be9ec..56ec479d 100644 --- a/.github/actions/docker-login-action/action.yml +++ b/.github/actions/docker-login-action/action.yml @@ -12,8 +12,7 @@ inputs: required: true runs: - using: 'docker' - image: 'docker://docker.io/docker:latest' + using: "composite" steps: - name: Log in to DockerHub uses: docker/login-action@v3 diff --git a/.github/workflows/docker-build.yml b/.github/workflows/docker-build.yml index 10ec6cda..04b7b27b 100644 --- a/.github/workflows/docker-build.yml +++ b/.github/workflows/docker-build.yml @@ -42,6 +42,10 @@ jobs: # Log in to DockerHub using your composite action - name: DockerHub Login uses: ./.github/actions/docker-login-action + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + - name: Set COMMIT_ID run: echo "COMMIT_ID=$(git rev-parse --short HEAD)" >> $GITHUB_ENV From f2f3a0289654390600a62ed83b365c919dd7061c Mon Sep 17 00:00:00 2001 From: Bob Tanner Date: Sat, 10 May 2025 19:27:23 -0500 Subject: [PATCH 04/38] chore: debug using docker/login-action@v3 --- .github/workflows/docker-build.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/docker-build.yml b/.github/workflows/docker-build.yml index 04b7b27b..3a71fd87 100644 --- a/.github/workflows/docker-build.yml +++ b/.github/workflows/docker-build.yml @@ -41,7 +41,8 @@ jobs: # Log in to DockerHub using your composite action - name: DockerHub Login - uses: ./.github/actions/docker-login-action + # uses: ./.github/actions/docker-login-action + uses: docker/login-action@v3 with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} From 1d1bf8721b0d168e9bfa7faafe37c03e67e53c71 Mon Sep 17 00:00:00 2001 From: Bob Tanner Date: Sat, 10 May 2025 19:29:07 -0500 Subject: [PATCH 05/38] Use my docker hub account name --- .github/workflows/docker-build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docker-build.yml b/.github/workflows/docker-build.yml index 3a71fd87..87fcf5ac 100644 --- a/.github/workflows/docker-build.yml +++ b/.github/workflows/docker-build.yml @@ -16,7 +16,7 @@ on: env: DOCKER_BUILDKIT: 1 - TAG_NS: your-dockerhub-username + TAG_NS: basictheprogram PUSH: yes jobs: From 03e3b5e31c94bd4014b21b3b70f49299e86af475 Mon Sep 17 00:00:00 2001 From: Bob Tanner Date: Sat, 10 May 2025 19:45:16 -0500 Subject: [PATCH 06/38] Ensures that all matrix jobs run to completion, even if one fails. All matrix jobs to continue regardless of outcome --- .../actions/docker-login-action/action.yml | 21 ------------------- .github/workflows/docker-build.yml | 18 +++++++++------- 2 files changed, 11 insertions(+), 28 deletions(-) delete mode 100644 .github/actions/docker-login-action/action.yml diff --git a/.github/actions/docker-login-action/action.yml b/.github/actions/docker-login-action/action.yml deleted file mode 100644 index 56ec479d..00000000 --- a/.github/actions/docker-login-action/action.yml +++ /dev/null @@ -1,21 +0,0 @@ -name: DockerHub Login - -description: | - This action logs in to DockerHub using GitHub secrets for username and token. - -inputs: - username: - description: 'DockerHub username' - required: true - password: - description: 'DockerHub token' - required: true - -runs: - using: "composite" - steps: - - name: Log in to DockerHub - uses: docker/login-action@v3 - with: - username: ${{ inputs.username }} - password: ${{ inputs.password }} diff --git a/.github/workflows/docker-build.yml b/.github/workflows/docker-build.yml index 87fcf5ac..0aff942f 100644 --- a/.github/workflows/docker-build.yml +++ b/.github/workflows/docker-build.yml @@ -25,6 +25,9 @@ jobs: strategy: matrix: platform: [linux/amd64, linux/arm64] + fail-fast: false + + continue-on-error: true steps: # https://github.com/actions/checkout @@ -39,15 +42,13 @@ jobs: - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 - # Log in to DockerHub using your composite action - - name: DockerHub Login - # uses: ./.github/actions/docker-login-action + # https://github.com/docker/login-action + - name: Login to DockerHub uses: docker/login-action@v3 with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} - - name: Set COMMIT_ID run: echo "COMMIT_ID=$(git rev-parse --short HEAD)" >> $GITHUB_ENV @@ -85,9 +86,12 @@ jobs: needs: build runs-on: ubuntu-latest steps: - # Log in to DockerHub again (separate job) - - name: DockerHub Login - uses: ./.github/actions/docker-login-action + # https://github.com/docker/login-action + - name: Login to DockerHub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} # Push multi-arch manifests - name: Create and Push Multi-Arch Manifests From 3589323acdc88c75154b9de937653ad97ec125b7 Mon Sep 17 00:00:00 2001 From: Bob Tanner Date: Sat, 10 May 2025 19:50:36 -0500 Subject: [PATCH 07/38] Fixed typo in file name --- .github/actions/build-action/{acton.yml => action.yml} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .github/actions/build-action/{acton.yml => action.yml} (100%) diff --git a/.github/actions/build-action/acton.yml b/.github/actions/build-action/action.yml similarity index 100% rename from .github/actions/build-action/acton.yml rename to .github/actions/build-action/action.yml From 1b7447fb119a375cab4b5426905d651d2fe7bdb6 Mon Sep 17 00:00:00 2001 From: Bob Tanner Date: Sat, 10 May 2025 19:56:15 -0500 Subject: [PATCH 08/38] Fixed indentation and whitespaces --- .github/actions/build-action/action.yml | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/.github/actions/build-action/action.yml b/.github/actions/build-action/action.yml index e2d7efe9..2dfaed59 100644 --- a/.github/actions/build-action/action.yml +++ b/.github/actions/build-action/action.yml @@ -21,13 +21,14 @@ inputs: required: true runs: - using: 'bash' + using: "composite" steps: - - name: Build Docker image for ${{ inputs.platform }} + - name: Build Docker image + shell: bash run: | docker buildx build \ - --platform ${{ inputs.platform }} \ - --label version.git_commit=${{ inputs.commit_id }} \ - -t ${{ inputs.tag_ns }}/mailman-core:rolling-${{ inputs.platform }} \ - -f ${{ inputs.dockerfile_path }} ${{ inputs.build_dir }} \ + --platform "${{ inputs.platform }}" \ + --label version.git_commit="${{ inputs.commit_id }}" \ + -t "${{ inputs.tag_ns }}/mailman-core:rolling-${{ inputs.platform }}" \ + -f "${{ inputs.dockerfile_path }}" "${{ inputs.build_dir }}" \ --push From 777cbb38184c1d6f6315ddac415877cf2b35958b Mon Sep 17 00:00:00 2001 From: Bob Tanner Date: Sat, 10 May 2025 20:00:11 -0500 Subject: [PATCH 09/38] Replace '/' with '-' to make it tag-safe --- .github/actions/build-action/action.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/actions/build-action/action.yml b/.github/actions/build-action/action.yml index 2dfaed59..3df3734c 100644 --- a/.github/actions/build-action/action.yml +++ b/.github/actions/build-action/action.yml @@ -26,9 +26,13 @@ runs: - name: Build Docker image shell: bash run: | + # Replace '/' with '-' to make it tag-safe + safe_platform="${{ inputs.platform }}" + safe_platform="${safe_platform//\//-}" + docker buildx build \ --platform "${{ inputs.platform }}" \ --label version.git_commit="${{ inputs.commit_id }}" \ - -t "${{ inputs.tag_ns }}/mailman-core:rolling-${{ inputs.platform }}" \ + -t "${{ inputs.tag_ns }}/mailman-core:rolling-${safe_platform}" \ -f "${{ inputs.dockerfile_path }}" "${{ inputs.build_dir }}" \ --push From 701c98d459b624aa20c7f4ce3fad4df210323bc7 Mon Sep 17 00:00:00 2001 From: Bob Tanner Date: Sat, 10 May 2025 21:01:35 -0500 Subject: [PATCH 10/38] Refactor the manifest to use the compose workflow --- .github/actions/manifest-action/action.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/actions/manifest-action/action.yml b/.github/actions/manifest-action/action.yml index 39c9df51..147450ff 100644 --- a/.github/actions/manifest-action/action.yml +++ b/.github/actions/manifest-action/action.yml @@ -12,9 +12,10 @@ inputs: required: true runs: - using: 'bash' + using: "composite" steps: - name: Push multi-arch manifests for mailman-core + shell: bash run: | docker manifest create ${{ inputs.tag_ns }}/mailman-core:rolling \ --amend ${{ inputs.tag_ns }}/mailman-core:rolling-linux/amd64 \ @@ -22,6 +23,7 @@ runs: docker manifest push ${{ inputs.tag_ns }}/mailman-core:rolling - name: Push multi-arch manifests for mailman-web + shell: bash run: | docker manifest create ${{ inputs.tag_ns }}/mailman-web:rolling \ --amend ${{ inputs.tag_ns }}/mailman-web:rolling-linux/amd64 \ @@ -29,6 +31,7 @@ runs: docker manifest push ${{ inputs.tag_ns }}/mailman-web:rolling - name: Push multi-arch manifests for postorius + shell: bash run: | docker manifest create ${{ inputs.tag_ns }}/postorius:rolling \ --amend ${{ inputs.tag_ns }}/postorius:rolling-linux/amd64 \ From 869001051edfee531726bc5f72c4c126a1f53019 Mon Sep 17 00:00:00 2001 From: Bob Tanner Date: Sun, 11 May 2025 08:48:27 -0500 Subject: [PATCH 11/38] Checkout the project before working on it? --- .github/workflows/docker-build.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/docker-build.yml b/.github/workflows/docker-build.yml index 0aff942f..2f9ef1f0 100644 --- a/.github/workflows/docker-build.yml +++ b/.github/workflows/docker-build.yml @@ -86,6 +86,10 @@ jobs: needs: build runs-on: ubuntu-latest steps: + # https://github.com/actions/checkout + - name: Checkout code + uses: actions/checkout@v4 + # https://github.com/docker/login-action - name: Login to DockerHub uses: docker/login-action@v3 From 31a239d6df20dd079acf7396ea94a80726849ec5 Mon Sep 17 00:00:00 2001 From: Bob Tanner Date: Sun, 11 May 2025 09:45:08 -0500 Subject: [PATCH 12/38] Fix for invalid referance format --- .github/actions/manifest-action/action.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/actions/manifest-action/action.yml b/.github/actions/manifest-action/action.yml index 147450ff..e4201043 100644 --- a/.github/actions/manifest-action/action.yml +++ b/.github/actions/manifest-action/action.yml @@ -18,22 +18,22 @@ runs: shell: bash run: | docker manifest create ${{ inputs.tag_ns }}/mailman-core:rolling \ - --amend ${{ inputs.tag_ns }}/mailman-core:rolling-linux/amd64 \ - --amend ${{ inputs.tag_ns }}/mailman-core:rolling-linux/arm64 + --amend ${{ inputs.tag_ns }}/mailman-core:rolling-linux-amd64 \ + --amend ${{ inputs.tag_ns }}/mailman-core:rolling-linux-arm64 docker manifest push ${{ inputs.tag_ns }}/mailman-core:rolling - name: Push multi-arch manifests for mailman-web shell: bash run: | docker manifest create ${{ inputs.tag_ns }}/mailman-web:rolling \ - --amend ${{ inputs.tag_ns }}/mailman-web:rolling-linux/amd64 \ - --amend ${{ inputs.tag_ns }}/mailman-web:rolling-linux/arm64 + --amend ${{ inputs.tag_ns }}/mailman-web:rolling-linux-amd64 \ + --amend ${{ inputs.tag_ns }}/mailman-web:rolling-linux-arm64 docker manifest push ${{ inputs.tag_ns }}/mailman-web:rolling - name: Push multi-arch manifests for postorius shell: bash run: | docker manifest create ${{ inputs.tag_ns }}/postorius:rolling \ - --amend ${{ inputs.tag_ns }}/postorius:rolling-linux/amd64 \ - --amend ${{ inputs.tag_ns }}/postorius:rolling-linux/arm64 + --amend ${{ inputs.tag_ns }}/postorius:rolling-linux-amd64 \ + --amend ${{ inputs.tag_ns }}/postorius:rolling-linux-arm64 docker manifest push ${{ inputs.tag_ns }}/postorius:rolling From 70b15ff2717f25304679277a77b9d405e2d4b6b1 Mon Sep 17 00:00:00 2001 From: Bob Tanner Date: Sun, 11 May 2025 10:32:39 -0500 Subject: [PATCH 13/38] Attempt to build and push and /not/ user manifests --- .github/workflows/docker-build.yml | 38 +++++++++++++++--------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/.github/workflows/docker-build.yml b/.github/workflows/docker-build.yml index 2f9ef1f0..3b974f5a 100644 --- a/.github/workflows/docker-build.yml +++ b/.github/workflows/docker-build.yml @@ -82,24 +82,24 @@ jobs: dockerfile_path: postorius/Dockerfile.dev build_dir: postorius/ - manifest: - needs: build - runs-on: ubuntu-latest - steps: - # https://github.com/actions/checkout - - name: Checkout code - uses: actions/checkout@v4 + # manifest: + # needs: build + # runs-on: ubuntu-latest + # steps: + # # https://github.com/actions/checkout + # - name: Checkout code + # uses: actions/checkout@v4 - # https://github.com/docker/login-action - - name: Login to DockerHub - uses: docker/login-action@v3 - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} + # # https://github.com/docker/login-action + # - name: Login to DockerHub + # uses: docker/login-action@v3 + # with: + # username: ${{ secrets.DOCKERHUB_USERNAME }} + # password: ${{ secrets.DOCKERHUB_TOKEN }} - # Push multi-arch manifests - - name: Create and Push Multi-Arch Manifests - uses: ./.github/actions/manifest-action - with: - tag_ns: ${{ env.TAG_NS }} - commit_id: ${{ env.COMMIT_ID }} + # # Push multi-arch manifests + # - name: Create and Push Multi-Arch Manifests + # uses: ./.github/actions/manifest-action + # with: + # tag_ns: ${{ env.TAG_NS }} + # commit_id: ${{ env.COMMIT_ID }} From 4f23f028cd32fcfe0911b68ae3686a986128bccf Mon Sep 17 00:00:00 2001 From: Bob Tanner Date: Sun, 11 May 2025 11:19:34 -0500 Subject: [PATCH 14/38] Pass in image_name to the build action --- .github/actions/build-action/action.yml | 5 ++++- .github/workflows/docker-build.yml | 3 +++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/actions/build-action/action.yml b/.github/actions/build-action/action.yml index 3df3734c..155b6421 100644 --- a/.github/actions/build-action/action.yml +++ b/.github/actions/build-action/action.yml @@ -4,6 +4,9 @@ description: | This action builds Docker images for multiple platforms using docker buildx. inputs: + image_name: + description: 'Name of the Docker image (e.g., mailman-core, mailman-web, postorius)' + required: true platform: description: 'Target platform for build (e.g., linux/amd64, linux/arm64)' required: true @@ -33,6 +36,6 @@ runs: docker buildx build \ --platform "${{ inputs.platform }}" \ --label version.git_commit="${{ inputs.commit_id }}" \ - -t "${{ inputs.tag_ns }}/mailman-core:rolling-${safe_platform}" \ + -t "${{ inputs.tag_ns }}/${{ image_name }}:rolling-${safe_platform}" \ -f "${{ inputs.dockerfile_path }}" "${{ inputs.build_dir }}" \ --push diff --git a/.github/workflows/docker-build.yml b/.github/workflows/docker-build.yml index 3b974f5a..37d36316 100644 --- a/.github/workflows/docker-build.yml +++ b/.github/workflows/docker-build.yml @@ -56,6 +56,7 @@ jobs: - name: Build mailman-core for ${{ matrix.platform }} uses: ./.github/actions/build-action with: + image_name: mailman-core platform: ${{ matrix.platform }} commit_id: ${{ env.COMMIT_ID }} tag_ns: ${{ env.TAG_NS }} @@ -66,6 +67,7 @@ jobs: - name: Build mailman-web for ${{ matrix.platform }} uses: ./.github/actions/build-action with: + image_name: mailman-web platform: ${{ matrix.platform }} commit_id: ${{ env.COMMIT_ID }} tag_ns: ${{ env.TAG_NS }} @@ -76,6 +78,7 @@ jobs: - name: Build postorius for ${{ matrix.platform }} uses: ./.github/actions/build-action with: + image_name: postorius platform: ${{ matrix.platform }} commit_id: ${{ env.COMMIT_ID }} tag_ns: ${{ env.TAG_NS }} From 89ecafe204ed5ab81d801bba2fb27666ccec5699 Mon Sep 17 00:00:00 2001 From: Bob Tanner Date: Sun, 11 May 2025 11:24:57 -0500 Subject: [PATCH 15/38] Fixed variable reference Using image_name without the inputs --- .github/actions/build-action/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/actions/build-action/action.yml b/.github/actions/build-action/action.yml index 155b6421..90f00095 100644 --- a/.github/actions/build-action/action.yml +++ b/.github/actions/build-action/action.yml @@ -36,6 +36,6 @@ runs: docker buildx build \ --platform "${{ inputs.platform }}" \ --label version.git_commit="${{ inputs.commit_id }}" \ - -t "${{ inputs.tag_ns }}/${{ image_name }}:rolling-${safe_platform}" \ + -t "${{ inputs.tag_ns }}/${{ inputs.image_name }}:rolling-${safe_platform}" \ -f "${{ inputs.dockerfile_path }}" "${{ inputs.build_dir }}" \ --push From 84859d99c1863978f6cdfaa7ec259646d70ec06d Mon Sep 17 00:00:00 2001 From: Bob Tanner Date: Sun, 11 May 2025 12:49:45 -0500 Subject: [PATCH 16/38] feat(ci): tag Docker images based on Git tag version - Trigger workflow on version tags matching 'v*' - Introduce `version` job to extract semantic version components (major, minor, full) - Make `build` job depend on `version` and pass version metadata to build-action - Enable multi-version tagging support (vX.Y.Z, vX.Y, vX) for Docker images --- .github/workflows/docker-build.yml | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/.github/workflows/docker-build.yml b/.github/workflows/docker-build.yml index 37d36316..632653a3 100644 --- a/.github/workflows/docker-build.yml +++ b/.github/workflows/docker-build.yml @@ -8,11 +8,14 @@ on: description: 'Build rolling images?' required: false default: 'no' + # Auto-trigger on push to these branches push: branches: - main - issue-731 + tags: + - 'v*' env: DOCKER_BUILDKIT: 1 @@ -20,8 +23,27 @@ env: PUSH: yes jobs: + version: + if: startsWith(github.ref, 'refs/tags/v') + runs-on: ubuntu-latest + outputs: + full: ${{ steps.extract.outputs.full }} + minor: ${{ steps.extract.outputs.minor }} + major: ${{ steps.extract.outputs.major }} + steps: + - name: Extract version parts + id: extract + run: | + RAW_TAG="${GITHUB_REF##*/}" + VERSION="${RAW_TAG#v}" + IFS='.' read -r MAJOR MINOR PATCH <<< "$VERSION" + echo "full=$VERSION" >> $GITHUB_OUTPUT + echo "minor=${MAJOR}.${MINOR}" >> $GITHUB_OUTPUT + echo "major=${MAJOR}" >> $GITHUB_OUTPUT + build: runs-on: ubuntu-latest + needs: [version] strategy: matrix: platform: [linux/amd64, linux/arm64] @@ -62,6 +84,9 @@ jobs: tag_ns: ${{ env.TAG_NS }} dockerfile_path: core/Dockerfile.dev build_dir: core/ + version_full: ${{ needs.version.outputs.full }} + version_minor: ${{ needs.version.outputs.minor }} + version_major: ${{ needs.version.outputs.major }} # Build mailman-web - name: Build mailman-web for ${{ matrix.platform }} From cc3520f58c248178e1e8700f61419ef2a574b753 Mon Sep 17 00:00:00 2001 From: Bob Tanner Date: Sun, 11 May 2025 13:01:37 -0500 Subject: [PATCH 17/38] refactor(workflow): inline version extraction with default fallback - Removed the separate 'version' job in favor of an inline step in the 'build' job - Version info is now extracted directly from the tag if available, or defaults to 0.5.2 - Simplifies workflow structure while maintaining version tagging behavior --- .github/workflows/docker-build.yml | 34 ++++++++++++++---------------- 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/.github/workflows/docker-build.yml b/.github/workflows/docker-build.yml index 632653a3..99876948 100644 --- a/.github/workflows/docker-build.yml +++ b/.github/workflows/docker-build.yml @@ -23,24 +23,6 @@ env: PUSH: yes jobs: - version: - if: startsWith(github.ref, 'refs/tags/v') - runs-on: ubuntu-latest - outputs: - full: ${{ steps.extract.outputs.full }} - minor: ${{ steps.extract.outputs.minor }} - major: ${{ steps.extract.outputs.major }} - steps: - - name: Extract version parts - id: extract - run: | - RAW_TAG="${GITHUB_REF##*/}" - VERSION="${RAW_TAG#v}" - IFS='.' read -r MAJOR MINOR PATCH <<< "$VERSION" - echo "full=$VERSION" >> $GITHUB_OUTPUT - echo "minor=${MAJOR}.${MINOR}" >> $GITHUB_OUTPUT - echo "major=${MAJOR}" >> $GITHUB_OUTPUT - build: runs-on: ubuntu-latest needs: [version] @@ -74,6 +56,22 @@ jobs: - name: Set COMMIT_ID run: echo "COMMIT_ID=$(git rev-parse --short HEAD)" >> $GITHUB_ENV + - name: Extract version info + id: versioning + run: | + if [[ "${GITHUB_REF}" == refs/tags/v* ]]; then + RAW_TAG="${GITHUB_REF##*/}" + VERSION="${RAW_TAG#v}" + else + VERSION="0.5.2" + fi + + IFS='.' read -r MAJOR MINOR PATCH <<< "$VERSION" + + echo "full=$VERSION" >> $GITHUB_OUTPUT + echo "minor=${MAJOR}.${MINOR}" >> $GITHUB_OUTPUT + echo "major=${MAJOR}" >> $GITHUB_OUTPUT + # Build mailman-core - name: Build mailman-core for ${{ matrix.platform }} uses: ./.github/actions/build-action From 036723755a747ed62a626850adb8c76b8aa4dc32 Mon Sep 17 00:00:00 2001 From: Bob Tanner Date: Sun, 11 May 2025 13:02:23 -0500 Subject: [PATCH 18/38] The workflow must contain at least one job with no dependencies. --- .github/workflows/docker-build.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/docker-build.yml b/.github/workflows/docker-build.yml index 99876948..4fc58c84 100644 --- a/.github/workflows/docker-build.yml +++ b/.github/workflows/docker-build.yml @@ -25,7 +25,6 @@ env: jobs: build: runs-on: ubuntu-latest - needs: [version] strategy: matrix: platform: [linux/amd64, linux/arm64] From 9d0ec1527a07c691c54ee0e51a3cbe44a37f27c0 Mon Sep 17 00:00:00 2001 From: Bob Tanner Date: Sun, 11 May 2025 13:16:02 -0500 Subject: [PATCH 19/38] Use ${{ steps.versioning.outputs.* }} to access the values. --- .github/workflows/docker-build.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/docker-build.yml b/.github/workflows/docker-build.yml index 4fc58c84..5a889ff8 100644 --- a/.github/workflows/docker-build.yml +++ b/.github/workflows/docker-build.yml @@ -81,9 +81,9 @@ jobs: tag_ns: ${{ env.TAG_NS }} dockerfile_path: core/Dockerfile.dev build_dir: core/ - version_full: ${{ needs.version.outputs.full }} - version_minor: ${{ needs.version.outputs.minor }} - version_major: ${{ needs.version.outputs.major }} + version_full: ${{ steps.version.outputs.full }} + version_minor: ${{ steps.version.outputs.minor }} + version_major: ${{ steps.version.outputs.major }} # Build mailman-web - name: Build mailman-web for ${{ matrix.platform }} From 6b6deac9ad3d5c7ea3d4bfd6edc022a43609db6f Mon Sep 17 00:00:00 2001 From: Bob Tanner Date: Sun, 11 May 2025 13:30:11 -0500 Subject: [PATCH 20/38] Use version not versioning --- .github/workflows/docker-build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docker-build.yml b/.github/workflows/docker-build.yml index 5a889ff8..6867fa3e 100644 --- a/.github/workflows/docker-build.yml +++ b/.github/workflows/docker-build.yml @@ -56,7 +56,7 @@ jobs: run: echo "COMMIT_ID=$(git rev-parse --short HEAD)" >> $GITHUB_ENV - name: Extract version info - id: versioning + id: version run: | if [[ "${GITHUB_REF}" == refs/tags/v* ]]; then RAW_TAG="${GITHUB_REF##*/}" From d352ceddf09cd3c4cb6e92ff658187e8c960edff Mon Sep 17 00:00:00 2001 From: Bob Tanner Date: Wed, 14 May 2025 11:01:26 -0500 Subject: [PATCH 21/38] Added full version and major version tags to the image --- .github/actions/build-action/action.yml | 29 ++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/.github/actions/build-action/action.yml b/.github/actions/build-action/action.yml index 90f00095..2a982487 100644 --- a/.github/actions/build-action/action.yml +++ b/.github/actions/build-action/action.yml @@ -22,14 +22,24 @@ inputs: build_dir: description: 'Directory of the build context' required: true + version_full: + description: 'Full version string (e.g., 0.5.2)' + required: true + version_minor: + description: 'Minor version string (e.g., 0.5)' + required: true + version_major: + description: 'Major version string (e.g., 0)' + required: true runs: using: "composite" steps: - - name: Build Docker image + - name: Build Rolling Release for ${{ inputs.platform }} shell: bash run: | # Replace '/' with '-' to make it tag-safe + set -e safe_platform="${{ inputs.platform }}" safe_platform="${safe_platform//\//-}" @@ -39,3 +49,20 @@ runs: -t "${{ inputs.tag_ns }}/${{ inputs.image_name }}:rolling-${safe_platform}" \ -f "${{ inputs.dockerfile_path }}" "${{ inputs.build_dir }}" \ --push + + - name: Tag and Push Versioned Images + shell: bash + run: | + set -e + safe_platform="${{ inputs.platform }}" + safe_platform="${safe_platform//\//-}" + + for version_tag in "${{ inputs.version_full }}" "${{ inputs.version_minor }}" "${{ inputs.version_major }}"; do + echo "Tagging and pushing: $version_tag" + docker buildx build \ + --platform "${{ inputs.platform }}" \ + --label version.git_commit="${{ inputs.commit_id }}" \ + -t "${{ inputs.tag_ns }}/${{ inputs.image_name }}:${version_tag}" \ + -f "${{ inputs.dockerfile_path }}" "${{ inputs.build_dir }}" \ + --push + done From 4179b4d0b7de07543b420787c37ca6184a57e2b3 Mon Sep 17 00:00:00 2001 From: Bob Tanner Date: Wed, 14 May 2025 12:34:35 -0500 Subject: [PATCH 22/38] Add in version_full, version_major variables --- .github/workflows/docker-build.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/docker-build.yml b/.github/workflows/docker-build.yml index 6867fa3e..eadcf23b 100644 --- a/.github/workflows/docker-build.yml +++ b/.github/workflows/docker-build.yml @@ -95,6 +95,9 @@ jobs: tag_ns: ${{ env.TAG_NS }} dockerfile_path: web/Dockerfile.dev build_dir: web/ + version_full: ${{ steps.version.outputs.full }} + version_minor: ${{ steps.version.outputs.minor }} + version_major: ${{ steps.version.outputs.major }} # Build postorius - name: Build postorius for ${{ matrix.platform }} @@ -106,6 +109,9 @@ jobs: tag_ns: ${{ env.TAG_NS }} dockerfile_path: postorius/Dockerfile.dev build_dir: postorius/ + version_full: ${{ steps.version.outputs.full }} + version_minor: ${{ steps.version.outputs.minor }} + version_major: ${{ steps.version.outputs.major }} # manifest: # needs: build From fa7a74ba8c1915596b4ce522183ab150e2f93e0c Mon Sep 17 00:00:00 2001 From: Bob Tanner Date: Wed, 14 May 2025 14:20:00 -0500 Subject: [PATCH 23/38] Only tag versioned images when things are "git tagged" is used --- .github/actions/build-action/action.yml | 27 +++++++++++++++---------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/.github/actions/build-action/action.yml b/.github/actions/build-action/action.yml index 2a982487..5c520830 100644 --- a/.github/actions/build-action/action.yml +++ b/.github/actions/build-action/action.yml @@ -54,15 +54,20 @@ runs: shell: bash run: | set -e - safe_platform="${{ inputs.platform }}" - safe_platform="${safe_platform//\//-}" + if [[ "${GITHUB_REF}" == refs/tags/* ]]; then + + safe_platform="${{ inputs.platform }}" + safe_platform="${safe_platform//\//-}" - for version_tag in "${{ inputs.version_full }}" "${{ inputs.version_minor }}" "${{ inputs.version_major }}"; do - echo "Tagging and pushing: $version_tag" - docker buildx build \ - --platform "${{ inputs.platform }}" \ - --label version.git_commit="${{ inputs.commit_id }}" \ - -t "${{ inputs.tag_ns }}/${{ inputs.image_name }}:${version_tag}" \ - -f "${{ inputs.dockerfile_path }}" "${{ inputs.build_dir }}" \ - --push - done + for version_tag in "${{ inputs.version_full }}" "${{ inputs.version_major }}"; do + echo "Tagging and pushing: $version_tag" + docker buildx build \ + --platform "${{ inputs.platform }}" \ + --label version.git_commit="${{ inputs.commit_id }}" \ + -t "${{ inputs.tag_ns }}/${{ inputs.image_name }}:${version_tag}" \ + -f "${{ inputs.dockerfile_path }}" "${{ inputs.build_dir }}" \ + --push + done + else + echo "No git tag detected; skipping versioned image tagging." + fi From d8c92b13d7b9a886956336144577e94b9de09305 Mon Sep 17 00:00:00 2001 From: Bob Tanner Date: Wed, 14 May 2025 18:07:37 -0500 Subject: [PATCH 24/38] Refactor version tags to be MAJOR.MINOR --- .github/actions/build-action/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/actions/build-action/action.yml b/.github/actions/build-action/action.yml index 5c520830..cf86b08c 100644 --- a/.github/actions/build-action/action.yml +++ b/.github/actions/build-action/action.yml @@ -59,7 +59,7 @@ runs: safe_platform="${{ inputs.platform }}" safe_platform="${safe_platform//\//-}" - for version_tag in "${{ inputs.version_full }}" "${{ inputs.version_major }}"; do + for version_tag in "${{ inputs.version_full }}" "${{ inputs.version_major }}."${{ inputs.version_minor }}"; do echo "Tagging and pushing: $version_tag" docker buildx build \ --platform "${{ inputs.platform }}" \ From 84b752d92133b7eb3e43ec2cbb01cfdb85e1517a Mon Sep 17 00:00:00 2001 From: Bob Tanner Date: Wed, 14 May 2025 18:25:17 -0500 Subject: [PATCH 25/38] Removed stray quotes --- .github/actions/build-action/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/actions/build-action/action.yml b/.github/actions/build-action/action.yml index cf86b08c..83723c29 100644 --- a/.github/actions/build-action/action.yml +++ b/.github/actions/build-action/action.yml @@ -59,7 +59,7 @@ runs: safe_platform="${{ inputs.platform }}" safe_platform="${safe_platform//\//-}" - for version_tag in "${{ inputs.version_full }}" "${{ inputs.version_major }}."${{ inputs.version_minor }}"; do + for version_tag in "${{ inputs.version_full }}" "${{ inputs.version_major }}.${{ inputs.version_minor }}"; do echo "Tagging and pushing: $version_tag" docker buildx build \ --platform "${{ inputs.platform }}" \ From e626a81df47bd0e19ef88e7815cf17f86c2cdbf3 Mon Sep 17 00:00:00 2001 From: Bob Tanner Date: Wed, 14 May 2025 18:56:52 -0500 Subject: [PATCH 26/38] =?UTF-8?q?Fixed=20the=20problem=20caused=20by=20Bas?= =?UTF-8?q?h=20not=20expanding=20${{=20inputs.*=20}}=20inside=20the=20loop?= =?UTF-8?q?=20=E2=80=94=20those=20expressions=20are=20only=20parsed=20by?= =?UTF-8?q?=20GitHub=20Actions=20outside=20the=20script=20block.=20Inside?= =?UTF-8?q?=20the=20run:=20|=20block=20(a=20Bash=20script),=20they=20becom?= =?UTF-8?q?e=20plain=20text=20strings.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/actions/build-action/action.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/actions/build-action/action.yml b/.github/actions/build-action/action.yml index 83723c29..3383c7b0 100644 --- a/.github/actions/build-action/action.yml +++ b/.github/actions/build-action/action.yml @@ -59,7 +59,11 @@ runs: safe_platform="${{ inputs.platform }}" safe_platform="${safe_platform//\//-}" - for version_tag in "${{ inputs.version_full }}" "${{ inputs.version_major }}.${{ inputs.version_minor }}"; do + version_full="${{ inputs.version_full }}" + version_minor="${{ inputs.version_minor }}" + version_major="${{ inputs.version_major }}" + + for version_tag in "$version_full" "${version_major}.${version_minor}"; do echo "Tagging and pushing: $version_tag" docker buildx build \ --platform "${{ inputs.platform }}" \ From 78eb8d2432eccee8ea068d8a818dab3b5e75301b Mon Sep 17 00:00:00 2001 From: Bob Tanner Date: Wed, 14 May 2025 21:38:11 -0500 Subject: [PATCH 27/38] This should NOT run release tags --- .github/actions/build-action/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/actions/build-action/action.yml b/.github/actions/build-action/action.yml index 3383c7b0..816eb98f 100644 --- a/.github/actions/build-action/action.yml +++ b/.github/actions/build-action/action.yml @@ -60,8 +60,8 @@ runs: safe_platform="${safe_platform//\//-}" version_full="${{ inputs.version_full }}" - version_minor="${{ inputs.version_minor }}" version_major="${{ inputs.version_major }}" + version_minor="${{ inputs.version_minor }}" for version_tag in "$version_full" "${version_major}.${version_minor}"; do echo "Tagging and pushing: $version_tag" From 0056c5a751f46cc0ab93ac45c5c1b89bdf044c96 Mon Sep 17 00:00:00 2001 From: Bob Tanner Date: Thu, 15 May 2025 20:30:57 -0500 Subject: [PATCH 28/38] minor=${MAJOR}.${MINOR} --- .github/actions/build-action/action.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/actions/build-action/action.yml b/.github/actions/build-action/action.yml index 816eb98f..a56233b0 100644 --- a/.github/actions/build-action/action.yml +++ b/.github/actions/build-action/action.yml @@ -61,9 +61,9 @@ runs: version_full="${{ inputs.version_full }}" version_major="${{ inputs.version_major }}" - version_minor="${{ inputs.version_minor }}" + version_minor="${{ inputs.version_minor }}" # version_minor is ${MAJOR}.${MINOR} - for version_tag in "$version_full" "${version_major}.${version_minor}"; do + for version_tag in "$version_full" "${version_minor}"; do echo "Tagging and pushing: $version_tag" docker buildx build \ --platform "${{ inputs.platform }}" \ From a229c6e1b299dacee60c5d845c2a5610b4670072 Mon Sep 17 00:00:00 2001 From: Bob Tanner Date: Fri, 16 May 2025 15:31:51 -0500 Subject: [PATCH 29/38] feat: refactor Docker build workflow with dynamic versioning and matrix support - Remove hardcoded version inputs from build-action - Add automatic extraction of commit ID and version from GITHUB_REF - Tag rolling images with rolling-YYYYmmDD format - Extend build matrix to support multiple alpine_version and image types (core, web, postorius) - Consolidate build steps into a single matrix-based loop for clarity and maintainability --- .github/actions/build-action/action.yml | 49 ++++++++----- .github/workflows/docker-build.yml | 93 +++++-------------------- 2 files changed, 46 insertions(+), 96 deletions(-) diff --git a/.github/actions/build-action/action.yml b/.github/actions/build-action/action.yml index a56233b0..c0914565 100644 --- a/.github/actions/build-action/action.yml +++ b/.github/actions/build-action/action.yml @@ -22,31 +22,46 @@ inputs: build_dir: description: 'Directory of the build context' required: true - version_full: - description: 'Full version string (e.g., 0.5.2)' - required: true - version_minor: - description: 'Minor version string (e.g., 0.5)' - required: true - version_major: - description: 'Major version string (e.g., 0)' + alpine_version: + description: 'Alpine version to use in the Dockerfile' required: true runs: using: "composite" steps: + - name: Determine commit and version info + id: meta + shell: bash + run: | + set -e + echo "commit_id=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT + + if [[ "${GITHUB_REF}" == refs/tags/v* ]]; then + RAW_TAG="${GITHUB_REF##*/}" + VERSION="${RAW_TAG#v}" + else + VERSION="0.5.2" + fi + + IFS='.' read -r MAJOR MINOR PATCH <<< "$VERSION" + + echo "version_full=$VERSION" >> $GITHUB_OUTPUT + echo "version_major=$MAJOR" >> $GITHUB_OUTPUT + echo "version_minor=${MAJOR}.${MINOR}" >> $GITHUB_OUTPUT + echo "version_patch=$PATCH" >> $GITHUB_OUTPUT + - name: Build Rolling Release for ${{ inputs.platform }} shell: bash run: | - # Replace '/' with '-' to make it tag-safe set -e safe_platform="${{ inputs.platform }}" safe_platform="${safe_platform//\//-}" docker buildx build \ --platform "${{ inputs.platform }}" \ - --label version.git_commit="${{ inputs.commit_id }}" \ - -t "${{ inputs.tag_ns }}/${{ inputs.image_name }}:rolling-${safe_platform}" \ + --label version.git_commit="${{ steps.meta.outputs.commit_id }}" \ + --build-arg ALPINE_VERSION="${{ inputs.alpine_version }}" \ + -t "${{ inputs.tag_ns }}/${{ inputs.image_name }}:rolling-${build_date}" \ -f "${{ inputs.dockerfile_path }}" "${{ inputs.build_dir }}" \ --push @@ -55,20 +70,16 @@ runs: run: | set -e if [[ "${GITHUB_REF}" == refs/tags/* ]]; then - safe_platform="${{ inputs.platform }}" safe_platform="${safe_platform//\//-}" - version_full="${{ inputs.version_full }}" - version_major="${{ inputs.version_major }}" - version_minor="${{ inputs.version_minor }}" # version_minor is ${MAJOR}.${MINOR} - - for version_tag in "$version_full" "${version_minor}"; do + for version_tag in "${{ steps.meta.outputs.version_full }}" "${{ steps.meta.outputs.version_minor }}"; do echo "Tagging and pushing: $version_tag" docker buildx build \ --platform "${{ inputs.platform }}" \ - --label version.git_commit="${{ inputs.commit_id }}" \ - -t "${{ inputs.tag_ns }}/${{ inputs.image_name }}:${version_tag}" \ + --label version.git_commit="${{ steps.meta.outputs.commit_id }}" \ + --build-arg ALPINE_VERSION="${{ inputs.alpine_version }}" \ + -t "${{ inputs.tag_ns }}/${{ inputs.image_name }}:${safe_platform}-${version_tag}" \ -f "${{ inputs.dockerfile_path }}" "${{ inputs.build_dir }}" \ --push done diff --git a/.github/workflows/docker-build.yml b/.github/workflows/docker-build.yml index eadcf23b..54d04c2b 100644 --- a/.github/workflows/docker-build.yml +++ b/.github/workflows/docker-build.yml @@ -28,6 +28,17 @@ jobs: strategy: matrix: platform: [linux/amd64, linux/arm64] + alpine_version: [3.20, 3.21, 3.21.3] + image: + - name: mailman-core + dockerfile: core/Dockerfile.dev + context: core/ + - name: mailman-web + dockerfile: web/Dockerfile.dev + context: web/ + - name: postorius + dockerfile: postorius/Dockerfile.dev + context: postorius/ fail-fast: false continue-on-error: true @@ -52,85 +63,13 @@ jobs: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} - - name: Set COMMIT_ID - run: echo "COMMIT_ID=$(git rev-parse --short HEAD)" >> $GITHUB_ENV - - - name: Extract version info - id: version - run: | - if [[ "${GITHUB_REF}" == refs/tags/v* ]]; then - RAW_TAG="${GITHUB_REF##*/}" - VERSION="${RAW_TAG#v}" - else - VERSION="0.5.2" - fi - - IFS='.' read -r MAJOR MINOR PATCH <<< "$VERSION" - - echo "full=$VERSION" >> $GITHUB_OUTPUT - echo "minor=${MAJOR}.${MINOR}" >> $GITHUB_OUTPUT - echo "major=${MAJOR}" >> $GITHUB_OUTPUT - - # Build mailman-core - - name: Build mailman-core for ${{ matrix.platform }} - uses: ./.github/actions/build-action - with: - image_name: mailman-core - platform: ${{ matrix.platform }} - commit_id: ${{ env.COMMIT_ID }} - tag_ns: ${{ env.TAG_NS }} - dockerfile_path: core/Dockerfile.dev - build_dir: core/ - version_full: ${{ steps.version.outputs.full }} - version_minor: ${{ steps.version.outputs.minor }} - version_major: ${{ steps.version.outputs.major }} - - # Build mailman-web - - name: Build mailman-web for ${{ matrix.platform }} + - name: Build ${{ matrix.image.name }} for ${{ matrix.platform }} uses: ./.github/actions/build-action with: - image_name: mailman-web + image_name: ${{ matrix.image.name }} platform: ${{ matrix.platform }} commit_id: ${{ env.COMMIT_ID }} tag_ns: ${{ env.TAG_NS }} - dockerfile_path: web/Dockerfile.dev - build_dir: web/ - version_full: ${{ steps.version.outputs.full }} - version_minor: ${{ steps.version.outputs.minor }} - version_major: ${{ steps.version.outputs.major }} - - # Build postorius - - name: Build postorius for ${{ matrix.platform }} - uses: ./.github/actions/build-action - with: - image_name: postorius - platform: ${{ matrix.platform }} - commit_id: ${{ env.COMMIT_ID }} - tag_ns: ${{ env.TAG_NS }} - dockerfile_path: postorius/Dockerfile.dev - build_dir: postorius/ - version_full: ${{ steps.version.outputs.full }} - version_minor: ${{ steps.version.outputs.minor }} - version_major: ${{ steps.version.outputs.major }} - - # manifest: - # needs: build - # runs-on: ubuntu-latest - # steps: - # # https://github.com/actions/checkout - # - name: Checkout code - # uses: actions/checkout@v4 - - # # https://github.com/docker/login-action - # - name: Login to DockerHub - # uses: docker/login-action@v3 - # with: - # username: ${{ secrets.DOCKERHUB_USERNAME }} - # password: ${{ secrets.DOCKERHUB_TOKEN }} - - # # Push multi-arch manifests - # - name: Create and Push Multi-Arch Manifests - # uses: ./.github/actions/manifest-action - # with: - # tag_ns: ${{ env.TAG_NS }} - # commit_id: ${{ env.COMMIT_ID }} + dockerfile_path: ${{ matrix.image.dockerfile }} + build_dir: ${{ matrix.image.context }} + alpine_version: ${{ matrix.alpine_version }} From 42732275321b043320fcfb2b27507b226b4b06be Mon Sep 17 00:00:00 2001 From: Bob Tanner Date: Fri, 16 May 2025 15:36:36 -0500 Subject: [PATCH 30/38] Added build_date variable definition --- .github/actions/build-action/action.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/actions/build-action/action.yml b/.github/actions/build-action/action.yml index c0914565..803ffd6b 100644 --- a/.github/actions/build-action/action.yml +++ b/.github/actions/build-action/action.yml @@ -57,6 +57,8 @@ runs: safe_platform="${{ inputs.platform }}" safe_platform="${safe_platform//\//-}" + build_date=$(date +%Y%m%d) + docker buildx build \ --platform "${{ inputs.platform }}" \ --label version.git_commit="${{ steps.meta.outputs.commit_id }}" \ From 13af50cbc6339c61904f5db00f32557439058bcc Mon Sep 17 00:00:00 2001 From: Bob Tanner Date: Fri, 16 May 2025 16:18:30 -0500 Subject: [PATCH 31/38] refactor: remove per-platform build matrix and hardcoded platform input - Removed `platform` as an input from the `build-action` composite action. - Updated `docker buildx build` to use multi-arch build for `linux/amd64,linux/arm64` by default. - Simplified version fallback logic in `action.yml`. - Updated `docker-build.yml` workflow to drop matrix strategy for platform and removed related references. --- .github/actions/build-action/action.yml | 12 ++---------- .github/workflows/docker-build.yml | 4 +--- 2 files changed, 3 insertions(+), 13 deletions(-) diff --git a/.github/actions/build-action/action.yml b/.github/actions/build-action/action.yml index 803ffd6b..8b5905b1 100644 --- a/.github/actions/build-action/action.yml +++ b/.github/actions/build-action/action.yml @@ -7,9 +7,6 @@ inputs: image_name: description: 'Name of the Docker image (e.g., mailman-core, mailman-web, postorius)' required: true - platform: - description: 'Target platform for build (e.g., linux/amd64, linux/arm64)' - required: true commit_id: description: 'Git commit hash to tag the image' required: true @@ -35,13 +32,11 @@ runs: run: | set -e echo "commit_id=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT + VERSION="0.5.2" if [[ "${GITHUB_REF}" == refs/tags/v* ]]; then RAW_TAG="${GITHUB_REF##*/}" VERSION="${RAW_TAG#v}" - else - VERSION="0.5.2" - fi IFS='.' read -r MAJOR MINOR PATCH <<< "$VERSION" @@ -54,13 +49,10 @@ runs: shell: bash run: | set -e - safe_platform="${{ inputs.platform }}" - safe_platform="${safe_platform//\//-}" - build_date=$(date +%Y%m%d) docker buildx build \ - --platform "${{ inputs.platform }}" \ + --platform linux/amd64,linux/arm64 \ --label version.git_commit="${{ steps.meta.outputs.commit_id }}" \ --build-arg ALPINE_VERSION="${{ inputs.alpine_version }}" \ -t "${{ inputs.tag_ns }}/${{ inputs.image_name }}:rolling-${build_date}" \ diff --git a/.github/workflows/docker-build.yml b/.github/workflows/docker-build.yml index 54d04c2b..73d3f0bf 100644 --- a/.github/workflows/docker-build.yml +++ b/.github/workflows/docker-build.yml @@ -27,7 +27,6 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - platform: [linux/amd64, linux/arm64] alpine_version: [3.20, 3.21, 3.21.3] image: - name: mailman-core @@ -63,11 +62,10 @@ jobs: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} - - name: Build ${{ matrix.image.name }} for ${{ matrix.platform }} + - name: Build ${{ matrix.image.name }} (Multi-Arch) uses: ./.github/actions/build-action with: image_name: ${{ matrix.image.name }} - platform: ${{ matrix.platform }} commit_id: ${{ env.COMMIT_ID }} tag_ns: ${{ env.TAG_NS }} dockerfile_path: ${{ matrix.image.dockerfile }} From 71fe59d0dc6a57c3002bbbdd404d20af3394e959 Mon Sep 17 00:00:00 2001 From: Bob Tanner Date: Fri, 16 May 2025 16:22:31 -0500 Subject: [PATCH 32/38] Fixed open if statement --- .github/actions/build-action/action.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/actions/build-action/action.yml b/.github/actions/build-action/action.yml index 8b5905b1..53cfa793 100644 --- a/.github/actions/build-action/action.yml +++ b/.github/actions/build-action/action.yml @@ -37,6 +37,7 @@ runs: if [[ "${GITHUB_REF}" == refs/tags/v* ]]; then RAW_TAG="${GITHUB_REF##*/}" VERSION="${RAW_TAG#v}" + fi IFS='.' read -r MAJOR MINOR PATCH <<< "$VERSION" From 5212747ef80d8461c36c15b0dd70f296ed44aac9 Mon Sep 17 00:00:00 2001 From: Bob Tanner Date: Fri, 16 May 2025 16:46:11 -0500 Subject: [PATCH 33/38] Added apline version to the docker image tag --- .github/actions/build-action/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/actions/build-action/action.yml b/.github/actions/build-action/action.yml index 53cfa793..bfd3013f 100644 --- a/.github/actions/build-action/action.yml +++ b/.github/actions/build-action/action.yml @@ -56,7 +56,7 @@ runs: --platform linux/amd64,linux/arm64 \ --label version.git_commit="${{ steps.meta.outputs.commit_id }}" \ --build-arg ALPINE_VERSION="${{ inputs.alpine_version }}" \ - -t "${{ inputs.tag_ns }}/${{ inputs.image_name }}:rolling-${build_date}" \ + -t "${{ inputs.tag_ns }}/${{ inputs.image_name }}:rolling-${build_date}-${alpine_version}" \ -f "${{ inputs.dockerfile_path }}" "${{ inputs.build_dir }}" \ --push From 164c74947dd2233c6ffbba92176dfe9ff37a519a Mon Sep 17 00:00:00 2001 From: Bob Tanner Date: Fri, 16 May 2025 16:58:47 -0500 Subject: [PATCH 34/38] Fixing my struggle with how GitHub workflows pass around variables --- .github/actions/build-action/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/actions/build-action/action.yml b/.github/actions/build-action/action.yml index bfd3013f..1387d243 100644 --- a/.github/actions/build-action/action.yml +++ b/.github/actions/build-action/action.yml @@ -56,7 +56,7 @@ runs: --platform linux/amd64,linux/arm64 \ --label version.git_commit="${{ steps.meta.outputs.commit_id }}" \ --build-arg ALPINE_VERSION="${{ inputs.alpine_version }}" \ - -t "${{ inputs.tag_ns }}/${{ inputs.image_name }}:rolling-${build_date}-${alpine_version}" \ + -t "${{ inputs.tag_ns }}/${{ inputs.image_name }}:rolling-${build_date}-${{ inputs.alpine_version }}" \ -f "${{ inputs.dockerfile_path }}" "${{ inputs.build_dir }}" \ --push From ae940f0b805fb115f491153b5a67f3c16a8c01bc Mon Sep 17 00:00:00 2001 From: Bob Tanner Date: Fri, 16 May 2025 17:14:21 -0500 Subject: [PATCH 35/38] Hard code the apline and version in the image tag --- .github/actions/build-action/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/actions/build-action/action.yml b/.github/actions/build-action/action.yml index 1387d243..e42e7328 100644 --- a/.github/actions/build-action/action.yml +++ b/.github/actions/build-action/action.yml @@ -56,7 +56,7 @@ runs: --platform linux/amd64,linux/arm64 \ --label version.git_commit="${{ steps.meta.outputs.commit_id }}" \ --build-arg ALPINE_VERSION="${{ inputs.alpine_version }}" \ - -t "${{ inputs.tag_ns }}/${{ inputs.image_name }}:rolling-${build_date}-${{ inputs.alpine_version }}" \ + -t "${{ inputs.tag_ns }}/${{ inputs.image_name }}:rolling-${build_date}-alpine${{ inputs.alpine_version }}" \ -f "${{ inputs.dockerfile_path }}" "${{ inputs.build_dir }}" \ --push From 415952647656e54e25e6271405fe662400a4bfde Mon Sep 17 00:00:00 2001 From: Bob Tanner Date: Fri, 16 May 2025 21:15:09 -0500 Subject: [PATCH 36/38] Activate the tagged version GitHub workflow --- .github/actions/build-action/action.yml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/actions/build-action/action.yml b/.github/actions/build-action/action.yml index e42e7328..a78c22ea 100644 --- a/.github/actions/build-action/action.yml +++ b/.github/actions/build-action/action.yml @@ -65,16 +65,14 @@ runs: run: | set -e if [[ "${GITHUB_REF}" == refs/tags/* ]]; then - safe_platform="${{ inputs.platform }}" - safe_platform="${safe_platform//\//-}" for version_tag in "${{ steps.meta.outputs.version_full }}" "${{ steps.meta.outputs.version_minor }}"; do echo "Tagging and pushing: $version_tag" docker buildx build \ - --platform "${{ inputs.platform }}" \ + --platform linux/amd64,linux/arm64 \ --label version.git_commit="${{ steps.meta.outputs.commit_id }}" \ --build-arg ALPINE_VERSION="${{ inputs.alpine_version }}" \ - -t "${{ inputs.tag_ns }}/${{ inputs.image_name }}:${safe_platform}-${version_tag}" \ + -t "${{ inputs.tag_ns }}/${{ inputs.image_name }}:${version_tag}-alpine${{ inputs.alpine_version }}" \ -f "${{ inputs.dockerfile_path }}" "${{ inputs.build_dir }}" \ --push done From 6449c42408914e2d23617f150f04faa76305aae6 Mon Sep 17 00:00:00 2001 From: Bob Tanner Date: Sat, 17 May 2025 08:33:41 -0500 Subject: [PATCH 37/38] feat(docker): parameterize Alpine version for multi-version build matrix - Added `ARG ALPINE_VERSION` and updated `FROM` directives in Dockerfiles (core, postorius, web) to use it - Extended GitHub Actions matrix to include general `3` tag alongside specific versions (3.20, 3.21, 3.21.3) - Retained previous `FROM alpine:x` lines as comments for reference --- .github/workflows/docker-build.yml | 2 +- core/Dockerfile.dev | 5 ++++- postorius/Dockerfile.dev | 5 ++++- web/Dockerfile.dev | 5 ++++- 4 files changed, 13 insertions(+), 4 deletions(-) diff --git a/.github/workflows/docker-build.yml b/.github/workflows/docker-build.yml index 73d3f0bf..2011df77 100644 --- a/.github/workflows/docker-build.yml +++ b/.github/workflows/docker-build.yml @@ -27,7 +27,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - alpine_version: [3.20, 3.21, 3.21.3] + alpine_version: [3, 3.20, 3.21, 3.21.3] image: - name: mailman-core dockerfile: core/Dockerfile.dev diff --git a/core/Dockerfile.dev b/core/Dockerfile.dev index d2366569..3bbcd69f 100644 --- a/core/Dockerfile.dev +++ b/core/Dockerfile.dev @@ -1,6 +1,9 @@ # syntax = docker/dockerfile:1.3 +ARG ALPINE_VERSION +FROM alpine:${ALPINE_VERSION} + # Use 3.15 for Core since it has Python 3.9 -FROM alpine:3.21 +# FROM alpine:3.21 # Set the commits that we are building. ARG CORE_REF diff --git a/postorius/Dockerfile.dev b/postorius/Dockerfile.dev index d718be77..cd2bdd60 100644 --- a/postorius/Dockerfile.dev +++ b/postorius/Dockerfile.dev @@ -1,5 +1,8 @@ # syntax = docker/dockerfile:1.3 -FROM alpine:3.21.3 +ARG ALPINE_VERSION +FROM alpine:${ALPINE_VERSION} + +# FROM alpine:3.21.3 ARG POSTORIUS_REF ARG DJ_MM3_REF diff --git a/web/Dockerfile.dev b/web/Dockerfile.dev index d3fa4592..659d76dc 100644 --- a/web/Dockerfile.dev +++ b/web/Dockerfile.dev @@ -1,5 +1,8 @@ # syntax = docker/dockerfile:1.3 -FROM alpine:3.21.3 +ARG ALPINE_VERSION +FROM alpine:${ALPINE_VERSION} + +# FROM alpine:3.21.3 ARG POSTORIUS_REF ARG HYPERKITTY_REF From 9b25a1788cc59045a4a5d0b71eca6f3b924f19a2 Mon Sep 17 00:00:00 2001 From: Bob Tanner Date: Sat, 17 May 2025 10:26:01 -0500 Subject: [PATCH 38/38] Fixed YAML interprets unquoted values like 3.20 as floating-point numbers, and 3.20 is the same as 3.2 in float notation. --- .github/workflows/docker-build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docker-build.yml b/.github/workflows/docker-build.yml index 2011df77..6f571558 100644 --- a/.github/workflows/docker-build.yml +++ b/.github/workflows/docker-build.yml @@ -27,7 +27,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - alpine_version: [3, 3.20, 3.21, 3.21.3] + alpine_version: ["3", "3.20", "3.21", "3.21.3"] image: - name: mailman-core dockerfile: core/Dockerfile.dev