Created
January 11, 2022 19:34
-
-
Save InclinedScorpio/0dab33b783cb84cd7eb02985dc10df4e to your computer and use it in GitHub Desktop.
Nodejs Typescript Dockerfile
This file contains 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
# stage 1 building the code, dev dependencies will be required (convert TS -> JS) | |
FROM node as builder | |
WORKDIR /usr/app | |
COPY package*.json ./ | |
RUN npm install | |
COPY . . | |
RUN npm run build | |
# stage 2, now as build is created, copy it from stage 1 and use it with prod dependencies | |
FROM node | |
WORKDIR /usr/app | |
COPY package*.json ./ | |
RUN npm install --production | |
COPY --from=builder /usr/app/dist ./dist | |
COPY .env . | |
EXPOSE 4000 | |
CMD node dist/src/index.js |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment