forked from dpawson905/homelabarr
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
45 lines (35 loc) · 1.84 KB
/
Dockerfile
File metadata and controls
45 lines (35 loc) · 1.84 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
# ── Stage 1: builder ──────────────────────────────────────────────────────────
FROM node:20-alpine AS builder
WORKDIR /app
# Install dependencies first (layer cache)
COPY package.json package-lock.json ./
RUN npm ci
# Copy source and build
COPY . .
# Pre-create a minimal DB so Next.js build workers don't race on SQLite init
RUN mkdir -p data && node -e "const D=require('better-sqlite3');const d=new D('./data/homelabarr.db');d.pragma('journal_mode=WAL');d.close();"
RUN npm run build
# ── Stage 2: runner ───────────────────────────────────────────────────────────
FROM node:20-alpine AS runner
WORKDIR /app
ENV NODE_ENV=production
ENV PORT=3575
ENV HOSTNAME=0.0.0.0
# Copy Next.js standalone server
COPY --from=builder /app/.next/standalone ./
# Copy static assets into the right place for the standalone server
COPY --from=builder /app/.next/static ./.next/static
# Copy public folder
COPY --from=builder /app/public ./public
# Copy drizzle migrations (needed by migrate.js at runtime)
COPY --from=builder /app/drizzle ./drizzle
# Copy migration + entrypoint scripts
COPY --from=builder /app/migrate.js ./migrate.js
COPY --from=builder /app/entrypoint.sh ./entrypoint.sh
# better-sqlite3 native binding: the standalone bundler doesn't copy .node files,
# so we copy the whole better-sqlite3 package from the builder's node_modules.
COPY --from=builder /app/node_modules/better-sqlite3 ./node_modules/better-sqlite3
COPY --from=builder /app/node_modules/bindings ./node_modules/bindings
COPY --from=builder /app/node_modules/file-uri-to-path ./node_modules/file-uri-to-path
EXPOSE 3575
ENTRYPOINT ["/bin/sh", "/app/entrypoint.sh"]