-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
50 lines (36 loc) · 1.67 KB
/
Copy pathDockerfile
File metadata and controls
50 lines (36 loc) · 1.67 KB
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
# syntax=docker/dockerfile:1.7
ARG NODE_VERSION=22-bookworm-slim
FROM --platform=$BUILDPLATFORM node:${NODE_VERSION} AS dependencies
WORKDIR /app
ENV CI=true
COPY package.json package-lock.json ./
RUN --mount=type=cache,target=/root/.npm \
npm ci --include=dev --no-audit --no-fund
FROM dependencies AS builder
WORKDIR /app
ENV NODE_ENV=production
COPY . .
RUN npm run build
RUN node scripts/assert-portable-runtime.mjs \
/app/dist/standalone /app/node_modules/react && \
install -d -m 0755 /runtime-data
FROM node:${NODE_VERSION} AS runner
WORKDIR /app
ENV NODE_ENV=production \
HOST=0.0.0.0 \
PORT=3000
# Keep target-platform stages command-free: the portable JS/WASM build is
# produced once on BUILDPLATFORM, then linked onto each native Node base image.
COPY --link --from=builder --chown=1000:1000 /runtime-data/ ./data/
COPY --link --from=builder --chown=1000:1000 /app/dist/standalone/dist ./dist
COPY --link --from=builder --chown=1000:1000 /app/dist/standalone/node_modules ./node_modules
COPY --link --from=builder --chown=1000:1000 /app/dist/standalone/server.js /app/dist/standalone/package.json ./
# Vinext's standalone output omits its React peer dependency.
COPY --link --from=builder --chown=1000:1000 /app/node_modules/react ./node_modules/react
COPY --link --from=builder --chown=1000:1000 /app/LICENSE ./
USER 1000:1000
EXPOSE 3000
VOLUME ["/app/data"]
HEALTHCHECK --interval=30s --timeout=5s --start-period=15s --retries=3 \
CMD ["node", "-e", "fetch('http://127.0.0.1:' + process.env.PORT + '/', { redirect: 'manual' }).then((response) => { if (response.status >= 400) process.exit(1) }).catch(() => process.exit(1))"]
CMD ["node", "server.js"]