-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
54 lines (43 loc) · 1.94 KB
/
Copy pathDockerfile
File metadata and controls
54 lines (43 loc) · 1.94 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
# ── Stage 1: install all dependencies (needed for build) ─────────────────────
FROM node:22-alpine AS deps
ENV PNPM_HOME="/pnpm"
ENV PATH="$PNPM_HOME:$PATH"
RUN corepack enable
WORKDIR /app
COPY package.json pnpm-lock.yaml ./
RUN pnpm install --frozen-lockfile
# ── Stage 2: build the app ────────────────────────────────────────────────────
FROM node:22-alpine AS builder
ENV PNPM_HOME="/pnpm"
ENV PATH="$PNPM_HOME:$PATH"
RUN corepack enable
WORKDIR /app
COPY --from=deps /app/node_modules ./node_modules
COPY . .
# Regenerate Prisma client for the current schema.
# DATABASE_URL is required by prisma.config.ts at config-load time even
# though generate never connects to the database.
RUN DATABASE_URL=postgresql://build-placeholder node_modules/.bin/prisma generate
# Produces the Nitro server bundle in .output/
RUN DATABASE_URL=postgresql://build-placeholder pnpm build
# ── Stage 3: production image ─────────────────────────────────────────────────
FROM node:22-alpine AS runner
ENV PNPM_HOME="/pnpm"
ENV PATH="$PNPM_HOME:$PATH"
RUN corepack enable
WORKDIR /app
ENV NODE_ENV=production
ENV PORT=3002
ENV HOST=0.0.0.0
# Self-contained Nitro server bundle (app doesn't need node_modules at runtime)
COPY --from=builder /app/.output ./.output
# Install production deps so the init container can run `prisma migrate deploy`.
# These are not used by the app itself (Nitro bundles everything), but prisma's
# migration engine and CLI live here.
COPY package.json pnpm-lock.yaml ./
RUN pnpm install --prod --frozen-lockfile --ignore-scripts
# Prisma schema, migrations, and config (required by `prisma migrate deploy`)
COPY prisma ./prisma
COPY prisma.config.ts ./
EXPOSE 3002
CMD ["node", ".output/server/index.mjs"]