Skip to content

Commit

Permalink
Build multi-arch images for commits on main (#7900)
Browse files Browse the repository at this point in the history
  • Loading branch information
ddelange authored and madkinsz committed Jan 12, 2023
1 parent 79e5d67 commit aad511e
Show file tree
Hide file tree
Showing 2 changed files with 79 additions and 0 deletions.
76 changes: 76 additions & 0 deletions .github/workflows/docker-builds.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
name: Build prefect docker images

# Note: Conda support for 3.11 is pending. See https://github.com/ContinuumIO/anaconda-issues/issues/13082

on:
# On each commit merged into main, push sha and branch patterns
push:
branches: main
# On workflow_dispatch, push sha and branch patterns
workflow_dispatch:

jobs:
publish-docker-images:
name: Build Docker images
runs-on: ubuntu-latest
environment: ${{ ( github.event_name == 'release' && 'prod' ) || 'dev' }}
strategy:
matrix:
flavor:
- ""
- "-conda"
python-version:
- "3.7"
- "3.8"
- "3.9"
- "3.10"
- "3.11"
exclude:
# Not yet supported, see note at top
- flavor: "-conda"
python-version: "3.11"

steps:
- name: Set up QEMU
uses: docker/setup-qemu-action@v2

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Generate image metadata
id: metadata
uses: docker/metadata-action@v4
with:
images: prefecthq/prefect-dev
tags: |
type=raw,enable=${{ github.event_name != 'release' }},value=${{ github.ref_name }},suffix=-python${{ matrix.python-version }}
type=sha,suffix=-python${{ matrix.python-version }}
flavor: |
latest=false
suffix=${{ matrix.flavor }}
- name: Build image
uses: docker/build-push-action@v3
with:
context: .
platforms: linux/amd64,linux/arm64
build-args: |
PYTHON_VERSION=${{ matrix.python-version }}
${{ ( endsWith(matrix.flavor, 'conda') && 'BASE_IMAGE=prefect-conda' ) || '' }}
tags: ${{ steps.metadata.outputs.tags }}
labels: ${{ steps.metadata.outputs.labels }}
push: true
# multi-stage cache manifests (mode=max) need a separate tag because they are not usable for runtime ref https://github.com/moby/buildkit#export-cache
cache-from: type=registry,ref=prefecthq/prefect-dev:buildcache-python${{ matrix.python-version }}${{ matrix.flavor }}
cache-to: ${{ ( github.event_name == 'push' && 'type=registry,ref=prefecthq/prefect-dev:buildcache-python${{ matrix.python-version }}${{ matrix.flavor }},mode=max' ) || '' }}
3 changes: 3 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,9 @@ COPY --from=python-builder /opt/prefect/dist ./dist
ARG PREFECT_EXTRAS=${PREFECT_EXTRAS:-""}
RUN pip install --no-cache-dir "./dist/prefect.tar.gz${PREFECT_EXTRAS}"

# Smoke test
RUN prefect version

# Setup entrypoint
COPY scripts/entrypoint.sh ./entrypoint.sh
ENTRYPOINT ["/usr/bin/tini", "-g", "--", "/opt/prefect/entrypoint.sh"]

0 comments on commit aad511e

Please sign in to comment.