#21: keep devDependencies in the build stage regardless of NODE_ENV

The deployment sets NODE_ENV=production, and npm omits devDependencies
when it is set - so "npm ci" in the build stage installed no typescript
and "npm run build" failed with exit 127, command not found. The first
Coolify deployment died there.

The build stage now asks for them explicitly rather than depending on the
environment it happens to run in. Reproduced by building all three images
with NODE_ENV=production before and after.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
Lucas RayanandClaude Opus 5 committed 2026-08-02 14:08:09 -03:00
1 parent 7a4ca10a39
commit 64c9efe078
3 files changed
+11 -5

No files matched your search

+4 -2
View File
@@ -2,8 +2,10 @@ FROM node:20-alpine AS build
WORKDIR /app WORKDIR /app
COPY package.json package-lock.json* ./ COPY package.json package-lock.json* ./
# npm ci, not npm install: the image must be the lockfile's content, not # npm ci, not npm install: the image must be the lockfile's content, not
# whatever resolves the day it is built. # whatever resolves the day it is built. --include=dev because this stage
RUN npm ci # needs typescript, and npm omits devDependencies when NODE_ENV=production -
# which the deployment sets.
RUN npm ci --include=dev
COPY . . COPY . .
RUN npm run build RUN npm run build
+4 -2
View File
@@ -2,8 +2,10 @@ FROM node:20-alpine AS build
WORKDIR /app WORKDIR /app
COPY package.json package-lock.json* ./ COPY package.json package-lock.json* ./
# npm ci, not npm install: the image must be the lockfile's content, not # npm ci, not npm install: the image must be the lockfile's content, not
# whatever resolves the day it is built. # whatever resolves the day it is built. --include=dev because this stage
RUN npm ci # needs typescript, and npm omits devDependencies when NODE_ENV=production -
# which the deployment sets.
RUN npm ci --include=dev
COPY . . COPY . .
RUN npm run build RUN npm run build
+3 -1
View File
@@ -1,7 +1,9 @@
FROM node:20-alpine AS build FROM node:20-alpine AS build
WORKDIR /app WORKDIR /app
COPY package.json package-lock.json* ./ COPY package.json package-lock.json* ./
RUN npm ci # --include=dev: the Next build needs devDependencies, and npm omits them
# when NODE_ENV=production, which the deployment sets.
RUN npm ci --include=dev
COPY . . COPY . .
RUN npm run build RUN npm run build