-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
106 lines (83 loc) · 2.27 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
FROM node:22.13.1-bookworm-slim AS node
ENV NODE_OPTIONS="--unhandled-rejections=strict --enable-source-maps"
WORKDIR /app
#
# Stage: NPM environment
#
FROM node AS npm
COPY .npmrc \
package.json \
package-lock.json \
./
#
# Stage: intlc environment
#
FROM --platform=linux/amd64 debian:12.9-slim AS intlc
ENV LANG=C.UTF-8
ENV LC_ALL=C.UTF-8
WORKDIR /app
ADD https://github.com/unsplash/intlc/releases/download/v0.8.3/intlc-v0.8.3-linux-x86_64 /usr/local/bin/intlc
COPY --from=ghcr.io/tests-always-included/mo:3.0.5 /usr/local/bin/mo /usr/local/bin/mo
RUN chmod +x /usr/local/bin/intlc
#
# Stage: Development NPM install
#
FROM npm AS npm-dev
ENV PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1
RUN npm ci --engine-strict --ignore-scripts
#
# Stage: Production NPM install
#
FROM npm AS npm-prod
RUN npm ci --engine-strict --ignore-scripts --production
#
# Stage: Intlc build
#
FROM intlc AS build-intlc
COPY .dev/ .dev/
COPY scripts/ scripts/
COPY locales/ locales/
RUN scripts/intlc.sh
#
# Stage: Production build
#
FROM npm AS build-prod
ENV NODE_ENV=production
COPY --from=npm-dev /app/node_modules/ node_modules/
COPY tsconfig.build.json \
tsconfig.json \
webpack.config.cjs \
./
COPY src/ src/
COPY assets/ assets/
COPY --from=build-intlc /app/assets/locales/ assets/locales/
COPY --from=build-intlc /app/src/locales/ src/locales/
RUN npm run build:assets && npm run build:app
#
# Stage: Integration test environment
#
FROM mcr.microsoft.com/playwright:v1.50.1-jammy AS test-integration
WORKDIR /app
COPY --from=npm-dev /app/ .
COPY --from=build-prod /app/dist/assets/ dist/assets/
COPY --from=build-prod /app/src/ src/
COPY integration/ integration/
COPY visual-regression/ visual-regression/
COPY playwright.config.ts .
ENTRYPOINT ["npx", "playwright", "test"]
#
# Stage: Production environment
#
FROM node AS prod
ENV NODE_ENV=production
RUN apt-get update && apt-get install --yes \
wget \
&& rm --recursive --force /var/lib/apt/lists/*
RUN mkdir data && chown node:node data && echo '{"type": "module"}' > /app/package.json
COPY --from=npm-prod /app/node_modules/ node_modules/
COPY --from=build-prod /app/dist/ dist/
HEALTHCHECK --interval=5s --timeout=1s \
CMD wget --quiet --tries=1 --spider http://localhost:3000/health || exit 1
EXPOSE 3000
USER node
CMD ["node", "dist/index.js"]