BetterFrame/deploy/docker/Dockerfile.server
Mitchell R 90a8f256d5
fix(docker): remove COPY .git — Coolify excludes it from build context
Coolify doesn't include .git in Docker build context, causing build
failure. Revert to ARG-based version stamping: compose passes
BF_SERVER_VERSION from Coolify's SOURCE_COMMIT/COOLIFY_GIT_COMMIT
env vars as a build arg, Dockerfile writes it to .bf-version. Removed
git from builder apt install (no longer needed).
2026-05-22 19:30:18 +02:00

64 lines
2.1 KiB
Docker

# BetterFrame server image — Node 24 + native deps for argon2/sqlite.
# Trixie base (Debian 13, latest stable) — matches the host distro we
# recommend in deploy/README.md.
FROM node:24-trixie-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:24-trixie-slim
# Version baked at build time. Coolify doesn't include .git in build context
# so we can't derive from git inside Docker. Instead, compose passes it as a
# build arg from SOURCE_COMMIT / COOLIFY_GIT_COMMIT env vars that Coolify
# DOES inject into the build environment.
ARG BF_SERVER_VERSION=dev
# 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 wget \
&& 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
# Bake version into a file readable by version.ts at runtime.
RUN echo "$BF_SERVER_VERSION" > /app/server/.bf-version
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"]