Last active
December 13, 2023 01:21
-
-
Save gjerokrsteski/43e4c6d5763d6fe166eb7f3e5e4222c8 to your computer and use it in GitHub Desktop.
Dockerfile with multi-stage build for dev and production
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM node:12-alpine as base | |
WORKDIR /src | |
COPY package.json package-lock.json /src/ | |
COPY . /src | |
EXPOSE 8080 | |
FROM base as production | |
ENV NODE_ENV=production | |
RUN npm install --production | |
CMD ["node", "index.js"] | |
FROM base as dev | |
ENV NODE_ENV=development | |
RUN npm config set unsafe-perm true && npm install -g nodemon | |
RUN npm install | |
CMD ["npm", "start"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Run the following commands to build the dev and the production images: