From f9f11ae88ba65f093b934ce27036e56d147fb342 Mon Sep 17 00:00:00 2001 From: vl Date: Sun, 20 Sep 2026 22:58:31 +0200 Subject: [PATCH] perf: drop Prisma Studio's browser dependencies from the image MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The Prisma CLI ships Studio, which brings React and a graph-layout engine along with it — tens of megabytes for a browser tool this image will never run. Removing them takes the image from 705 MB to 649 MB. `effect` looks like part of the same bundle and is not: the CLI itself requires it, and removing it breaks `migrate deploy` outright. That was found by running the migration in the pruned image rather than by reading the dependency tree. Worth recording how the first attempt at this went wrong: the prune was tried inside a running container, where the files belong to root and the process runs as node, so every `rm` failed silently behind a `2>/dev/null`. The migration then passed against an untouched tree and looked like proof. The check only became a check once the prune happened at build time. The entrypoint migrates on every start, so an over-eager prune now fails loudly at first boot rather than quietly at the worst moment. Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_012cSY9pVhZmJUKNN7wf1Myd --- Dockerfile | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 2318cea..40df0ea 100644 --- a/Dockerfile +++ b/Dockerfile @@ -30,6 +30,13 @@ RUN npx prisma generate && npm run build # drift from the client the application was built against. dotenv comes along # because prisma.config.ts imports it; in a container the environment is # already populated, but the file is shared with local development. +# +# The CLI ships Prisma Studio, which drags in React and a graph-layout engine +# this image will never run; those are removed here. `effect` looks like part +# of the same bundle but is not — the CLI itself requires it, and removing it +# breaks `migrate deploy` outright. The entrypoint runs a migration on every +# start, so an over-eager prune fails loudly at the first boot rather than +# quietly at the worst moment. # --------------------------------------------------------------------------- FROM node:22-alpine AS migrator WORKDIR /cli @@ -37,7 +44,9 @@ COPY package.json ./ RUN PRISMA_VERSION="$(node -p "require('./package.json').dependencies.prisma")" \ && rm package.json \ && npm init -y > /dev/null \ - && npm install --no-audit --no-fund --omit=dev "prisma@${PRISMA_VERSION}" dotenv + && npm install --no-audit --no-fund --omit=dev "prisma@${PRISMA_VERSION}" dotenv \ + && rm -rf node_modules/react node_modules/react-dom node_modules/scheduler \ + node_modules/elkjs node_modules/@electric-sql # --------------------------------------------------------------------------- # runner — standalone output plus what the migrations need