This commit is contained in:
2024-12-11 21:54:55 +02:00
parent 42a61cf7d1
commit 20b6b44b24
4 changed files with 216 additions and 158 deletions

View File

@@ -0,0 +1,53 @@
name: Build AMD64
on:
workflow_call:
inputs:
python-version:
required: true
type: string
secrets:
DOCKER_USERNAME:
required: true
DOCKER_PASSWORD:
required: true
jobs:
build:
runs-on: linux_amd
container:
image: catthehacker/ubuntu:act-latest
env:
RUNNER_TOOL_CACHE: /toolcache
steps:
- name: Checkout
uses: actions/checkout@v4
with:
github-server-url: https://gitea.technocloud.ee
- name: Set up Docker BuildX
uses: docker/setup-buildx-action@v3
with:
platforms: linux/amd64
- name: Login to DockerHub
uses: docker/login-action@v3
with:
registry: gitea.technocloud.ee
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Get Meta
id: meta
run: |
echo "REPO_NAME=${GITHUB_REPOSITORY}" >> $GITHUB_OUTPUT
- name: Build and Push AMD64
id: build-docker
uses: docker/build-push-action@v5
with:
context: .
file: Dockerfile.python${{ inputs.python-version }}
platforms: linux/amd64
push: true
provenance: false
outputs: type=image,name=gitea.technocloud.ee/${{ steps.meta.outputs.REPO_NAME }},push-by-digest=true

View File

@@ -0,0 +1,53 @@
name: Build ARM64
on:
workflow_call:
inputs:
python-version:
required: true
type: string
secrets:
DOCKER_USERNAME:
required: true
DOCKER_PASSWORD:
required: true
jobs:
build:
runs-on: ubuntu-latest
container:
image: catthehacker/ubuntu:act-latest
env:
RUNNER_TOOL_CACHE: /toolcache
steps:
- name: Checkout
uses: actions/checkout@v4
with:
github-server-url: https://gitea.technocloud.ee
- name: Set up Docker BuildX
uses: docker/setup-buildx-action@v3
with:
platforms: linux/arm64
- name: Login to DockerHub
uses: docker/login-action@v3
with:
registry: gitea.technocloud.ee
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Get Meta
id: meta
run: |
echo "REPO_NAME=${GITHUB_REPOSITORY}" >> $GITHUB_OUTPUT
- name: Build and Push ARM64
id: build-docker
uses: docker/build-push-action@v6
with:
context: .
file: Dockerfile.python${{ inputs.python-version }}
platforms: linux/arm64
push: true
provenance: false
outputs: type=image,name=gitea.technocloud.ee/${{ steps.meta.outputs.REPO_NAME }},push-by-digest=true

View File

