fix(smtp): install the SMTP server from the monorepo lockfile in every build
Merged
KM
8d ago+132+132+012345678901234567890123456789-337-337-012345678901234567890123456789
The SMTP server's dependencies were never installed from our lockfile, in production or in the self-host image. This makes every build install exactly the locked versions.
The problem
apps/smtp-server/pnpm-workspace.yamlmade the SMTP app its own pnpm workspace. So pnpm installed it without the rootpnpm-lock.yamland resolved fresh versions on every build.- Production (Coolify) had a second, unlocked
apps/smtp-server/node_modulesthat the server actually loads: smtp-server 3.21.4, nodemailer 10.5.0, mailparser 3.14.3. The lockfile said 3.21.1, 10.2.1 and 3.12.4. - The self-host
smtp-proxyimage was built withcontext: ./apps/smtp-server, where there's no lockfile, so itspnpm installwas unlocked too.
What changed
- Removed
apps/smtp-server/pnpm-workspace.yaml. Its settings (allowBuilds: esbuild, thelinkify-itoverride) are already in the root workspace file. - The lockfile and
package.jsonnow pin smtp-server 3.21.4, nodemailer 10.5.0 and mailparser 3.14.3, the versions production runs today, so live behaviour doesn't change.- Only those packages and their deps (libmime, @zone-eu/mailsplit, encoding-japanese) change version. I diffed every
name@versionin the lockfile's packages section. - The other lockfile churn is pnpm re-normalising optional-peer suffixes (e.g.
next@15.5.29no longer lists the optional@babel/corepeer). No versions change, and the web app has no Babel config (SWC).
- Only those packages and their deps (libmime, @zone-eu/mailsplit, encoding-japanese) change version. I diffed every
apps/smtp-server/Dockerfilenow builds from the repository root:pnpm install --frozen-lockfile --filter smtp-server, then build.- Then a
--prodfrozen reinstall, so the image carries only runtime deps (no typescript/tsup/vitest). - The builder copies only
src,tsconfig.jsonandtsup.config.ts, never local.envfiles ornode_modules. - The image mirrors the repo layout and still runs from
/app(CMD node apps/smtp-server/dist/server.js), so a mounted/app/.envkeeps loading. Same ports and env vars.
publish.yml: the smtp-proxy build context is now...dockerignorenow applies at any depth (**/node_modules,**/.next/,**/.turbo,**/.env,**/.env.*, keeping**/.env*.example). With a whole-repo build context, a developer's nested.envornode_modulescan no longer reach either image. Verified by planting both and listing the build context.
Verified locally (re-run after the review fixes: SMTP image amd64, 4-port end-to-end, web image build)
- New image (amd64): Node 22.23.5, and versions match the lockfile exactly. No dev tools in the image (224 MB).
- End-to-end: with test TLS certs and a fake useSend API, I sent mail with nodemailer through 465, 587, 2465 and 2587. All returned
250 OK, and the API received each email with the right auth, recipient and subject. - Coolify's current Nixpacks build (its exact install/build/start commands) still works, and now resolves the lockfile versions (3.21.4 / 10.5.0). So a Coolify redeploy before the switch is safe.
- SMTP unit tests 20/20. Web: typecheck, unit 313, tRPC 23, API 44, plus
pnpm build:editor && pnpm build:web.
Next
- Switch the Coolify SMTP app to this Dockerfile (base dir
/, Dockerfileapps/smtp-server/Dockerfile), and narrow its disk mount. - Then delete
nixpacks.tomlanddocker/nixpacks/install-node.sh, which nothing will use any more.
Self-hosters get the reproducible image in the next release. The container still starts in /app.
Not changed here: the container still runs as root, as before. Switching to USER node would break reading the root-only Let's Encrypt keys, so it gets its own change.