-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
68 lines (49 loc) · 1.7 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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
## -------------------------------------------------------------------
## BASE IMAGE
## ~~
## We need full node as we need git to download from some GitHub repos
## as of now.
## -------------------------------------------------------------------
FROM node:8.16.1 as BASE
ARG PORT=3001
ENV PORT=$PORT
ENV HOME /opt/scheduler-service
RUN mkdir -p $HOME
WORKDIR $HOME
COPY package.json ./
## -------------------------------------------------------------------
## DEPENDENCIES
## -------------------------------------------------------------------
FROM BASE as DEPENDENCIES
RUN npm install --silent --only=production
# copy production node_modules aside
RUN cp -R node_modules prod_node_modules
# install ALL node_modules, including 'devDependencies'
RUN npm install --silent
## -------------------------------------------------------------------
## TEST
## -------------------------------------------------------------------
# run linters, setup and tests
FROM dependencies AS TEST
COPY .eslintrc.json .
COPY /src ./src/
COPY /test ./test/
#ENV MOCHA_FILE=/junit/test-results.xml
#RUN mkdir /junit
RUN npm run lint && npm run test
CMD ["/bin/bash"]
## -------------------------------------------------------------------
## RELEASE
## -------------------------------------------------------------------
FROM node:8.16.1-alpine as RELEASE
ARG PORT=3001
ENV PORT=$PORT
ENV HOME /opt/scheduler-service
RUN mkdir -p $HOME
WORKDIR $HOME
COPY index.js package.json ./
# copy production node_modules
COPY --from=dependencies $HOME/prod_node_modules ./node_modules
COPY /src ./src/
EXPOSE $PORT
CMD ["npm", "run", "start"]