Repository navigation
Expand file tree
/
Copy pathDockerfile.web
More file actions
37 lines (34 loc) · 1.51 KB
/
Copy pathDockerfile.web
File metadata and controls
37 lines (34 loc) · 1.51 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
# syntax=docker/dockerfile:1
# Next.js player app and admin prototype (repository root, src/app). Build from the repository root:
# docker build -f Dockerfile.web -t openquest-web .
# Needs `output: "standalone"` in next.config.* because the runtime stage only copies .next/standalone.
ARG NODE_VERSION=22
ARG PNPM_VERSION=10.34.5
FROM node:${NODE_VERSION}-alpine AS build
ARG PNPM_VERSION
RUN npm install -g pnpm@${PNPM_VERSION} && npm cache clean --force
WORKDIR /repo
COPY . .
ENV NEXT_TELEMETRY_DISABLED=1
RUN --mount=type=cache,id=pnpm-store,target=/root/.local/share/pnpm/store \
pnpm install --frozen-lockfile --filter "openquest..."
RUN pnpm build \
&& if [ ! -f .next/standalone/server.js ]; then echo 'no .next/standalone: set output: "standalone" in next.config' >&2; exit 1; fi \
&& mkdir -p public
FROM node:${NODE_VERSION}-alpine AS runtime
ENV NODE_ENV=production \
NEXT_TELEMETRY_DISABLED=1 \
HOSTNAME=0.0.0.0 \
PORT=3000 \
TREE_DATA_PATH=/app/data/trees.json
WORKDIR /app
COPY --from=build /repo/.next/standalone ./
COPY --from=build /repo/.next/static ./.next/static
COPY --from=build /repo/public ./public
# Tree data for /api/tree-search (Jev search), see next.config.ts.
COPY --from=build /repo/packages/tree-search/data/trees.json ./data/trees.json
USER node
EXPOSE 3000
HEALTHCHECK --interval=15s --timeout=5s --start-period=20s --retries=5 \
CMD node -e "fetch('http://127.0.0.1:'+(process.env.PORT||3000)+'/').then(r=>process.exit(r.ok?0:1),()=>process.exit(1))"
CMD ["node", "server.js"]