Skip to content

Commit

Permalink
ci: add docker build args to repo selection
Browse files Browse the repository at this point in the history
  • Loading branch information
gmontanola committed May 20, 2024
1 parent 7f1461b commit 74c5d00
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
13 changes: 9 additions & 4 deletions .github/workflows/build_and_push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,11 @@ on:
- 'requirements.txt'
- 'Dockerfile*'
workflow_dispatch:
name: Build and push Docker images
jobs:
build-and-push:
env:
APP_NAME: appex
name: Build and push Docker images
permissions:
contents: read
Expand Down Expand Up @@ -53,7 +56,7 @@ jobs:
with:
context: .
push: true
tags: "ghcr.io/${{ github.repository }}/appex:deps"
tags: "ghcr.io/${{ github.repository }}/${{ env.APP_NAME }}:deps"
file: Dockerfile.deps
cache-from: type=gha
cache-to: type=gha,mode=max
Expand All @@ -67,15 +70,15 @@ jobs:
if: steps.cache-src.outputs.cache-hit != 'true'
run: |
pex -o build/src.pex --include-tools \
--layout=packed -P appex
--layout=packed -P ${{ env.APP_NAME }}
- name: Build and push src
if: steps.build-src-pex.outputs.cache-hit != 'true'
uses: docker/build-push-action@v5
id: build-src-docker
with:
context: .
push: true
tags: "ghcr.io/${{ github.repository }}/appex:src"
tags: "ghcr.io/${{ github.repository }}/${{ env.APP_NAME }}:src"
file: Dockerfile.src
cache-from: type=gha
cache-to: type=gha,mode=max
Expand All @@ -84,7 +87,9 @@ jobs:
with:
context: .
push: true
tags: "ghcr.io/${{ github.repository }}/appex:app"
tags: "ghcr.io/${{ github.repository }}/${{ env.APP_NAME }}:app"
file: Dockerfile.app
cache-from: type=gha
cache-to: type=gha,mode=max
build-args: |
repo=ghcr.io/${{ github.repository }}/${{ env.APP_NAME }}
5 changes: 3 additions & 2 deletions Dockerfile.app
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
FROM python:3.11-slim
COPY --from=ttl.sh/appex:deps /app /app
COPY --from=ttl.sh/appex:src /app /app
ARG repo=ttl.sh/appex
COPY --from=${repo}:deps /app /app
COPY --from=${repo}:src /app /app

ENTRYPOINT ["/app/pex"]
EXPOSE 8000

0 comments on commit 74c5d00

Please sign in to comment.