From bef3b8bf1c93b4b1e5393b7609f7660be5eff737 Mon Sep 17 00:00:00 2001 From: Gary Yendell Date: Fri, 21 Jun 2024 13:34:33 +0000 Subject: [PATCH] Refactor container CI --- .github/workflows/container.yml | 65 +++++++++------------------------ Dockerfile | 2 +- 2 files changed, 18 insertions(+), 49 deletions(-) diff --git a/.github/workflows/container.yml b/.github/workflows/container.yml index 7e85cd25..8181bf3c 100644 --- a/.github/workflows/container.yml +++ b/.github/workflows/container.yml @@ -18,6 +18,9 @@ jobs: contents: read packages: write + env: + TAG: ghcr.io/${{ github.repository_owner }}/${{ github.event.repository.name }} + steps: - name: Checkout uses: actions/checkout@v2 @@ -40,83 +43,49 @@ jobs: username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - - name: Docker meta - id: meta - uses: docker/metadata-action@v4 - with: - images: ghcr.io/${{ github.repository }} - tags: | - type=ref,event=branch - type=ref,event=tag - type=raw,value=latest - - name: Set up Docker Buildx id: buildx uses: docker/setup-buildx-action@v1 - - name: Docker meta config developer - id: meta-developer - uses: docker/metadata-action@v4 + - name: Build image + uses: docker/build-push-action@v4 with: - images: ghcr.io/${{ github.repository }}-developer - tags: | - type=ref,event=branch - type=ref,event=tag - type=raw,value=latest + context: . + file: Dockerfile + target: runtime + push: false + cache-from: type=local,src=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache - - name: Docker build developer image + - name: Push developer image uses: docker/build-push-action@v4 with: context: . file: Dockerfile target: developer + tags: ${{ env.TAG }}-developer:latest push: ${{ github.event_name != 'pull_request' }} - tags: ${{ steps.meta-build.outputs.tags }} - labels: ${{ steps.meta-build.outputs.labels }} cache-from: type=local,src=/tmp/.buildx-cache cache-to: type=local,dest=/tmp/.buildx-cache - - - name: Docker meta config build - id: meta-build - uses: docker/metadata-action@v4 - with: - images: ghcr.io/${{ github.repository }}-build - tags: | - type=ref,event=branch - type=ref,event=tag - type=raw,value=latest - - - name: Docker build build image + - name: Push build image uses: docker/build-push-action@v4 with: context: . file: Dockerfile target: build + tags: ${{ env.TAG }}-build:latest push: ${{ github.event_name != 'pull_request' }} - tags: ${{ steps.meta-build.outputs.tags }} - labels: ${{ steps.meta-build.outputs.labels }} cache-from: type=local,src=/tmp/.buildx-cache cache-to: type=local,dest=/tmp/.buildx-cache - - name: Docker meta config runtime - id: meta-runtime - uses: docker/metadata-action@v4 - with: - images: ghcr.io/${{ github.repository }}-runtime - tags: | - type=ref,event=branch - type=ref,event=tag - type=raw,value=latest - - - name: Docker build runtime image + - name: Push runtime image uses: docker/build-push-action@v4 with: context: . file: Dockerfile target: runtime + tags: ${{ env.TAG }}-runtime:latest push: ${{ github.event_name != 'pull_request' }} - tags: ${{ steps.meta-runtime.outputs.tags }} - labels: ${{ steps.meta-runtime.outputs.labels }} cache-from: type=local,src=/tmp/.buildx-cache cache-to: type=local,dest=/tmp/.buildx-cache diff --git a/Dockerfile b/Dockerfile index 096a2626..e1fda635 100644 --- a/Dockerfile +++ b/Dockerfile @@ -55,7 +55,7 @@ RUN mkdir /odin && \ RUN python -m pip install /tmp/odin-data/python[meta_writer] # Runtime stage ################################################################ -FROM common as runtime +FROM common AS runtime # runtime system dependencies RUN apt-get update -y && apt-get install -y --no-install-recommends \