feat(docker): install production dependencies only in the app images #251
No reviewers
Labels
No labels
dependencies
major
security-pin
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
trails-cool/trails!251
Loading…
Reference in a new issue
No description provided.
Delete branch "prod-only-images"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Closes #250.
The journal and planner runtime images now contain only production dependencies. A new
prod-depsstage runspnpm install --frozen-lockfile --prod, and the runtime stage copiesnode_modulesfrom it.Changes
package.jsondeclared, as dev dependencies. The table in #250 lists them.@trails-cool/i18nand@trails-cool/gpxinto the server build but leaves their own imports external. The apps therefore also declarei18next,i18next-browser-languagedetectorandlinkedom.drizzle-kitis now a dependency ofapps/journal, because the deploy runsdrizzle-kit pushinside the journal image.drizzle.config.tsnow uses a type-only import, so it no longer resolvesdrizzle-kitfrompackages/db/.Guards
import-x/no-extraneous-dependenciescovers app and package source. Every import must be declared in the importing package. Against the oldpackage.jsonfiles, it reports exactly the imports this PR declares.scripts/check-server-externals.mjsruns in the Docker build. It fails when the server bundle imports a package that does not resolve. Lint cannot find this kind of error. In the first test build, the journal then returned HTTP 500 for every page, while/api/healthreturned 200.Tested locally
Both images were built for arm64, with a throwaway PostGIS container on its own Docker network.
npx --no drizzle-kit push --config /app/packages/db/drizzle.config.ts --forcein the journal image applies the schema.--nomeans npx uses the installed copy and never downloads one.migrate-data.tsin the journal image exits with 0./api/health,/and/auth/login: all return 200. planner/healthand/: both return 200. The logs contain no errors.pnpm lint,pnpm typecheck,pnpm testandscripts/check-dockerfiles.shall pass. I did not run the e2e suite locally; CI runs it.Size
journal 1.77 → 1.47 GB, planner 1.71 → 1.35 GB. These are approximate: the test images are arm64 and the registry images are amd64.
The images are still large, because about 70 React Native and Expo packages are installed as production dependencies. pnpm resolves
drizzle-ormandreact-i18nextwith peer dependencies fromapps/mobileacross the whole workspace. That is a follow-up (noted in #250).Before merging
No auto-merge. A merge deploys new production images through
cd-apps.yml. Check the staging preview first.🤖 Generated with Claude Code
https://claude.ai/code/session_01LQv5c9rFGq2hSPpjLiFmQ8