-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
72 lines (63 loc) · 2.29 KB
/
Copy pathDockerfile
File metadata and controls
72 lines (63 loc) · 2.29 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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# syntax=docker/dockerfile:1
#
# Davion web, production image for Hetzner (or any vanilla Linux host).
#
# Multi-stage: deps -> build -> runner. The final image is ~150 MB and
# only contains the Nuxt server output plus a pinned Node 22 runtime.
# No pnpm, no source, no devDependencies in the runtime layer.
#
# Replaces the contractor-era multi-target Dockerfile (web + admin
# + postgres-client). We use Neon for postgres and the admin app
# isn't deployed here, so the runtime image is much leaner.
#
# Build:
# docker build -t davion-web .
#
# Run:
# docker run --rm -p 3000:3000 \
# -e DATABASE_URL=postgresql://... \
# -e IP_HASH_SALT=... \
# davion-web
#
# Or via docker compose (recommended): see docker-compose.yml at repo root.
FROM node:22-alpine AS base
WORKDIR /app
RUN corepack enable && corepack prepare pnpm@10.11.1 --activate
# --- Stage 1: install workspace deps ---
FROM base AS deps
COPY package.json pnpm-lock.yaml pnpm-workspace.yaml turbo.json ./
COPY apps/web/package.json ./apps/web/
COPY apps/admin/package.json ./apps/admin/
COPY packages/database/package.json ./packages/database/
RUN pnpm install --frozen-lockfile --prefer-offline
# --- Stage 2: build ---
FROM base AS build
COPY --from=deps /app/node_modules ./node_modules
COPY --from=deps /app/apps/web/node_modules ./apps/web/node_modules
COPY --from=deps /app/packages/database/node_modules ./packages/database/node_modules
# Source.
COPY pnpm-workspace.yaml turbo.json ./
COPY packages ./packages
COPY apps/web ./apps/web
# Build with the default node-server Nitro preset. NUXT_DEPLOY_TARGET is
# left unset so the nuxt.config.ts conditional skips NuxtHub (which only
# makes sense on Cloudflare).
ENV NODE_ENV=production
RUN pnpm --filter web build
# --- Stage 3: minimal runtime ---
FROM node:22-alpine AS runner
WORKDIR /app
RUN apk add --no-cache tini wget \
&& addgroup -g 1001 -S nodejs \
&& adduser -S nuxt -u 1001 -G nodejs
# Nitro's node-server preset produces a self-contained .output directory
# with its own node_modules. Copy just that.
COPY --from=build --chown=nuxt:nodejs /app/apps/web/.output ./
USER nuxt
ENV NODE_ENV=production
ENV NUXT_HOST=0.0.0.0
ENV NUXT_PORT=3000
EXPOSE 3000
# tini PID 1 so SIGTERM cleanly stops Node on `docker stop`.
ENTRYPOINT ["/sbin/tini", "--"]
CMD ["node", "server/index.mjs"]