- Dockerfile: npm ci (uses package-lock for reproducible installs) - CMD now: migrate → seed (idempotent) → start. Gated by SEED_ON_BOOT. - docker-compose: name: helix, healthcheck on /, OAuth env defaults to empty so `docker compose up` works without a .env (public pages render; sign-in fails until OAuth is configured). - README: explicit "Run it locally — two ways" section. Docker first (production-like), native Node second. Documents port-conflict workaround and Gitea OAuth setup. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
45 lines
1.3 KiB
Docker
45 lines
1.3 KiB
Docker
# syntax=docker/dockerfile:1.7
|
|
|
|
# ---- build stage ----
|
|
FROM node:20-bookworm-slim AS build
|
|
WORKDIR /app
|
|
|
|
# better-sqlite3 needs build tools when no prebuilt is available
|
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
|
python3 make g++ \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
COPY package.json package-lock.json ./
|
|
RUN npm ci --include=dev
|
|
|
|
COPY . .
|
|
RUN npm run build
|
|
RUN npm prune --omit=dev
|
|
|
|
# ---- runtime stage ----
|
|
FROM node:20-bookworm-slim AS runtime
|
|
WORKDIR /app
|
|
|
|
ENV NODE_ENV=production \
|
|
PORT=3000 \
|
|
DATABASE_URL=/data/helix.db
|
|
|
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
|
ca-certificates \
|
|
&& rm -rf /var/lib/apt/lists/* \
|
|
&& mkdir -p /data \
|
|
&& chown node:node /data
|
|
|
|
COPY --from=build --chown=node:node /app/build ./build
|
|
COPY --from=build --chown=node:node /app/node_modules ./node_modules
|
|
COPY --from=build --chown=node:node /app/package.json ./package.json
|
|
COPY --from=build --chown=node:node /app/drizzle ./drizzle
|
|
COPY --from=build --chown=node:node /app/scripts ./scripts
|
|
|
|
USER node
|
|
EXPOSE 3000
|
|
|
|
# Run migrations + seed (idempotent INSERT OR IGNORE) then start the server.
|
|
# Set SEED_ON_BOOT=false in production once you've added real content.
|
|
CMD ["sh", "-c", "node scripts/migrate.js && { [ \"$SEED_ON_BOOT\" = \"false\" ] || node scripts/seed.js; } && node build"]
|