-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
49 lines (37 loc) · 1.06 KB
/
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
41
42
43
44
45
46
47
48
49
# base used
FROM telkomindonesia/alpine:nodejs-8.9.3
# maintainer
LABEL maintainer="Aas Suhendar <aas.suhendar@gmail.com>"
# Environment
ENV PM2_INSTANCE 1
# Add workdir
WORKDIR /usr/src/app
# Cached layer for node modules
ADD package.json /tmp/package.json
RUN cd /tmp && npm i -g npm && npm install --production
RUN mkdir -p /usr/src/app \
&& cp -a /tmp/node_modules /usr/src
# Add project files
ADD . /usr/src/app
# update node_module, and change permission
# setting native node js
# RUN rm -rf node_modules \
# && mv /usr/src/node_modules /usr/src/app/ \
# setting pm2
RUN rm -rf /tmp/node_modules \
&& mkdir -p /.pm2 \
&& chown -R user:root /.pm2 \
&& chmod 775 /.pm2 \
&& chmod -R 775 uploaded \
&& chmod -R 775 logs
# expose port
EXPOSE 3000
# RUN command native
# CMD ["npm","start"]
# Healthcheck
HEALTHCHECK --interval=5s --timeout=3s CMD ["curl", "http://127.0.0.1:3000/health"] || exit 1
# Mounting Volume
VOLUME ["/usr/src/app/uploaded"]
VOLUME ["/usr/src/app/logs"]
# RUN command pm2
CMD ["sh","-c","pm2 start bin/www --no-daemon -i $PM2_INSTANCE"]