From a9b3481f4746f80c7b7fdf112f1f0a1e29f9674f Mon Sep 17 00:00:00 2001 From: sharkeshd <110453042+sharkeshd@users.noreply.github.com> Date: Tue, 24 Sep 2024 20:17:13 +0530 Subject: [PATCH] Update Dockerfile Key Points: Base Stage: This stage sets up the working directory and the base image. Development Stage: It installs all dependencies (including dev dependencies) and sets up the command for development. Production Stage: It installs only production dependencies, making the final image smaller. --- Dockerfile | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index e78e737..f62a27f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,16 +1,19 @@ +# Base stage FROM node:lts AS base WORKDIR /usr/local/app +# Development stage FROM base AS dev ENV NODE_ENV=development COPY app/package.json app/yarn.lock ./ RUN yarn install && yarn cache clean -COPY app . +COPY app ./ CMD ["yarn", "dev"] +# Production stage FROM base AS prod ENV NODE_ENV=production COPY app/package.json app/yarn.lock ./ RUN yarn install --production && yarn cache clean -COPY app . -CMD ["node", "src/index.js"] \ No newline at end of file +COPY app ./ +CMD ["node", "src/index.js"]