Do not include dev npm packages in final image

This commit is contained in:
Adrian Jagielak
2025-07-21 22:39:48 +02:00
parent 74c77738ff
commit 74ceb9ce31
4 changed files with 59 additions and 9 deletions

View File

@@ -4,12 +4,20 @@ FROM ${BUILD_FROM}
# ---------- install NodeJS ----------
RUN apk add --no-cache nodejs npm python3 make g++
# ---------- copy source -------------
# ---------- copy source & build -----
WORKDIR /usr/src/app
COPY package.json tsconfig.json ./
RUN npm install
COPY package.json package-lock.json tsconfig.json ./
# ① install EVERYTHING (prod + dev)
RUN npm ci
COPY src ./src
# ② compile TypeScript
RUN npm run build
# ③ throw dev stuff away so the final image stays small
RUN npm prune --omit=dev
# ---------- copy s6 service files ---
COPY rootfs /