Skip to content

Instantly share code, notes, and snippets.

@MwinyiMoha
Created August 25, 2020 19:13
Show Gist options
  • Save MwinyiMoha/6efa4acd53ec91d2ed45ec03da47c62a to your computer and use it in GitHub Desktop.
Save MwinyiMoha/6efa4acd53ec91d2ed45ec03da47c62a to your computer and use it in GitHub Desktop.
# 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