From b277d06106c1fe4de06e443398b9b0532fece360 Mon Sep 17 00:00:00 2001 From: quytranDF Date: Sun, 8 Sep 2024 16:09:17 +0700 Subject: [PATCH] config(pipeline): export running port --- Dockerfile | 50 ++++++++++++++++++++++++++------------------------ 1 file changed, 26 insertions(+), 24 deletions(-) diff --git a/Dockerfile b/Dockerfile index c93b40c..0f7fb6e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,24 +1,26 @@ -FROM node:16-alpine as build - -WORKDIR /app - -COPY package*.json ./ -RUN npm ci - -COPY --chown=node:node . . -RUN npm run build - -# Running `npm ci` removes the existing node_modules directory and passing in --only=production ensures that only the production dependencies are installed. This ensures that the node_modules directory is as optimized as possible -RUN npm ci --only=production && npm cache clean --force - -USER node - -FROM node:16-alpine - -WORKDIR /app - -COPY --from=build --chown=node:node /app/package*.json ./ -COPY --from=build --chown=node:node /app/node_modules ./node_modules -COPY --from=build --chown=node:node /app/dist ./dist - -CMD ["node", "dist/main.js"] \ No newline at end of file +FROM node:16-alpine as build + +WORKDIR /app + +COPY package*.json ./ +RUN npm ci + +COPY --chown=node:node . . +RUN npm run build + +# Running `npm ci` removes the existing node_modules directory and passing in --only=production ensures that only the production dependencies are installed. This ensures that the node_modules directory is as optimized as possible +RUN npm ci --only=production && npm cache clean --force + +USER node + +FROM node:16-alpine + +WORKDIR /app + +COPY --from=build --chown=node:node /app/package*.json ./ +COPY --from=build --chown=node:node /app/node_modules ./node_modules +COPY --from=build --chown=node:node /app/dist ./dist + +EXPOSE 3000 + +CMD ["node", "dist/main.js"]