-
Notifications
You must be signed in to change notification settings - Fork 35
Expand file tree
/
Copy pathDockerfile
More file actions
61 lines (44 loc) · 2.21 KB
/
Copy pathDockerfile
File metadata and controls
61 lines (44 loc) · 2.21 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
# ── Stage 1: Install dependencies ────────────────────────────────
FROM node:22-slim AS deps
WORKDIR /app
RUN corepack enable && corepack prepare pnpm@latest --activate
COPY package.json pnpm-lock.yaml ./
RUN pnpm install --frozen-lockfile --prod=false
# ── Stage 2: Build ───────────────────────────────────────────────
FROM node:22-slim AS builder
WORKDIR /app
RUN corepack enable && corepack prepare pnpm@latest --activate
COPY --from=deps /app/node_modules ./node_modules
COPY . .
ENV NEXT_TELEMETRY_DISABLED=1
RUN pnpm build
# Install better-sqlite3 with flat node_modules for easy copying
RUN mkdir -p /tmp/sqlite3 && cd /tmp/sqlite3 && npm init -y && npm install better-sqlite3
# ── Stage 3: Production runner ───────────────────────────────────
FROM node:22-slim AS runner
WORKDIR /app
ENV NODE_ENV=production
ENV NEXT_TELEMETRY_DISABLED=1
ENV PORT=3000
ENV HOSTNAME=0.0.0.0
# Reuse the built-in node user (uid 1000, gid 1000) from node:22-slim
# This matches clawhost sidecar securityContext and PVC ownership
# Copy standalone build
COPY --from=builder /app/.next/standalone ./
COPY --from=builder /app/.next/static ./.next/static
COPY --from=builder /app/public ./public
# Copy better-sqlite3 native binding (not traced by Next.js standalone)
COPY --from=builder /tmp/sqlite3/node_modules/better-sqlite3 ./node_modules/better-sqlite3
COPY --from=builder /tmp/sqlite3/node_modules/bindings ./node_modules/bindings
COPY --from=builder /tmp/sqlite3/node_modules/file-uri-to-path ./node_modules/file-uri-to-path
# Data directory for SQLite (mount as volume)
RUN mkdir -p /data && chown node:node /data
USER node
EXPOSE 3000
# All configuration via .env file or environment variables at runtime:
# DB_BACKEND=drizzle (drizzle | indexeddb)
# CHATCLAW_DATA_DIR=/data (SQLite data directory)
# AUTH_ENABLED=false (true | false)
# AUTH_SECRET=xxx (required when AUTH_ENABLED=true)
# MULTI_COMPANY=true (true | false)
CMD ["node", "server.js"]