@@ -5,177 +5,88 @@ on:
- main - main
schedule: schedule:
- cron: '@monthly' - cron: '@monthly'
name: Build Docker Image
on:
push:
branches:
- main
schedule:
- cron: '@monthly'
jobs: jobs:
# build-amd64: python-3-10:
# runs-on: linux_amd name: Build Python 3.10
# name: Build AMD64
# container:
# image: catthehacker/ubuntu:act-latest
# env:
# RUNNER_TOOL_CACHE: /toolcache
# strategy:
# matrix:
# python-version: ['3.10', '3.11', '3.12', '3.13']
# outputs:
# digest-3-10: ${{ steps.digest.outputs.DIGEST_3_10 }}
# digest-3-11: ${{ steps.digest.outputs.DIGEST_3_11 }}
# digest-3-12: ${{ steps.digest.outputs.DIGEST_3_12 }}
# digest-3-13: ${{ steps.digest.outputs.DIGEST_3_13 }}
# steps:
# - name: Checkout
# uses: actions/checkout@v4
# with:
# github-server-url: https://gitea.technocloud.ee
# - name: Set up Docker BuildX
# uses: docker/setup-buildx-action@v3
# with:
# platforms: linux/amd64
# - name: Login to DockerHub
# uses: docker/login-action@v3
# with:
# registry: gitea.technocloud.ee
# username: ${{ secrets.DOCKER_USERNAME }}
# password: ${{ secrets.DOCKER_PASSWORD }}
# - name: Get Meta
# id: meta
# run: |
# echo "REPO_NAME=${GITHUB_REPOSITORY}" >> $GITHUB_OUTPUT
# - name: Build and Push AMD64
# id: build-docker
# uses: docker/build-push-action@v5
# with:
# context: .
# file: Dockerfile.python${{ matrix.python-version }}
# platforms: linux/amd64
# push: true
# provenance: false
# outputs: type=image,name=gitea.technocloud.ee/${{ steps.meta.outputs.REPO_NAME }},push-by-digest=true
# - name: Summarize the Docker digest
# id: digest
# run: |
# PY_VERSION=${{ matrix.python-version }}
# PY_VERSION_MOD=$(echo $PY_VERSION | sed 's/\./_/g')
# echo DIGEST_${PY_VERSION_MOD}="${{ steps.build-docker.outputs.digest }}" >> $GITHUB_OUTPUT
build-arm64:
runs-on: ubuntu-latest runs-on: ubuntu-latest
name: Build ARM64
container:
image: catthehacker/ubuntu:act-latest
env:
RUNNER_TOOL_CACHE: /toolcache
outputs:
digest-3-10: ${{ steps.digest.outputs.DIGEST_3_10 }}
digest-3-11: ${{ steps.digest.outputs.DIGEST_3_11 }}
digest-3-12: ${{ steps.digest.outputs.DIGEST_3_12 }}
digest-3-13: ${{ steps.digest.outputs.DIGEST_3_13 }}
strategy:
matrix:
python-version: ['3.10', '3.11', '3.12', '3.13']
steps: steps:
- name: Checkout - name: Build AMD64
uses: actions/checkout@v4 uses: ./.gitea/workflows/build-amd64.yml
with: with:
github-server-url: https://gitea.technocloud.ee python-version: '3.10'
- name: Set up Docker BuildX
uses: docker/setup-buildx-action@v3
with:
platforms: linux/arm64
- name: Login to DockerHub
uses: docker/login-action@v3
with:
registry: gitea.technocloud.ee
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Get Meta
id: meta
run: |
echo "REPO_NAME=${GITHUB_REPOSITORY}" >> $GITHUB_OUTPUT
- name: Build and Push ARM64
id: build-docker
uses: docker/build-push-action@v6
with:
context: .
file: Dockerfile.python${{ matrix.python-version }}
platforms: linux/arm64
push: true
provenance: false
outputs: type=image,name=gitea.technocloud.ee/${{ steps.meta.outputs.REPO_NAME }},push-by-digest=true
- name: Save digest to artifact
run: |
PY_VERSION=${{ matrix.python-version }}
PY_VERSION_MOD=$(echo $PY_VERSION | sed 's/\./_/g')
mkdir -p ./digests
echo "${{ steps.build-docker.outputs.digest }}" > ./digests/DIGEST_${PY_VERSION_MOD}
- name: Upload digest artifact - name: Build ARM64
uses: actions/upload-artifact@v4 uses: ./.gitea/workflows/build-arm64.yml
with: with:
name: docker-digests python-version: '3.10'
path: ./digests/
retention-days: 1
- name: Download previous digests - name: Create Manifest
uses: actions/download-artifact@v4 uses: ./.gitea/workflows/create-manifest.yml
with: with:
name: docker-digests python-version: '3.10'
path: ./digests
- name: Combine all digests python-3-11:
id: digest name: Build Python 3.11
run: |
PY_VERSION=${{ matrix.python-version }}
PY_VERSION_MOD=$(echo $PY_VERSION | sed 's/\./_/g')
# Current version
echo DIGEST_${PY_VERSION_MOD}="${{ steps.build-docker.outputs.digest }}"
echo DIGEST_${PY_VERSION_MOD}="${{ steps.build-docker.outputs.digest }}" >> $GITHUB_OUTPUT
echo "Contents of ./digests/:"
ls -la ./digests/
# Read other versions from artifacts
for f in ./digests/DIGEST_*; do
if [ -f "$f" ]; then
version=$(basename "$f")
digest=$(cat "$f")
echo "$version=$digest"
echo "$version=$digest" >> $GITHUB_OUTPUT
fi
done
create-manifest:
needs: [build-arm64]
runs-on: ubuntu-latest runs-on: ubuntu-latest
name: Create Multi-arch Manifest
strategy:
matrix:
python-version: ['3.10', '3.11', '3.12', '3.13']
steps: steps:
- name: Login to Docker Registry - name: Build AMD64
uses: docker/login-action@v3 uses: ./.gitea/workflows/build-amd64.yml
with: with:
registry: gitea.technocloud.ee python-version: '3.11'
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Set up Docker BuildX - name: Build ARM64
uses: docker/setup-buildx-action@v3 uses: ./.gitea/workflows/build-arm64.yml
with: with:
driver: docker-container python-version: '3.11'
- name: Get Repository Metadata - name: Create Manifest
id: meta uses: ./.gitea/workflows/create-manifest.yml
run: | with:
echo "PACKAGE=gitea.technocloud.ee/${GITHUB_REPOSITORY}" >> $GITHUB_OUTPUT python-version: '3.11'
echo "PY_VERSION=digest-$(echo ${{ matrix.python-version }} | sed 's/\./-/g')" >> $GITHUB_OUTPUT
- name: Create and Push Multi-arch Manifest python-3-12:
run: | name: Build Python 3.12
echo '${{ toJSON(needs.build-arm64.outputs) }}' runs-on: ubuntu-latest
echo '${{ toJSON(needs.build-amd64.outputs) }}' steps:
echo '${{ steps.meta.outputs.PY_VERSION }}' - name: Build AMD64
ARM_DIGEST=${{ needs.build-arm64.outputs[steps.meta.outputs.PY_VERSION] }} uses: ./.gitea/workflows/build-amd64.yml
AMD_DIGEST=${{ needs.build-amd64.outputs[steps.meta.outputs.PY_VERSION] }} with:
IMAGE_NAME=${{ steps.meta.outputs.PACKAGE }}:python${{ matrix.python-version }} python-version: '3.12'
docker manifest create $IMAGE_NAME --amend ${{ steps.meta.outputs.PACKAGE }}@${ARM_DIGEST} --amend ${{ steps.meta.outputs.PACKAGE }}@${AMD_DIGEST}
docker manifest push $IMAGE_NAME - name: Build ARM64
uses: ./.gitea/workflows/build-arm64.yml
with:
python-version: '3.12'
- name: Create Manifest
uses: ./.gitea/workflows/create-manifest.yml
with:
python-version: '3.12'
python-3-13:
name: Build Python 3.13
runs-on: ubuntu-latest
steps:
- name: Build AMD64
uses: ./.gitea/workflows/build-amd64.yml
with:
python-version: '3.13'
- name: Build ARM64
uses: ./.gitea/workflows/build-arm64.yml
with:
python-version: '3.13'
- name: Create Manifest
uses: ./.gitea/workflows/create-manifest.yml
with:
python-version: '3.13'

View File

@@ -0,0 +1,41 @@
name: Create Manifest
on:
workflow_call:
inputs:
python-version:
required: true
type: string
secrets:
DOCKER_USERNAME:
required: true
DOCKER_PASSWORD:
required: true
jobs:
create:
runs-on: ubuntu-latest
steps:
- name: Login to Docker Registry
uses: docker/login-action@v3
with:
registry: gitea.technocloud.ee
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Set up Docker BuildX
uses: docker/setup-buildx-action@v3
with:
driver: docker-container
- name: Get Repository Metadata
id: meta
run: |
echo "PACKAGE=gitea.technocloud.ee/${GITHUB_REPOSITORY}" >> $GITHUB_OUTPUT
- name: Create and Push Multi-arch Manifest
run: |
IMAGE_NAME=${{ steps.meta.outputs.PACKAGE }}:python${{ inputs.python-version }}
docker manifest create $IMAGE_NAME \
--amend ${{ steps.meta.outputs.PACKAGE }}@${ARM_DIGEST} \
--amend ${{ steps.meta.outputs.PACKAGE }}@${AMD_DIGEST}
docker manifest push $IMAGE_NAME