Created
August 25, 2020 19:13
-
-
Save MwinyiMoha/6efa4acd53ec91d2ed45ec03da47c62a to your computer and use it in GitHub Desktop.
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
# Final stage | |
FROM node AS final | |
# Prepare destination directory and ensure user node owns it | |
RUN mkdir -p /home/node/app/dist && chown -R node:node /home/node/app | |
# Set CWD | |
WORKDIR /home/node/app | |
# Copy package.json and package-lock.json | |
COPY package*.json ./ | |
# Switch to user node | |
USER node | |
# Install libraries as user node | |
RUN npm i --only=production | |
# Copy js files and change ownership to user node | |
COPY --chown=node:node --from=builder /app/dist ./dist | |
# Open desired port | |
EXPOSE 3000 | |
# Use js files to run the application | |
ENTRYPOINT ["node", "./dist/index.js"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment