Browse Source

Keep dev dependencies in the container so it can compile at start

NODE_ENV=production makes 'npm ci' omit devDependencies, which stripped
typescript and tsx from the bind-mounted node_modules on first start and left
the entrypoint unable to build. Both RELAY_MODE=prod (tsc) and dev (tsx watch)
compile from source at runtime, so the dev dependencies have to stay.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WvzjhjUY7tr5Naj1Co4N6B
Maciek 3 tuần trước cách đây
mục cha
commit
e09111b4d2
2 tập tin đã thay đổi với 5 bổ sung3 xóa
  1. 1 1
      Dockerfile
  2. 4 2
      docker/entrypoint.sh

+ 1 - 1
Dockerfile

@@ -12,7 +12,7 @@ WORKDIR /app
 
 # Warm the layer cache with the dependency manifests only.
 COPY package.json package-lock.json ./
-RUN npm ci
+RUN npm ci --include=dev
 
 COPY . .
 RUN npx prisma generate

+ 4 - 2
docker/entrypoint.sh

@@ -23,9 +23,11 @@ needs_refresh() {
 
 record() { mkdir -p "$STAMP_DIR"; hash_of "$1" > "$STAMP_DIR/$2"; }
 
-if [ ! -d node_modules/express ] || needs_refresh package-lock.json lock; then
+# --include=dev is required even in prod mode: NODE_ENV=production would
+# otherwise omit typescript/tsx, and both modes compile or watch from source.
+if [ ! -d node_modules/typescript ] || needs_refresh package-lock.json lock; then
   echo "[entrypoint] installing dependencies"
-  npm ci --no-audit --no-fund
+  npm ci --include=dev --no-audit --no-fund
   record package-lock.json lock
 else
   echo "[entrypoint] dependencies up to date"