From fa681c53ecd89804e1bed44b9c0bcf94f4d4ad8a Mon Sep 17 00:00:00 2001 From: Johannes Henning Date: Sat, 24 May 2025 22:22:41 +0200 Subject: [PATCH] Compile in builder, use runner for pure javascript --- Dockerfile | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/Dockerfile b/Dockerfile index 3747a03..a6af752 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,24 +1,23 @@ -FROM node:lts-alpine - -RUN apk --no-cache add curl - -WORKDIR /app - -COPY app/ ./ - -RUN chown -R node:node /app +FROM node:lts-alpine as builder USER node +WORKDIR /app +COPY -chown=node:node app/ ./ -RUN npm install --omit=dev +RUN npm ci \ + && npx tsc + +FROM node:lts-alpine as runner + +USER node +WORKDIR /app +COPY --chown=node:node app/ ./ + +RUN apk --no-cache add curl \ + && npm ci --omit=dev ARG PACKAGE_VERSION ENV APP_VERSION=${PACKAGE_VERSION} ENV NODE_ENV=production -# Build without type checking, as we have removed the Typescript -# dev-dependencies above to save space in the final build. -# Type checking is done in the repo before building the image. -RUN npx tsc --noCheck - CMD ["node", "dist/index.js" ]