perf: drop Prisma Studio's browser dependencies from the image
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 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012cSY9pVhZmJUKNN7wf1Myd
This commit is contained in:
+10
-1
@@ -30,6 +30,13 @@ RUN npx prisma generate && npm run build
|
|||||||
# drift from the client the application was built against. dotenv comes along
|
# drift from the client the application was built against. dotenv comes along
|
||||||
# because prisma.config.ts imports it; in a container the environment is
|
# because prisma.config.ts imports it; in a container the environment is
|
||||||
# already populated, but the file is shared with local development.
|
# 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
|
FROM node:22-alpine AS migrator
|
||||||
WORKDIR /cli
|
WORKDIR /cli
|
||||||
@@ -37,7 +44,9 @@ COPY package.json ./
|
|||||||
RUN PRISMA_VERSION="$(node -p "require('./package.json').dependencies.prisma")" \
|
RUN PRISMA_VERSION="$(node -p "require('./package.json').dependencies.prisma")" \
|
||||||
&& rm package.json \
|
&& rm package.json \
|
||||||
&& npm init -y > /dev/null \
|
&& 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
|
# runner — standalone output plus what the migrations need
|
||||||
|
|||||||
Reference in New Issue
Block a user