Skip to content

change cache key

change cache key #10

Workflow file for this run

on:
pull_request:
push:
jobs:
build:
name: Build docker images
runs-on: ubuntu-latest
strategy:
matrix:
service:
- app
- gis
- ui
- web
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Cache
uses: actions/cache@v3
id: cache
with:
path: |
var-cache-apt
var-lib-apt
key: cache-${{ matrix.service }}-${{ hashFiles( format('{0}/{1}', matrix.service, 'Dockerfile')) }}
- name: inject cache into docker
uses: reproducible-containers/buildkit-cache-dance@v3.1.0
with:
cache-map: |
{
"var-cache-apt": "/var/cache/apt",
"var-lib-apt": "/var/lib/apt"
}
skip-extraction: ${{ steps.cache.outputs.cache-hit }}
- name: Build and export image
uses: docker/build-push-action@v5
with:
context: ${{ matrix.service }}
tags: smithmicro/n7m-${{ matrix.service }}:latest
cache-from: type=gha
cache-to: type=gha,mode=max
outputs: type=docker,dest=/tmp/${{ matrix.service }}.tar
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.service }}
path: /tmp/${{ matrix.service }}.tar
test:
name: Test docker images
needs: build
runs-on: ubuntu-latest
steps:
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
merge-multiple: true
path: /tmp
- name: Load images
run: |-
docker load --input /tmp/app.tar
docker load --input /tmp/gis.tar
docker load --input /tmp/ui.tar
docker load --input /tmp/web.tar
docker image ls -a
- name: Checkout
uses: actions/checkout@v4
- name: Start all services
run: |-
docker compose up -f docker-compose.yml -f .github/docker-compose.ci.yml --wait --wait-timeout 120 --pull never --no-build
- name: Test API health
run: |-
curl --fail-with-body http://localhost:8080/health