Skip to content

Instantly share code, notes, and snippets.

@angeloreale
Created February 4, 2019 01:59
Show Gist options
  • Save angeloreale/aa878acfb584458467dc5846dafcd68a to your computer and use it in GitHub Desktop.
Save angeloreale/aa878acfb584458467dc5846dafcd68a to your computer and use it in GitHub Desktop.
Dockerizing a Node.js and MongoDB app with CI/CD Pipelines on Gitlab for staging and production environments.
# Use an official Node runtime as a parent image
FROM node:latest
# Set the working directory to /app
WORKDIR /app
# Copy the current directory contents into the container at /app
COPY . /app
# Install any needed packages specified in package.json as well as PM2 to ensure the app integrity.
RUN npm install
RUN npm install pm2 -g
# Make port 80 available to the world outside this container
EXPOSE 80
# Run app.js under PM2 when the container launches
CMD ["pm2-runtime", "app.js"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment