Last active
October 11, 2021 22:58
-
-
Save gaboluque/7c687d2a6a7b960e84fb6805738d3792 to your computer and use it in GitHub Desktop.
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
## Stage one: where the app is built | |
FROM node:14.17 AS builder | |
WORKDIR /usr | |
# We copy the necessary files to build our project | |
COPY package.json ./ | |
COPY tsconfig.json ./ | |
COPY src ./src | |
# We build our project | |
RUN ls -a | |
RUN npm install | |
RUN npm run build | |
## Stage two: where the app actually runs | |
FROM node:14.17 AS runner | |
WORKDIR /usr | |
COPY package.json ./ | |
RUN npm install --only=production | |
# Here we copy all of our dist folder to the docker image | |
COPY --from=builder /usr/dist ./ | |
# PM2 will handle the actual server | |
RUN npm install pm2 -g | |
EXPOSE 8000 | |
# PM2 will handle the actual server | |
CMD ["pm2-runtime","src/index.js"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment