diff --git a/.github/actions/build-action/action.yml b/.github/actions/build-action/action.yml new file mode 100644 index 00000000..a78c22ea --- /dev/null +++ b/.github/actions/build-action/action.yml @@ -0,0 +1,81 @@ +name: Build Docker Images + +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 + 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 + 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 + VERSION="0.5.2" + + if [[ "${GITHUB_REF}" == refs/tags/v* ]]; then + RAW_TAG="${GITHUB_REF##*/}" + VERSION="${RAW_TAG#v}" + 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: | + set -e + build_date=$(date +%Y%m%d) + + docker buildx build \ + --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${{ inputs.alpine_version }}" \ + -f "${{ inputs.dockerfile_path }}" "${{ inputs.build_dir }}" \ + --push + + - name: Tag and Push Versioned Images + shell: bash + run: | + set -e + if [[ "${GITHUB_REF}" == refs/tags/* ]]; then + + 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 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 }}:${version_tag}-alpine${{ inputs.alpine_version }}" \ + -f "${{ inputs.dockerfile_path }}" "${{ inputs.build_dir }}" \ + --push + done + else + echo "No git tag detected; skipping versioned image tagging." + fi diff --git a/.github/actions/manifest-action/action.yml b/.github/actions/manifest-action/action.yml new file mode 100644 index 00000000..e4201043 --- /dev/null +++ b/.github/actions/manifest-action/action.yml @@ -0,0 +1,39 @@ +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: "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 \ + --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 + 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 + 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..6f571558 --- /dev/null +++ b/.github/workflows/docker-build.yml @@ -0,0 +1,73 @@ +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 + tags: + - 'v*' + +env: + DOCKER_BUILDKIT: 1 + TAG_NS: basictheprogram + PUSH: yes + +jobs: + build: + runs-on: ubuntu-latest + strategy: + matrix: + alpine_version: ["3", "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 + + 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 + + # 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: Build ${{ matrix.image.name }} (Multi-Arch) + uses: ./.github/actions/build-action + with: + image_name: ${{ matrix.image.name }} + commit_id: ${{ env.COMMIT_ID }} + tag_ns: ${{ env.TAG_NS }} + dockerfile_path: ${{ matrix.image.dockerfile }} + build_dir: ${{ matrix.image.context }} + alpine_version: ${{ matrix.alpine_version }} 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 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