Skip to content

Commit 7351ca9

Browse files
authored
Create Dcokerfile
1 parent b5987a7 commit 7351ca9

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

Dcokerfile

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
FROM node:alpine
2+
3+
# Set working directory
4+
WORKDIR /usr/app
5+
6+
# Install PM2 globally
7+
RUN npm install --global pm2
8+
9+
# Copy "package.json" and "package-lock.json" before other files
10+
# Utilise Docker cache to save re-installing dependencies if unchanged
11+
COPY ./package*.json ./
12+
13+
# Install dependencies
14+
RUN npm install --production
15+
16+
# Copy all files
17+
COPY ./ ./
18+
19+
# Expose the listening port
20+
EXPOSE 80
21+
22+
# Run container as non-root (unprivileged) user
23+
# The "node" user is provided in the Node.js Alpine base image
24+
USER node
25+
26+
# Launch app with PM2
27+
CMD [ "pm2-runtime", "start", "npm", "--", "start" ]

0 commit comments

Comments
 (0)