Skip to content

Commit 466ed1a

Browse files
authored
Merge pull request #240 from orionrobots/copilot/fix-239
Add Docker registry caching with service-specific cache refs for all services in CI workflows
2 parents e722471 + 015e218 commit 466ed1a

File tree

3 files changed

+82
-4
lines changed

3 files changed

+82
-4
lines changed

.github/workflows/on_call_build_site.yaml

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,28 @@ on:
55
jobs:
66
build_site:
77
runs-on: ubuntu-latest
8+
permissions:
9+
packages: write
10+
env:
11+
CACHE_IMAGE: orionrobots/orionrobots-site
12+
DOCKER_BUILDKIT: 1
13+
COMPOSE_DOCKER_CLI_BUILD: 1
814
steps:
915
- uses: actions/checkout@v4
1016

17+
- name: Set up Docker Buildx
18+
uses: docker/setup-buildx-action@v3
19+
20+
- name: Login to Docker
21+
uses: docker/login-action@74a5d142397b4f367a81961eba4e8cd7edddf772 # v3
22+
with:
23+
registry: ghcr.io
24+
username: ${{ github.actor }}
25+
password: ${{ github.token }}
26+
1127
- name: Build the site with docker compose
1228
run: |
13-
docker compose run --build build
29+
docker compose -f docker-compose.yml -f docker-compose.ci.yml run --build build
1430
1531
- name: Tarball the site
1632
run: |

.github/workflows/on_call_staging_test.yaml

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ on:
55
jobs:
66
staging_test:
77
runs-on: ubuntu-latest
8+
permissions:
9+
packages: write
10+
env:
11+
CACHE_IMAGE: orionrobots/orionrobots-site
12+
DOCKER_BUILDKIT: 1
13+
COMPOSE_DOCKER_CLI_BUILD: 1
814
steps:
915
- uses: actions/checkout@v4
1016
- name: Fetch site artifact
@@ -18,6 +24,13 @@ jobs:
1824
- name: Set up Docker Buildx
1925
uses: docker/setup-buildx-action@v3
2026

27+
- name: Login to Docker
28+
uses: docker/login-action@74a5d142397b4f367a81961eba4e8cd7edddf772 # v3
29+
with:
30+
registry: ghcr.io
31+
username: ${{ github.actor }}
32+
password: ${{ github.token }}
33+
2134
- name: Prepare staging context
2235
run: |
2336
# Copy staging files into the _site directory for the docker build
@@ -42,7 +55,7 @@ jobs:
4255
# Run BDD integration tests using docker compose
4356
echo "## BDD Test Results" >> $GITHUB_STEP_SUMMARY
4457
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
45-
docker compose run test 2>&1 | tee bdd_output.txt
58+
docker compose -f docker-compose.yml -f docker-compose.ci.yml run test 2>&1 | tee bdd_output.txt
4659
bdd_exit_code=$?
4760
cat bdd_output.txt >> $GITHUB_STEP_SUMMARY
4861
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY

docker-compose.ci.yml

Lines changed: 51 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,56 @@
11
services:
2+
serve:
3+
build:
4+
cache_from:
5+
- type=registry,ref=ghcr.io/orionrobots/orionrobots-site.serve:cache
6+
cache_to:
7+
- type=registry,ref=ghcr.io/orionrobots/orionrobots-site.serve:cache,mode=max
8+
9+
dist:
10+
build:
11+
cache_from:
12+
- type=registry,ref=ghcr.io/orionrobots/orionrobots-site.dist:cache
13+
cache_to:
14+
- type=registry,ref=ghcr.io/orionrobots/orionrobots-site.dist:cache,mode=max
15+
16+
build:
17+
build:
18+
cache_from:
19+
- type=registry,ref=ghcr.io/orionrobots/orionrobots-site.build:cache
20+
cache_to:
21+
- type=registry,ref=ghcr.io/orionrobots/orionrobots-site.build:cache,mode=max
22+
223
staging:
324
build:
425
cache_from:
5-
- type=gha
26+
- type=registry,ref=ghcr.io/orionrobots/orionrobots-site.staging:cache
27+
cache_to:
28+
- type=registry,ref=ghcr.io/orionrobots/orionrobots-site.staging:cache,mode=max
29+
30+
test:
31+
build:
32+
cache_from:
33+
- type=registry,ref=ghcr.io/orionrobots/orionrobots-site.test:cache
34+
cache_to:
35+
- type=registry,ref=ghcr.io/orionrobots/orionrobots-site.test:cache,mode=max
36+
37+
shell:
38+
build:
39+
cache_from:
40+
- type=registry,ref=ghcr.io/orionrobots/orionrobots-site.shell:cache
41+
cache_to:
42+
- type=registry,ref=ghcr.io/orionrobots/orionrobots-site.shell:cache,mode=max
43+
44+
http_serve:
45+
build:
46+
cache_from:
47+
- type=registry,ref=ghcr.io/orionrobots/orionrobots-site.http_serve:cache
48+
cache_to:
49+
- type=registry,ref=ghcr.io/orionrobots/orionrobots-site.http_serve:cache,mode=max
50+
51+
broken_links:
52+
build:
53+
cache_from:
54+
- type=registry,ref=ghcr.io/orionrobots/orionrobots-site.broken_links:cache
655
cache_to:
7-
- type=gha,mode=max
56+
- type=registry,ref=ghcr.io/orionrobots/orionrobots-site.broken_links:cache,mode=max

0 commit comments

Comments
 (0)