-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
150 lines (108 loc) · 2.25 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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
FROM node:16-alpine3.12 AS node
WORKDIR /app
RUN \
apk add --no-cache \
netcat-openbsd \
postgresql-client
COPY \
.npmrc \
package.json \
package-lock.json \
./
#
# Stage: Builder
#
FROM node AS builder
RUN \
apk add --no-cache --virtual .build-deps \
git \
&& npm ci \
&& npm cache clean --force \
&& rm -rf ~/.node-gyp \
&& apk del --no-cache .build-deps
COPY \
.parcelrc \
.terserrc \
tsconfig.json \
./
#
# Stage: Scripts build
#
FROM builder AS scripts
COPY src/common/ src/common/
COPY src/backend/ src/backend/
RUN \
npm run build:scripts \
&& rm -rf .parcel-cache
#
# Stage: Backend build
#
FROM builder AS backend
COPY src/common/ src/common/
COPY src/backend/ src/backend/
RUN \
npm run build:backend \
&& rm -rf .parcel-cache
#
# Stage: Frontend build
#
FROM builder AS frontend
COPY --from=scripts /app/dist/scripts/ dist/scripts/
COPY src/common/ src/common/
COPY src/frontend/ src/frontend/
RUN \
mkdir --parents dist src/frontend/hooks \
&& npm run build:hooks \
&& npm run build:frontend \
&& rm -rf .parcel-cache
#
# Stage: Development
#
FROM builder AS dev
ENV NODE_ENV=development
COPY \
.eslintignore \
.eslintrc.json \
.gitignore \
.prettierignore \
.prettierrc \
.proxyrc \
docker-entrypoint.sh \
jest.config.ts \
tsconfig.dev.json \
./
COPY --from=scripts /app/dist/scripts/ dist/scripts/
COPY --from=backend /app/dist/backend/ dist/backend/
ENTRYPOINT ["./docker-entrypoint.sh"]
CMD ["start:dev"]
#
# Stage: Production
#
FROM node AS prod
RUN apk add --update --no-cache \
curl
EXPOSE 3000
RUN \
apk add --no-cache --virtual .build-deps \
git \
&& npm ci --production \
&& npm cache clean --force \
&& rm -rf ~/.node-gyp \
&& apk del --no-cache .build-deps
COPY --from=scripts /app/dist/scripts/ dist/scripts/
COPY --from=backend /app/dist/backend/ dist/backend/
COPY --from=frontend /app/dist/frontend/ dist/frontend/
COPY ./docker-entrypoint.sh .
HEALTHCHECK --interval=5s \
--timeout=5s \
--retries=6 \
CMD curl -fs http://localhost:3000/ || exit 1
ENV NODE_ENV=production
USER node
ENTRYPOINT ["./docker-entrypoint.sh"]
CMD ["start"]
#
# Stage: Integration
#
FROM prod AS integration
ENV NODE_ENV=integration