Skip to content

Commit

Permalink
fix: move docker cache to gha
Browse files Browse the repository at this point in the history
  • Loading branch information
danut13 committed Dec 18, 2024
1 parent 8e743d4 commit d0f9f89
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 45 deletions.
16 changes: 1 addition & 15 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,6 @@ jobs:
uses: docker/setup-buildx-action@v3
id: buildx

- name: Cache Docker layers
uses: actions/cache@v4
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-v1.0-service-node-${{ matrix.arch }}-${{ github.ref_name }}
restore-keys: |
${{ runner.os }}-buildx-v1.0-service-node-${{ matrix.arch }}-
- name: Check docker config and disable live reload
run: |
cat /etc/docker/daemon.json
Expand Down Expand Up @@ -106,8 +98,7 @@ jobs:
- name: Build and load
run: |
mkdir export
make docker-build ARGS='--set "*.cache-from=type=local,src=/tmp/.buildx-cache" \
--set "*.cache-to=type=local,dest=/tmp/.buildx-cache-new" \
make docker-build ARGS='--set "*.cache-from=type=gha" \
--set "*.platform=linux/${{ matrix.arch }}" \
--builder ${{ steps.buildx.outputs.name }} \
--set "app.output=type=tar,dest=export/app.tar" \
Expand All @@ -133,11 +124,6 @@ jobs:
timeout 1 make docker-logs || true
working-directory: ethereum-contracts

- name: Move cache
run: |
rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
Expand Down
16 changes: 1 addition & 15 deletions .github/workflows/docker-vulnerabilities.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,18 +48,10 @@ jobs:
uses: docker/setup-buildx-action@v3
id: buildx

- name: Cache Docker layers
uses: actions/cache@v4
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-trivy-service-node-${{ matrix.arch }}-${{ github.ref_name }}
restore-keys: |
${{ runner.os }}-trivy-service-node-${{ matrix.arch }}-
- name: Build and load
run: |
docker buildx bake \
--set "*.cache-from=type=local,src=/tmp/.buildx-cache" \
--set "*.cache-to=type=local,dest=/tmp/.buildx-cache-new" \
--set "*.cache-from=type=gha" \
--set "*.platform=linux/${{ matrix.arch }}" \
--builder ${{ steps.buildx.outputs.name }} \
-f docker-compose.yml \
Expand Down Expand Up @@ -98,9 +90,3 @@ jobs:
with:
category: 'service-node-worker-${{ matrix.arch }}'
sarif_file: 'trivy-worker-results.sarif'

- name: Move cache
if: always()
run: |
rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
1 change: 1 addition & 0 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ jobs:
with:
tag: development
environment: main
cache_enabled: true

test:
needs: publish-docker
Expand Down
22 changes: 7 additions & 15 deletions .github/workflows/publish-docker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ on:
required: false
type: string
default: ""
cache_enabled:
description: 'Enable caching'
required: false
type: boolean
default: false
secrets:
DOCKERHUB_USERNAME:
description: 'Docker Hub username'
Expand Down Expand Up @@ -46,14 +51,6 @@ jobs:
uses: docker/setup-buildx-action@v3
id: buildx

- name: Cache Docker layers
uses: actions/cache@v4
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-to-publish-service-node-${{ matrix.arch }}-${{ github.ref_name }}
restore-keys: |
${{ runner.os }}-to-publish-service-node-${{ matrix.arch }}-
- uses: actions/download-artifact@v4
with:
merge-multiple: true
Expand Down Expand Up @@ -87,8 +84,8 @@ jobs:
export EXTRA_TAG=$DOCKER_TAG
fi
docker buildx bake \
--set "*.cache-from=type=local,src=/tmp/.buildx-cache" \
--set "*.cache-to=type=local,dest=/tmp/.buildx-cache-new" \
--set "*.cache-from=type=gha" \
${{ inputs.cache_enabled && '--set "*.cache-to=type=gha,mode=max" \' || '' }}
--set "*.platform=linux/amd64" \
--builder ${{ steps.buildx.outputs.name }} \
--sbom=true \
Expand Down Expand Up @@ -116,8 +113,3 @@ jobs:
env:
DOCKER_TAG: ${{ inputs.tag }}
COSIGN_EXPERIMENTAL: "true"

- name: Move cache
run: |
rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cache

0 comments on commit d0f9f89

Please sign in to comment.