Files
zpan/Dockerfile
T
saltbo a575e055fe fix(docker): resolve 404 on port 8222 and simplify build
Docker build ran vite with the cloudflare plugin, which put SPA output
under dist/client/, while entry-node.ts serves from ./dist — causing
404 on every request in the container.

- Add build:node (vite --mode node) so the SPA lands in dist/, and
  fold build:server into it as a single command
- Move better-sqlite3 to dependencies (Node runtime needs it; CF
  Workers build tree-shakes it out anyway)
- Collapse Dockerfile from 4 stages to 2: one npm ci with a BuildKit
  cache mount, then npm prune --omit=dev in place. Drops the
  duplicate install and the cross-stage better-sqlite3 copy hack.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-21 23:19:46 -04:00

38 lines
972 B
Docker

# syntax=docker/dockerfile:1.7
FROM node:24-slim AS builder
RUN apt-get update \
&& apt-get install -y --no-install-recommends python3 make g++ \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app
COPY package.json package-lock.json ./
RUN --mount=type=cache,target=/root/.npm npm ci
COPY . .
RUN npm run build:node \
&& npm prune --omit=dev
FROM node:24-slim
WORKDIR /app
RUN addgroup --system zpan && adduser --system --ingroup zpan zpan
COPY --from=builder /app/dist ./dist
COPY --from=builder /app/dist-server ./dist-server
COPY --from=builder /app/node_modules ./node_modules
COPY --from=builder /app/package.json ./package.json
COPY --from=builder /app/migrations ./migrations
COPY --from=builder /app/scripts/docker-entrypoint.sh /app/scripts/docker-entrypoint.sh
RUN mkdir -p /data && chown zpan:zpan /data
USER zpan
ENV NODE_ENV=production
ENV PORT=8222
EXPOSE 8222
ENTRYPOINT ["/app/scripts/docker-entrypoint.sh"]
CMD ["node", "dist-server/entry-node.js"]