BetterFrame/deploy/docker/Dockerfile.server
Mitchell R c8fa5d95a2
fix(deploy): bake configs into images — no host bind mounts
Coolify deployments don't always carry the full source tree on disk
at the bind-mount source path. Mounting a missing file lets Docker
auto-create a directory at the target, which then fails to mount over
the file the image expects.

Fix: bake config files into the images themselves:
- Dockerfile.server COPYs deploy/docker/sec-config.yaml → /app/server/.
  Env vars (BF_*) still override at runtime per env-overrides.ts.
- New Dockerfile.angie wraps nginx:alpine + baked betterframe.docker.conf.
- Dockerfile.nodered COPYs nodered-settings.js to /usr/src/bf-settings.js
  (outside the /data volume) and uses --settings to point at it.

Compose drops the three bind mounts; volumes are now strictly
runtime state (DB + secrets, Node-RED flows). Users who want a
different sec-config still get full control via env overrides or
Coolify's Storage UI.
2026-05-18 12:18:46 +02:00

53 lines
1.6 KiB
Docker

# BetterFrame server image — Node 23 + native deps for argon2/sqlite
FROM node:23-bookworm-slim AS builder
WORKDIR /app
# Build deps for argon2 + bsb-plugin-cli
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential python3 \
&& rm -rf /var/lib/apt/lists/*
COPY package.json package-lock.json ./
COPY server/package.json ./server/
COPY tsconfig.base.json ./
RUN npm ci && npm rebuild argon2
COPY server ./server
# Run BSB build — extracts schemas + compiles TS + generates plugin manifests
WORKDIR /app/server
RUN npm run build
# ---- Runtime image ----
FROM node:23-bookworm-slim
# ffmpeg for camera snapshot capture (optional but needed for /admin/entities/:id/snapshot)
RUN apt-get update && apt-get install -y --no-install-recommends \
ca-certificates ffmpeg \
&& rm -rf /var/lib/apt/lists/*
RUN useradd -m -d /var/lib/betterframe -s /bin/false betterframe
WORKDIR /app
COPY --from=builder /app/node_modules ./node_modules
COPY --from=builder /app/server ./server
COPY --from=builder /app/tsconfig.base.json ./
COPY --from=builder /app/package.json ./
# Default sec-config baked into image. BF_* env vars in compose override at
# runtime (see shared/env-overrides.ts). No host bind mount needed.
COPY deploy/docker/sec-config.yaml /app/server/sec-config.yaml
RUN mkdir -p /var/lib/betterframe && chown betterframe:betterframe /var/lib/betterframe
VOLUME /var/lib/betterframe
EXPOSE 18080 18081 18082
USER betterframe
WORKDIR /app/server
ENV NODE_OPTIONS=--import=tsx
CMD ["node", "--import", "tsx", "/app/node_modules/@bsb/base/lib/scripts/bsb-plugin-cli.js", "start"]