Halving CI/CD deploy time: patching manifest to skip redundant Docker build in svc package #6098
thomaswitt
started this conversation in
Show and tell
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Problem
When using
copilot svc packagein a CodeBuild pipeline, Copilot triggers a full Docker build if the manifest specifiesimage.build. This means the image gets built twice per deployment:docker buildx build→ push to ECR (the one you actually want)copilot svc packageseesimage.buildand rebuilds, even though the image already exists in ECRDocker layer caching in CodeBuild was also unreliable in our setup, so each redundant build was essentially a from-scratch build every time.
Solution
Before the
svc packageloop, patch the manifest to replaceimage.buildwithimage.locationpointing to the already-pushed ECR image:How it works
awk— replaces the entireimage:block withimage.location: <ECR_REPO>:<TAG>copilot svc packageseesimage.locationand skips buildingResult
~50% reduction in pipeline time — eliminating one full Docker build per deployment across all environments.
Setup
Load Balanced Web Servicewithimage.build: Dockerfilecopilot svc package→ CloudFormation deploylinux/arm64(Graviton)Hope this helps anyone running into the same double-build issue! 🚀
Beta Was this translation helpful? Give feedback.
All reactions