Skip to content

Deploy in about a minute: pull CI-built images instead of building on the VPS - #3

Merged
rshdhere merged 1 commit into
mainfrom
ci/prebuilt-images
Oct 5, 2026
Merged

rshdhere merged 1 commit into
mainfrom
ci/prebuilt-images

Conversation

@rshdhere

@rshdhere rshdhere commented Oct 5, 2026 •

Copy link
Copy Markdown
Owner

Why

The deploy job ran docker compose build --pull on the VPS: all 14 images, including three Rust servers, compiled on a 2-core, 4 GB machine that is also serving the stack and other sites. The deploy for PR #2 was still building after 27 minutes, while CI had already built every image on GitHub's runners minutes earlier.

What changes

  • images job: on pushes to main, also pushes each image to ghcr.io/rshdhere/load-test/<name>:<commit>. It reuses the build cache from the step before, so this is mostly an upload.
  • compose: images are ${IMAGE_REGISTRY:-o11y}/<name>:${IMAGE_TAG:-local}, so local docker compose up --build is unchanged.
  • deploy.sh: with IMAGE_TAG set it runs compose pull and up --no-build, then deletes this stack's images from earlier deploys (only those, so other images on the machine are untouched). Without it, it still builds, for manual use.
  • deploy job: logs the VPS into GHCR with the job's own GITHUB_TOKEN (packages: read, valid only while the job runs), deploys, and logs out. No long-lived credential on the VPS; works whether or not the packages are public.

Notes

  • If a pull fails, the deploy stops before up, so the running stack keeps serving the previous version.
  • The first run on main creates the GHCR packages.

… VPS

- Push every image to ghcr.io/<repo>/<name>:<commit> from the images job on main, reusing its build cache
- Name compose images ${IMAGE_REGISTRY:-o11y}/<name>:${IMAGE_TAG:-local}, so local builds keep working
- Make infra/deploy.sh pull and start with --no-build when IMAGE_TAG is set, and build only when run by hand without it
- Log the VPS into GHCR with the deploy job's short-lived token and log out when done
- Remove this stack's images from earlier deploys after each pull, leaving other images on the machine alone
- Document the faster deploy and the manual path in infra/README.md
@rshdhere
rshdhere merged commit a77980e into main Oct 5, 2026
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant