From d008496389acdc28a62efb89f3403a88b4cb30ce Mon Sep 17 00:00:00 2001 From: Aidos Kanapyanov Date: Sun, 23 Feb 2025 03:39:22 +0500 Subject: [PATCH] perf(ci/gha-caching): add gha docker builds caching --- .../.github/workflows/ci.yml | 28 ++++++++++++++++--- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/{{cookiecutter.project_slug}}/.github/workflows/ci.yml b/{{cookiecutter.project_slug}}/.github/workflows/ci.yml index 83625e481..cc762a830 100644 --- a/{{cookiecutter.project_slug}}/.github/workflows/ci.yml +++ b/{{cookiecutter.project_slug}}/.github/workflows/ci.yml @@ -68,11 +68,31 @@ jobs: uses: actions/checkout@v4 {%- if cookiecutter.use_docker == 'y' %} - - name: Build the Stack - run: docker compose -f docker-compose.local.yml build django + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 - - name: Build the docs - run: docker compose -f docker-compose.docs.yml build docs + - name: Build and cache local backend + uses: docker/bake-action@v6 + with: + push: false + load: true + files: docker-compose.local.yml + targets: django + set: | + django.cache-from=type=gha,scope=django-cached-tests + django.cache-to=type=gha,scope=django-cached-tests,mode=max + postgres.cache-from=type=gha,scope=postgres-cached-tests + postgres.cache-to=type=gha,scope=postgres-cached-tests,mode=max + + - name: Build and cache docs + uses: docker/bake-action@v6 + with: + push: false + load: true + files: docker-compose.docs.yml + set: | + docs.cache-from=type=gha,scope=cached-docs + docs.cache-to=type=gha,scope=cached-docs,mode=max - name: Check DB Migrations run: docker compose -f docker-compose.local.yml run --rm django python manage.py makemigrations --check