2nd attempt at optimising and hardening Docker image

This commit is contained in:
Maciej Pędzich 2024-07-22 09:17:33 +02:00
parent 979d77cca5
commit c0886b73e5
Signed by: maciejpedzich
GPG Key ID: CE4A303D84882F0D

View File

@ -1,11 +1,15 @@
FROM node:lts-alpine AS build FROM node:lts-alpine AS build
WORKDIR /app WORKDIR /app
COPY . . COPY . .
RUN npm i RUN npm ci
RUN npm run build RUN npm run build
FROM node:lts-alpine AS runtime FROM node:lts-alpine AS runtime
WORKDIR /app WORKDIR /app
COPY --from=build /app/dist /app ENV NODE_ENV production
CMD ["node", "./index.js"] USER node
COPY --chown=node:node package*.json ./
RUN npm ci --production
COPY --from=builder --chown=node:node /app/dist ./dist
EXPOSE 3000 EXPOSE 3000
CMD ["node", "./dist/index.js"]