-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
63 lines (51 loc) · 2.13 KB
/
Copy pathDockerfile
File metadata and controls
63 lines (51 loc) · 2.13 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
51
52
53
54
55
56
57
58
59
60
61
62
63
# syntax=docker/dockerfile:1.7
# Keep all installs and builds in one stage. BuildKit otherwise executes the
# independent server, Web portal, and Live Share stages in parallel, which can
# make small hosts spend hours swapping under three concurrent Node workloads.
FROM node:24.18.0-bookworm AS builder
ARG NPM_REGISTRY=https://registry.npmjs.org
ENV MAKEFLAGS="-j1" \
NPM_CONFIG_REGISTRY=${NPM_REGISTRY} \
NPM_CONFIG_AUDIT=false \
NPM_CONFIG_FUND=false
# Install each dependency tree before copying sources so lockfile layers remain
# cacheable. The shared BuildKit cache also avoids downloading common packages
# again for the Web portal and Live Share application.
WORKDIR /build/server
COPY package.json package-lock.json ./
RUN --mount=type=cache,id=openlogtool-npm-cache,target=/root/.npm,sharing=locked \
npm ci --prefer-offline
WORKDIR /build/web
COPY web/package.json web/package-lock.json ./
RUN --mount=type=cache,id=openlogtool-npm-cache,target=/root/.npm,sharing=locked \
npm ci --prefer-offline
WORKDIR /build/live
COPY live/package.json live/package-lock.json ./
RUN --mount=type=cache,id=openlogtool-npm-cache,target=/root/.npm,sharing=locked \
npm ci --prefer-offline
# Build sequentially to keep peak memory predictable on low-resource servers.
WORKDIR /build/server
COPY tsconfig.json ./
COPY src/ ./src/
RUN npm run build && npm prune --omit=dev
WORKDIR /build/web
COPY web/ ./
RUN npm run build
WORKDIR /build/live
COPY live/ ./
RUN npm run build
FROM node:24.18.0-bookworm-slim
WORKDIR /app
COPY --from=builder /build/server/dist ./dist
COPY --from=builder /build/server/node_modules ./node_modules
COPY --from=builder /build/server/package.json ./
COPY --from=builder /build/web/dist ./web/dist
COPY --from=builder /build/live/dist ./live/dist
RUN mkdir -p /app/data && chown node:node /app/data
ENV PORT=3000
ENV NODE_ENV=production
EXPOSE 3000
USER node
HEALTHCHECK --interval=30s --timeout=5s --start-period=20s --retries=5 \
CMD ["node", "-e", "fetch('http://127.0.0.1:3000/api/v1/server-info').then((response) => { if (!response.ok) process.exit(1); }).catch(() => process.exit(1))"]
CMD ["node", "dist/index.js"]