diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 8d533e2..7d0d549 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -6,10 +6,7 @@ on: - main tags: - '*' - pull_request: - - # temp while iterating workflow_dispatch: # Defines two custom environment variables for the workflow. These are used for the Container registry domain, and a name for the Docker image that this workflow builds. @@ -33,6 +30,11 @@ jobs: - name: Checkout repository uses: actions/checkout@v4 + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + with: + platforms: arm32v7/armhf # arm64v8/aarch64 - no current need for arm64 + # Uses the `docker/login-action` action to log in to the Container registry registry using the account and password that will publish the packages. Once published, the packages are scoped to the account defined here. - name: Log in to the Container registry uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1 @@ -40,7 +42,12 @@ jobs: registry: ${{ env.REGISTRY }} username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + with: + driver: docker-container # Use docker-container driver for multi-platform builds + # This step uses [docker/metadata-action](https://github.com/docker/metadata-action#about) to extract tags and labels that will be applied to the specified image. The `id` "meta" allows the output of this step to be referenced in a subsequent step. The `images` value provides the base name for the tags and labels. - name: Extract metadata (tags, labels) for Docker id: meta @@ -61,9 +68,12 @@ jobs: uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4 with: context: . + platforms: linux/arm/v7,linux/amd64 # linux/arm64 no current need for arm64 push: true tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} + cache-from: type=gha + cache-to: type=gha,mode=max # This step generates an artifact attestation for the image, which is an unforgeable statement about where and how it was built. It increases supply chain security for people who consume the image. For more information, see "[AUTOTITLE](/actions/security-guides/using-artifact-attestations-to-establish-provenance-for-builds)." - name: Generate artifact attestation diff --git a/Dockerfile b/Dockerfile index 556e2d2..b3c9015 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,3 +1,10 @@ +# Split out the wheel build into the non-slim image +# See https://github.com/docker-library/python/issues/869 +FROM python:3.12 AS build +COPY requirements.txt ./ +RUN --mount=type=cache,target=/var/cache/buildkit/pip \ + pip wheel --wheel-dir /wheels -r requirements.txt + FROM python:3.12-slim LABEL org.opencontainers.image.source=https://github.com/mdiluz/matchy LABEL org.opencontainers.image.description="Matchy matches matchees" @@ -5,6 +12,9 @@ LABEL org.opencontainers.image.licenses=Unlicense WORKDIR /usr/src/app COPY requirements.txt ./ -RUN pip install --no-cache-dir -r requirements.txt +COPY --from=build /wheels /wheels +RUN --mount=type=cache,target=/var/cache/buildkit/pip \ + pip install --find-links /wheels --no-index -r requirements.txt + COPY . . CMD ["python", "py/matchy.py"] \ No newline at end of file