From 0603d97dee1deb378049479bcaca2ad51c73570f Mon Sep 17 00:00:00 2001 From: Justin McLellan Date: Sat, 8 Aug 2026 01:14:43 -0500 Subject: [PATCH] Stub Prisma Studio out of the runtime image MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The migrator stage pulled in @prisma/studio-core and its UI stack (effect, @electric-sql, react-dom, elkjs) — about 95MB that `migrate deploy` never loads. Deleting it does not work: the CLI eagerly requires several @prisma/studio-core subpaths and dies with 'Cannot find module'. An npm override pointing at a stub with a wildcard exports map satisfies every subpath, and --install-links copies the stub into node_modules so it survives the COPY into the runner stage. Image drops from 685MB to 591MB. Pull and extract was ~120s of template's 202s deploy, and the old container is stopped before it starts, so this shortens the outage window on every deploy. Verified against the full production stack: all 4 migrations applied, the container exited 0, the app came up healthy and served the VAPID key. Co-Authored-By: Claude Opus 5 (1M context) --- Dockerfile | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 06bf5f9..4222736 100644 --- a/Dockerfile +++ b/Dockerfile @@ -47,8 +47,15 @@ FROM base AS migrator WORKDIR /src COPY package.json ./ WORKDIR /migrator +# @prisma/studio-core pulls in a UI stack (effect, @electric-sql, react-dom, +# elkjs) that `migrate deploy` never loads — ~95MB. Stub it via an npm override; +# --install-links copies rather than symlinks so it survives the COPY below. RUN npm init -y > /dev/null && \ - npm install --no-audit --no-fund \ + mkdir -p stub && \ + printf '{"name":"@prisma/studio-core","version":"0.0.0","main":"index.js","exports":{".":"./index.js","./*":"./index.js"}}' > stub/package.json && \ + printf 'module.exports=new Proxy({},{get:()=>undefined});' > stub/index.js && \ + npm pkg set overrides.@prisma/studio-core=file:./stub && \ + npm install --no-audit --no-fund --install-links \ "prisma@$(node -p "require('/src/package.json').devDependencies.prisma")" \ "dotenv@$(node -p "require('/src/package.json').dependencies.dotenv")"