From 64c9efe078dceb9ed034e9173080e6668601e0ea Mon Sep 17 00:00:00 2001 From: Lucas Rayan Date: Sun, 2 Aug 2026 14:08:09 -0300 Subject: [PATCH] #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 --- services/auth/Dockerfile | 6 ++++-- services/storage/Dockerfile | 6 ++++-- services/webmail/Dockerfile | 4 +++- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/services/auth/Dockerfile b/services/auth/Dockerfile index 908ddb7..b6ec99d 100644 --- a/services/auth/Dockerfile +++ b/services/auth/Dockerfile @@ -2,8 +2,10 @@ FROM node:20-alpine AS build WORKDIR /app COPY package.json package-lock.json* ./ # npm ci, not npm install: the image must be the lockfile's content, not -# whatever resolves the day it is built. -RUN npm ci +# whatever resolves the day it is built. --include=dev because this stage +# needs typescript, and npm omits devDependencies when NODE_ENV=production - +# which the deployment sets. +RUN npm ci --include=dev COPY . . RUN npm run build diff --git a/services/storage/Dockerfile b/services/storage/Dockerfile index 96ccdf8..6d4862b 100644 --- a/services/storage/Dockerfile +++ b/services/storage/Dockerfile @@ -2,8 +2,10 @@ FROM node:20-alpine AS build WORKDIR /app COPY package.json package-lock.json* ./ # npm ci, not npm install: the image must be the lockfile's content, not -# whatever resolves the day it is built. -RUN npm ci +# whatever resolves the day it is built. --include=dev because this stage +# needs typescript, and npm omits devDependencies when NODE_ENV=production - +# which the deployment sets. +RUN npm ci --include=dev COPY . . RUN npm run build diff --git a/services/webmail/Dockerfile b/services/webmail/Dockerfile index d16f193..952540b 100644 --- a/services/webmail/Dockerfile +++ b/services/webmail/Dockerfile @@ -1,7 +1,9 @@ FROM node:20-alpine AS build WORKDIR /app 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 . . RUN npm run build