Skip to content

Daily Docker Build

Daily Docker Build #3

Workflow file for this run

name: Daily Docker Build
on:
schedule:
- cron: "0 0 * * *" # Run daily at midnight UTC
workflow_dispatch: # Allow manual triggering
jobs:
# Build AMD64 image
build-amd64:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set date
id: date
run: echo "DATE=$(date +'%Y-%m-%d')" >> $GITHUB_ENV
- name: Free disk space
run: |
sudo rm -rf /usr/local/lib/android /usr/share/dotnet /opt/ghc /opt/hostedtoolcache/CodeQL
df -h
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
driver-opts: |
image=moby/buildkit:latest
network=host
- name: Build and push base image (AMD64)
uses: docker/build-push-action@v5
with:
context: .
push: true
target: base
platforms: linux/amd64
tags: |
ghcr.io/${{ github.repository }}:base-amd64-${{ env.DATE }}
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Prune Docker
run: |
docker system prune -af
df -h
- name: Build and push pre-built image (AMD64)
uses: docker/build-push-action@v5
with:
context: .
push: true
target: prebuilt
platforms: linux/amd64
tags: |
ghcr.io/${{ github.repository }}:prebuilt-amd64-${{ env.DATE }}
cache-from: type=gha
build-args: |
BUILDKIT_INLINE_CACHE=1
# Build ARM64 image using GitHub's ARM64 runner
build-arm64:
runs-on: ubuntu-24.04-arm
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set date
id: date
run: echo "DATE=$(date +'%Y-%m-%d')" >> $GITHUB_ENV
- name: Free disk space
run: |
sudo rm -rf /usr/local/lib/android /usr/share/dotnet /opt/ghc /opt/hostedtoolcache/CodeQL
df -h
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
driver-opts: |
image=moby/buildkit:latest
network=host
- name: Build and push base image (ARM64)
uses: docker/build-push-action@v5
with:
context: .
push: true
target: base
platforms: linux/arm64
tags: |
ghcr.io/${{ github.repository }}:base-arm64-${{ env.DATE }}
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Prune Docker
run: |
docker system prune -af
df -h
- name: Build and push pre-built image (ARM64)
uses: docker/build-push-action@v5
with:
context: .
push: true
target: prebuilt
platforms: linux/arm64
tags: |
ghcr.io/${{ github.repository }}:prebuilt-arm64-${{ env.DATE }}
cache-from: type=gha
build-args: |
BUILDKIT_INLINE_CACHE=1
# Create multi-platform images
create-multiplatform-images:
needs: [build-amd64, build-arm64]
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Set date
id: date
run: echo "DATE=$(date +'%Y-%m-%d')" >> $GITHUB_ENV
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Create and push multi-platform manifest for base image
run: |
docker manifest create ghcr.io/${{ github.repository }}:latest \
ghcr.io/${{ github.repository }}:base-amd64-${{ env.DATE }} \
ghcr.io/${{ github.repository }}:base-arm64-${{ env.DATE }}
docker manifest create ghcr.io/${{ github.repository }}:${{ env.DATE }} \
ghcr.io/${{ github.repository }}:base-amd64-${{ env.DATE }} \
ghcr.io/${{ github.repository }}:base-arm64-${{ env.DATE }}
docker manifest push ghcr.io/${{ github.repository }}:latest
docker manifest push ghcr.io/${{ github.repository }}:${{ env.DATE }}
- name: Create and push multi-platform manifest for prebuilt image
run: |
docker manifest create ghcr.io/${{ github.repository }}:prebuilt \
ghcr.io/${{ github.repository }}:prebuilt-amd64-${{ env.DATE }} \
ghcr.io/${{ github.repository }}:prebuilt-arm64-${{ env.DATE }}
docker manifest create ghcr.io/${{ github.repository }}:prebuilt-${{ env.DATE }} \
ghcr.io/${{ github.repository }}:prebuilt-amd64-${{ env.DATE }} \
ghcr.io/${{ github.repository }}:prebuilt-arm64-${{ env.DATE }}
docker manifest push ghcr.io/${{ github.repository }}:prebuilt
docker manifest push ghcr.io/${{ github.repository }}:prebuilt-${{ env.DATE }}