Optimize production Docker builds - #1503
Open
skyfallwastaken wants to merge 4 commits into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR optimizes the production Docker build to reduce cold build time and runtime image size by parallelizing dependency/asset stages and ensuring the SSR bundle no longer requires shipping node_modules in the final image.
Changes:
- Refactors the Dockerfile into parallel Ruby/JS dependency stages and parallel Rails/Blume asset stages, then combines outputs into a slimmer runtime image.
- Improves Docker build caching by excluding Blume-only inputs from the Rails asset compilation cache key.
- Updates Vite SSR configuration to bundle dependencies (
ssr.noExternal) so the SSR output is self-contained.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| Dockerfile | Splits dependency and asset compilation into parallel BuildKit stages; avoids copying build-only node_modules into the runtime image. |
| vite.config.ts | Makes the SSR bundle self-contained by setting ssr.noExternal: true. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Member
Author
|
@greptile-apps review |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary of the problem
Docker builds were very slow, and the images were rather large too!
Describe your changes
the gory details...
node_modulesis unnecessary.js_from_routesgeneration and Rails asset precompilation into one Rails boot.wget,unzip, andvimpackages. Retaincurlfor Coolify healthchecks. Git, tar, SQLite, PostgreSQL, libvips, fontconfig, and Bun remain available..ruby-version.Benchmarks
Measured on the same 8-vCPU, 15 GiB Amp orb with BuildKit v0.31.2 and overlayfs. Both builds exported compressed OCI archives, so wall time includes image compression/export.
--no-cacheused.mainat9913ab0.buildctl ducache accountingThe increased aggregate cold host memory is the intentional tradeoff for concurrent package, dependency, docs, client, and SSR work. BuildKit's own measured peak declined substantially and the total remains well below available CI memory.
Screenshots / Media
N/A