-
Notifications
You must be signed in to change notification settings - Fork 1
Add Docker registry caching with service-specific cache refs for all services in CI workflows #240
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Co-authored-by: dannystaple <426859+dannystaple@users.noreply.github.com>
🦙 MegaLinter status: ❌ ERROR
See detailed report in MegaLinter reports |
This doesn't appear to be using that cache. - name: Login to Docker
uses: docker/login-action@74a5d142397b4f367a81961eba4e8cd7edddf772 # v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ github.token }} |
Co-authored-by: dannystaple <426859+dannystaple@users.noreply.github.com>
You're absolutely right! I've added the Docker login action to both workflows ( |
Looking at the guide at https://testdriven.io/blog/faster-ci-builds-with-docker-cache/ we need more.
But with the right cache image name, perhaps orionrobots/orionrobots-site ? |
Co-authored-by: dannystaple <426859+dannystaple@users.noreply.github.com>
... Added the environment variables you suggested to both workflow files. Used |
Co-authored-by: dannystaple <426859+dannystaple@users.noreply.github.com>
Ahh - a problem here:
I think the token needs to be granted the package write scope using the permissions key? |
Co-authored-by: dannystaple <426859+dannystaple@users.noreply.github.com>
... Fixed the authentication issue by adding |
…rvice Co-authored-by: dannystaple <426859+dannystaple@users.noreply.github.com>
This PR extends the Docker Compose CI overlay to add registry-based caching for all services, significantly reducing build times in CI workflows.
Problem
Previously, only the
staging
service had caching configured indocker-compose.ci.yml
. This meant that other services likebuild
,test
,dist
, andserve
were rebuilding from scratch on every CI run, leading to unnecessarily long build times - particularly noticeable in the staging test workflow where "many minutes are spent retrieving and setting up dependencies, for a test that takes seconds to run."Solution
Extended
docker-compose.ci.yml
to add registry-based caching for all 8 services that build from Dockerfile:ghcr.io/orionrobots/orionrobots-site.{service_name}:cache
serve
,dist
,build
,test
,shell
,http_serve
,broken_links
,staging
Updated workflows to consistently use the CI overlay:
on_call_build_site.yaml
: Added Docker Buildx setup and CI overlay usageon_call_staging_test.yaml
: Updated test service to use CI overlayAdded Docker authentication and permissions to enable GitHub Container Registry access:
ghcr.io
registrygithub.actor
andgithub.token
for authenticationpackages: write
permission to allow pushing cache layers to GHCRAdded Docker environment variables for optimal caching performance:
CACHE_IMAGE: orionrobots/orionrobots-site
- Defines the cache image nameDOCKER_BUILDKIT: 1
- Enables Docker BuildKit for enhanced caching capabilitiesCOMPOSE_DOCKER_CLI_BUILD: 1
- Enables Docker CLI build features for ComposeService-specific cache strategy: Each service uses dedicated cache references like:
serve
→cache_from/to: type=registry,ref=ghcr.io/orionrobots/orionrobots-site.serve:cache
build
→cache_from/to: type=registry,ref=ghcr.io/orionrobots/orionrobots-site.build:cache
test
→cache_from/to: type=registry,ref=ghcr.io/orionrobots/orionrobots-site.test:cache
Benefits
Example
Before: Every
docker compose run build
downloads Node.js base image and runsnpm ci
from scratch.After: Subsequent runs will show
CACHED
for layers that haven't changed, dramatically reducing build time. Each service will maintain its own optimized cache.All changes follow
.editorconfig
conventions and maintain backward compatibility.Fixes #239.
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.