Skip to content

fix(docker): 2-stage build, apt cache mounts, .dockerignore - #2487

Open
McCio wants to merge 3 commits into
jackyzha0:v5from
McCio:fix/docker-layering
Open

McCio wants to merge 3 commits into
jackyzha0:v5from
McCio:fix/docker-layering

Conversation

@McCio

@McCio McCio commented Jul 19, 2026 •

Copy link
Copy Markdown
Contributor

I noticed rebuilds were slow since npm install and plugin install shared a layer, so changing one busted the other. Pulling the image was also slow as everything was bundled together.

I initially split into three stages (builder, plugins, runtime) to cache npm and plugin install independently, then revised to two stages after realising that plugins with requiresInstall add native deps to root node_modules, so copying node_modules from a stage that skipped plugin install would silently drop those.

The builder stage now runs both npm ci and plugin install, each as its own layer, so the npm cache still survives a plugin-only change. The runtime stage copies node_modules and .quartz from builder.

I also added ENV NPM_CONFIG_USERCONFIG=/usr/src/app/.npmrc since plugin install can spawn child npm processes inside .quartz/plugins/<name>/, which would miss the root .npmrc otherwise, plus apt cache mounts to keep the apt cache out of the layers, a .dockerignore to keep node_modules and .quartz out of the build context, and glob patterns on quartz.lock.json and quartz.config.yaml.

@github-actions

github-actions Bot commented Jul 19, 2026 •

Copy link
Copy Markdown
built with Refined Cloudflare Pages Action

⚡ Cloudflare Pages Deployment

Name Status Preview Last Commit
quartz ✅ Ready (View Log) Visit Preview aca352d

@McCio

McCio commented Jul 25, 2026

Copy link
Copy Markdown
Contributor Author

@saberzero1 I see you are working on main branch on the dockerfile. should I realign this? I really think this should be merged, among the other things it reduced the final image size to just ~500MB instead of ~1.5GB

@McCio McCio changed the title fix(docker): 3-stage build, apt cache mounts, .dockerignore fix(docker): 2-stage build, apt cache mounts, .dockerignore Aug 5, 2026

This branch was successfully deployed

1 active deployment
Branch Preview — aca352d7 Deployed Aug 5, 2026 by github-actions[bot]
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