33 lines
1.4 KiB
Docker
33 lines
1.4 KiB
Docker
# The API server (Step 13.1). Build from the repository root:
|
|
# docker build -f deploy/server.Dockerfile .
|
|
# Runs the TypeScript sources with tsx, as `pnpm start` does; migrations run on
|
|
# every start (they are idempotent) before the server listens.
|
|
|
|
FROM node:24-slim AS build
|
|
RUN corepack enable
|
|
WORKDIR /repo
|
|
# Manifests first, so dependency layers are cached across source changes.
|
|
COPY package.json pnpm-lock.yaml pnpm-workspace.yaml ./
|
|
COPY apps/server/package.json apps/server/
|
|
COPY packages/content/package.json packages/content/
|
|
COPY packages/schema/package.json packages/schema/
|
|
COPY packages/sim/package.json packages/sim/
|
|
RUN pnpm install --frozen-lockfile --prod --filter "@deadhead/server..."
|
|
COPY tsconfig.base.json ./
|
|
COPY packages packages
|
|
COPY apps/server apps/server
|
|
# A self-contained copy of the server with its workspace packages and runtime
|
|
# dependencies (tsx is one: the server runs its TypeScript directly).
|
|
RUN pnpm --filter @deadhead/server deploy --legacy --prod /out
|
|
|
|
FROM node:24-slim
|
|
WORKDIR /app
|
|
COPY --from=build /out .
|
|
ENV NODE_ENV=production \
|
|
PORT=3000
|
|
EXPOSE 3000
|
|
USER node
|
|
HEALTHCHECK --interval=10s --timeout=5s --start-period=30s --retries=3 \
|
|
CMD node -e "fetch('http://127.0.0.1:' + process.env.PORT + '/api/health').then(r => process.exit(r.ok ? 0 : 1), () => process.exit(1))"
|
|
CMD ["sh", "-c", "node_modules/.bin/tsx src/db/migrate-cli.ts && exec node_modules/.bin/tsx src/main.ts"]
|