-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
executable file
·40 lines (35 loc) · 989 Bytes
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
### Node Cache Stage
FROM node:12-alpine as node_cache
# Configure path
WORKDIR /src/
RUN chmod -R 777 /src/
# Install app dependecies
USER node
COPY app/package.json .
# Install dependencies
RUN npm prune
RUN npm install
RUN npm audit fix
### App Stage
FROM node:12-alpine
# Setting up envs
ENV N_PATH "/usr/src/app"
ENV N_USER "node"
# Install nodemon or pm2 for production
RUN npm install -g pm2 nodemon
# Create app dir
WORKDIR ${N_PATH}
RUN chmod -R 777 ${N_PATH}
# Adding files to project
COPY ./app .
RUN chown -R ${N_USER}:${N_USER} .
COPY --chown=$N_USER:$N_USER --from=node_cache /src/node_modules ./node_modules
COPY --chown=$N_USER:$N_USER --from=node_cache /src/package-lock.json ./package-lock.json
# Setting up logs dir
RUN mkdir -p /home/${N_USER}/.npm/_logs
RUN chown -R ${N_USER}:${N_USER} /home/${N_USER}/.npm
USER ${N_USER}
CMD [ "nodemon", "-L", "index.js" ]
# CMD [ "nodemon", "-L", "./app.js" ]
# CMD [ "pm2-runtime", "/usr/src/app/ecosystem.json" ]
EXPOSE 4000