Build Docker #36
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build Docker | |
on: | |
workflow_call: | |
workflow_dispatch: # manual | |
jobs: | |
build-backend: | |
name: Build Backend | |
runs-on: ubuntu-latest | |
env: | |
DJANGO_SETTINGS_MODULE: zest.settings.dev | |
DJANGO_SECRET_KEY: "JASIDJ*@ioda89dY2hdaiophd80a23p06i%8-4ods3" | |
DJANGO_ALLOWED_HOSTS: localhost,0.0.0.0,127.0.0.1 | |
DJANGO_AUTH_MODE: jwt | |
TESTFLAGS: "--with-coverage --cover-xml --cover-erase" | |
SQL_ENGINE: django.db.backends.postgresql | |
SQL_DATABASE: zest | |
SQL_USER: zest | |
SQL_PASSWORD: zest | |
SQL_HOST: db | |
SQL_PORT: 5432 | |
UID: 1001 | |
GID: 121 | |
REDIS_ADDRESS: redis://cache:6379/1 | |
steps: | |
- uses: actions/checkout@v3 | |
# This gives us access to buildx | |
- name: Set up Docker CLI | |
uses: docker/setup-buildx-action@v3 | |
- name: "🔧 docker meta" | |
id: meta | |
uses: docker/metadata-action@v4 | |
with: | |
images: ${{ github.repository }} | |
tags: latest | |
- name: Build and Push Docker Images | |
uses: docker/bake-action@v5 | |
env: | |
TAG: ${{ steps.release-tag.outputs.tag }} | |
with: | |
source: "." | |
files: "docker-compose.yml" | |
tags: dbadrian/zest:latest | |
push: true | |
load: true | |
set: | | |
*.cache-from=type=registry,ref=dbadrian/zest:latest | |
*.cache-to=type=inline,mode=min | |
# set: | | |
# *.cache-from=type=gha | |
# *.cache-to=type=gha,mode=max | |
- name: Install Task | |
uses: arduino/setup-task@v2 | |
with: | |
version: 3.x | |
repo-token: ${{ secrets.GITHUB_TOKEN }} | |
- name: Create Docker Export Artifact | |
run: | | |
# Step 2: Pull prebuilt images (skip locally built ones) | |
# docker compose pull db | |
# Step 3: Extract all image names from the compose file | |
IMAGES=$(docker compose config | grep 'image:' | awk '{print $2}' | grep -v '^$' | xargs) | |
# Debug: Print the images being exported | |
echo "Exporting images: $IMAGES" | |
# Step 4: Save all images to a tar file | |
docker save -o /tmp/docker.tar $IMAGES | |
- name: "📂 Upload Docker Artifacts" | |
uses: actions/upload-artifact@v4 | |
with: | |
name: docker | |
path: /tmp/docker.tar | |
compression-level: 0 |