dragonflight/services/framecache/Dockerfile

32 lines
1.2 KiB
Text
Raw Normal View History

# ── Build stage ─────────────────────────────────────────────────────
FROM debian:bookworm AS builder
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential cmake libmicrohttpd-dev \
&& rm -rf /var/lib/apt/lists/*
COPY . /src
RUN cmake -S /src -B /build \
-DCMAKE_BUILD_TYPE=Release \
&& cmake --build /build -j"$(nproc)"
# ── Runtime stage ────────────────────────────────────────────────────
FROM debian:bookworm-slim
RUN apt-get update && apt-get install -y --no-install-recommends \
libmicrohttpd12 \
&& rm -rf /var/lib/apt/lists/*
feat(framecache): phase 4 — capture-manager reads from framecache - services/framecache/client/fc_pipe.c: new slot→stdout pipe adapter - Opens framecache slot as consumer (independent cursor per instance) - Streams raw UYVY422 frames to stdout continuously - SIGPIPE detection via write() return — exits cleanly on ffmpeg exit - SIGTERM/SIGINT clean stop from capture-manager - Periodic stats to stderr (every 300 frames) - Exit codes: 0=clean, 1=slot not found, 2=EPIPE - services/framecache/CMakeLists.txt: add fc_pipe target + install - services/framecache/Dockerfile: copy fc_pipe to runtime image - services/capture/Dockerfile: - New fc-pipe-builder stage (builds fc_pipe from framecache sources) - Copies fc_pipe binary to /usr/local/bin/fc_pipe in runtime image - services/capture/src/capture-manager.js: - _buildInputArgs: new framecache path for deltacast + sdi/blackmagic when FC_SLOT_ID env is set (injected by node-agent from bridge fmt JSON) - Spawns fc_pipe <slot_id> as child process - Uses pipe:0 as ffmpeg rawvideo input 0 - Audio FIFO (unchanged) as ffmpeg input 1 - Falls back to legacy FIFO path when FC_SLOT_ID unset - audioMap: covers blackmagic via framecache (input 1 for audio FIFO) - isInterlacedSource: covers blackmagic interlaced signals - hiresStdio: pipe stdin when bridgeProcess set (fc_pipe stdout→ffmpeg) - Non-growing spawn: pipes fc_pipe.stdout → ffmpeg.stdin - Growing orchestrator spawn: pipes fc_pipe.stdout → bash.stdin - sdiHlsDir: covers blackmagic source type - Session state stores _fcPipeProcess for clean stop - stop(): sends SIGTERM to fc_pipe after ffmpeg SIGINT
2026-06-03 11:32:40 -04:00
COPY --from=builder /build/framecache /usr/local/bin/framecache
feat(framecache): phase 5 — network ingest (RTMP/SRT) via framecache - services/framecache/src/net_ingest.c: new network ingest process - Spawns ffmpeg to decode SRT/RTMP → raw UYVY422 stdout - Reads decoded frames and writes into framecache slot via shm - Registers slot with framecache HTTP API on startup - Deregisters slot on clean exit (SIGTERM) - Reconnect loop for listener mode (stays alive between sessions) - --url, --slot-id, --fc-url, --width, --height, --fps-num/den, --source-type, --listen, --listen-port, --stream-key args - Emits format JSON to stderr on first frame - services/framecache/CMakeLists.txt: add net_ingest target - services/framecache/Dockerfile: copy net_ingest to runtime image - services/node-agent/index.js: - startNetIngest() / stopNetIngest(): lifecycle management per recorder - Spawns net_ingest before sidecar start for srt/rtmp sourceTypes - Injects FC_SLOT_ID=net-<containerId> into sidecar env - Sets IpcMode=host for network sidecars using framecache - Maps temp id → real containerId after container create - stopNetIngest() called on sidecar stop - NET_INGEST_BIN env var (default: docker exec framecache net_ingest) - services/capture/src/capture-manager.js: - _buildInputArgs srt/rtmp: framecache path when FC_SLOT_ID set (spawns fc_pipe, uses pipe:0 rawvideo input — same as SDI path) - Falls back to direct URL when FC_SLOT_ID not set (legacy path) - audioMap: network via framecache uses '0:a:0?' (video-only fc_pipe, no audio FIFO — audio-in-shm is roadmap) - HLS tee: sdiHlsDir covers network-via-framecache; legacy tee gated on !FC_SLOT_ID to avoid duplicate HLS outputs - fc_pipe piped to ffmpeg stdin for network framecache path - docker-compose.worker.yml: FC_URL + NET_INGEST_BIN in node-agent env
2026-06-03 11:37:17 -04:00
COPY --from=builder /build/net_ingest /usr/local/bin/net_ingest
# /dev/shm/framecache is created at runtime (tmpfs)
RUN mkdir -p /dev/shm/framecache
EXPOSE 7435
HEALTHCHECK --interval=10s --timeout=3s --start-period=5s \
CMD wget -qO- http://localhost:7435/health || exit 1
CMD ["/usr/local/bin/framecache"]