Files
jason5ng32andClaude Opus 5.5 c29e48687b Refactor(layout): split backend-only code out of common/, group frontend utils
common/ had become the backend's library: 30 of its 41 modules were
imported by nothing in the frontend, so the name no longer said what
belonged there. It now holds only what the frontend or the build imports
too; backend-only code moved to server/, flat except for datasets/ (the
dataset engine and its readers). The *-db/ dataset directories stay in
common/: self-hosting docs and Docker volumes mount those paths.

frontend/utils/ keeps its app-wide modules at the root and gains ip/
(IP / ASN shaping and validation), report/ (the report pipeline) and
features/ (the pure layer of a single feature). Paths only — no logic
changes. The Dockerfile copies server/, and the AGENTS.md files say where
a new module goes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-05 13:10:02 +08:00

39 lines
1.6 KiB
Docker

# Build stage
FROM node:24-alpine AS build-stage
# corepack ships with the node image and provisions pnpm at the version pinned
# by the `packageManager` field in package.json — no global npm install needed.
RUN corepack enable
# node-gyp toolchain for native deps without musl prebuilds (node-pty, pulled
# in by the code-inspector dev plugin) — build stage only, the production
# stage below stays toolchain-free.
RUN apk add --no-cache python3 make g++
WORKDIR /app
# Copy the manifests first so this layer (and the install below) stays cached
# unless dependencies actually change. pnpm-workspace.yaml carries the
# allowBuilds approvals; pnpm-lock.yaml is required by --frozen-lockfile.
COPY package.json pnpm-lock.yaml pnpm-workspace.yaml ./
RUN pnpm install --frozen-lockfile
COPY . .
RUN pnpm run build
# Production stage
FROM node:24-alpine AS production-stage
WORKDIR /app
# node_modules is copied as-is from the build stage (pnpm's symlink farm into
# .pnpm is preserved within /app), so the runtime needs no install step.
COPY --from=build-stage /app/node_modules ./node_modules
COPY --from=build-stage /app/package.json ./
COPY --from=build-stage /app/dist ./dist
COPY --from=build-stage /app/backend-server.js ./
COPY --from=build-stage /app/frontend-server.js ./
# npm start boots the backend with `--import ./sentry-instrument.js`
COPY --from=build-stage /app/sentry-instrument.js ./
COPY --from=build-stage /app/api ./api
COPY --from=build-stage /app/server ./server
COPY --from=build-stage /app/common ./common
EXPOSE 18966
# Start application
CMD ["npm", "start"]