-
Notifications
You must be signed in to change notification settings - Fork 1
/
Dockerfile
49 lines (44 loc) · 1.1 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 Node ----
FROM alpine:3.11.5 AS base
# install nodejs
RUN apk add --no-cache nodejs
# set working directory
WORKDIR /app
# copy project files
COPY . .
#
# ---- Dependencies ----
FROM base AS dependencies
# install yarn pakage manager
RUN apk add yarn
# install only the production node_modules
RUN yarn --pure-lockfile --production=true
# prune unnecessary files from node_modules
RUN yarn modclean
# remove modclean folder from node_modules
RUN rm -R node_modules/modclean
# copy production node_modules aside
RUN cp -R node_modules prod_node_modules
# install ALL node_modules, including 'devDependencies'
RUN yarn --pure-lockfile --production=false
#
# ---- Test ----
FROM dependencies AS test
# prettify and lint
RUN yarn prettier && yarn lint
#
# ---- Cleanup ----
FROM base as cleanup
# remove unnecessary files
RUN rm .dockerignore && \
rm .eslintrc.js && \
rm .gitignore && \
rm .prettierrc && \
rm yarn.lock
#
# ---- Release ----
FROM cleanup AS release
# copy production node_modules
COPY --from=dependencies /app/prod_node_modules ./node_modules
ENTRYPOINT ["node", "./src/init.js"]