/
Dockerfile
107 lines (78 loc) · 1.79 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
FROM node:18.18-alpine AS node
ENV NODE_OPTIONS --unhandled-rejections=strict --enable-source-maps
WORKDIR /app
COPY .npmrc \
package.json \
package-lock.json \
./
#
# Stage: Development NPM install
#
FROM node AS npm-dev
ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true
ENV TAIKO_SKIP_CHROMIUM_DOWNLOAD=true
ENV PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=true
RUN npm ci
#
# Stage: Development environment
#
FROM node AS dev
ENV NODE_ENV=development
ENV PRETTY_LOG=true
COPY .eslintignore \
.eslintrc.js \
.stylelintignore \
.stylelintrc \
jest.config.js \
tsconfig.json \
./
COPY --from=npm-dev /app/ .
COPY test/ test/
COPY src/ src/
COPY static/ static/
COPY data/ data/
COPY scripts/ scripts/
CMD ["sh", "./scripts/start-dev.sh"]
#
# Stage: Production build
#
FROM dev AS build-prod
ENV NODE_ENV=production
RUN npm run build
#
# Stage: Fast build without type checking
#
FROM dev AS build-fast
ENV NODE_ENV=production
COPY .swcrc ./
RUN npx swc src --out-dir build
RUN npm run build:css
#
# Stage: Production NPM install
#
FROM node AS npm-prod
RUN npm ci --production
#
# Stage: Production environment
#
FROM node AS prod
ENV NODE_ENV=production
COPY --from=npm-prod /app/ .
COPY --from=build-prod /app/build/src/ build/
COPY --from=build-prod /app/static/ static/
COPY data/ data/
HEALTHCHECK --interval=5s --timeout=1s \
CMD wget --quiet --tries=1 --spider http://localhost:80/ping || exit 1
CMD ["node", "./build/index.js"]
#
# Stage: Local environment with fast build
#
FROM node AS fast
ENV NODE_ENV=production
COPY --from=npm-prod /app/ .
COPY --from=build-fast /app/build/src/ build/
COPY --from=build-fast /app/static/ static/
COPY data/ data/
HEALTHCHECK --interval=5s --timeout=1s \
CMD wget --quiet --tries=1 --spider http://localhost:80/ping || exit 1
CMD ["node", "./build/index.js"]