forked from stefanwalther/docker-test
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
67 lines (47 loc) · 1.31 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
ARG NODE_VER="14.3.0"
# --------------------------------------
# BASE NODE
# --------------------------------------
FROM node:${NODE_VER}-alpine as BASE
ARG PORT=3000
ENV PORT=$PORT
ENV HOME=/app
RUN mkdir -p $HOME
WORKDIR $HOME
COPY package.json package-lock.json ./
# --------------------------------------
# DEPENDENCIES
# --------------------------------------
FROM BASE as DEPENDENCIES
RUN npm install -g npm@8.11.0
RUN npm version
RUN npm install --only=production
RUN npm version
# copy production node_modules aside
RUN cp -R node_modules prod_node_modules
# install ALL node_modules, including 'devDependencies'
RUN npm install
RUN npm version
RUN npm ci
RUN npm install prisma --save-dev
RUN npx prisma
RUN prisma generate
# --------------------------------------
# TEST
# --------------------------------------
# run linters, setup and tests
FROM dependencies AS TEST
COPY .eslintrc.json .
COPY /src ./src/
COPY /test ./test/
RUN npm run lint && npm run test
# --------------------------------------
# RELEASE
# --------------------------------------
FROM BASE as RELEASE
# copy production node_modules
COPY --from=dependencies /app/prod_node_modules ./node_modules
COPY /src ./src/
COPY ./nodemon.json ./
EXPOSE $PORT
CMD ["npm", "run", "start"]