Skip to content

Update docker-compose.yaml #1

Update docker-compose.yaml

Update docker-compose.yaml #1

Workflow file for this run

name: cache
on:
pull_request:
types:
- closed
env:
DOCKER_FILE_DIRECTORY: environments
DOCKER_COMPOSE_DIRECTORY: environments/ci
COMPOSE_DOCKER_CLI_BUILD: 1
DOCKER_BUILDKIT: 1
USE_CACHE: true
jobs:
create-cache:
if: github.event.pull_request.merged == true
name: ${{ matrix.os }} / ${{ matrix.python-version }}
runs-on: ${{ matrix.image }}
timeout-minutes: 10
strategy:
fail-fast: false
matrix:
os: [ubuntu]
python-version: ["3.8", "3.9"]
include:
- os: ubuntu
image: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Check version info
run: pwd && docker-compose --version && docker --version
# Provide a builder instance with docker buildx.
- name: Set up Docker Buildx
if: env.USE_CACHE == 'true'
uses: docker/setup-buildx-action@v3
# Specify a cache directory for build cache, and reuse past build cache as long as there are no changes to the environment files.
- name: Cache Docker layers
if: env.USE_CACHE == 'true'
id: build-cache
uses: actions/cache@v4
with:
path: /tmp/.buildx-cache/${{ matrix.python-version }}
key: buildx-${{ hashFiles(format('{0}/Dockerfile', env.DOCKER_FILE_DIRECTORY), format('{0}/docker-compose.yaml', env.DOCKER_COMPOSE_DIRECTORY), 'poetry.lock') }}
# If build cache is not found, build the Docker image to create a new cache.
- name: Build docker image with cache using buildx
if: steps.build-cache.outputs.cache-hit != 'true' && env.USE_CACHE == 'true'
uses: docker/bake-action@v4
with:
files: docker-compose.yaml
workdir: ${{ env.DOCKER_COMPOSE_DIRECTORY }}
load: true
set: |
core.args.PYTHON_VERSION=${{ matrix.python-version }}
*.cache-from=type=local,src=/tmp/.buildx-cache/${{ matrix.python-version }}
*.cache-to=type=local,dest=/tmp/.buildx-cache-new/${{ matrix.python-version }}
# Temp fix
# https://github.com/docker/build-push-action/issues/252
# https://github.com/moby/buildkit/issues/1896
- name: Move cache
if: steps.build-cache.outputs.cache-hit != 'true' && env.USE_CACHE == 'true'
run: |
rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cache