datarhei-dragonfork-core/deploy/truenas/core/Dockerfile

111 lines
4.3 KiB
Text
Raw Normal View History

# Dragon Fork datarhei Core image (M2 + WebRTC egress).
#
# Builds the real root Core binary — the one that replaces the M1 PoC
# in production. FFmpeg is baked in so restream processes can run the
# RTP output legs emitted by the WebRTC subsystem.
#
# Two-stage:
# 1. builder: compile a static Go binary (CGO off — no dynamic libs)
# 2. ui-builder: clone wilddragon-restreamer-ui, apply its overlay on
# top of upstream datarhei/restreamer-ui v1.14.0, yarn build.
# See https://forge.wilddragon.net/zgaetano/wilddragon-restreamer-ui
# 3. runtime: alpine with ffmpeg for the subprocess path
#
# Usage via compose:
# docker compose -f deploy/truenas/core/docker-compose.yml up -d --build
#
# The compose file drives configuration via CORE_* env vars — see
# README.md in this directory.
# ---- builder ----
# go.mod requires go 1.24; pinning the image keeps Docker's toolchain
# download off the hot path and makes the build reproducible.
FROM golang:1.24-alpine3.20 AS builder
WORKDIR /src
RUN apk add --no-cache git make
COPY . .
ENV CGO_ENABLED=0 GOOS=linux GOARCH=amd64
RUN make release && make import && make ffmigrate
# ---- ui-builder ----
# Clones wilddragon-restreamer-ui (the Wild Dragon UI fork) which
# provides apply-overlay.sh and all overlay files (branding, WebRTC
# WHEP controls). Then clones upstream restreamer-ui at the pinned
# tag, applies the overlay, and runs yarn build.
#
# WD_UI_REF: branch or tag in wilddragon-restreamer-ui to build from.
# RESTREAMER_UI_REF: upstream datarhei/restreamer-ui tag to base on.
FROM node:21-alpine3.20 AS ui-builder
ARG WD_UI_REF=main
ARG RESTREAMER_UI_REF=v1.14.0
RUN apk add --no-cache git
feat(ui): Wild Dragon reskin overlay on the Restreamer UI Layers Wild Dragon branding on top of upstream restreamer-ui v1.14.0 without forking the whole repo — keeps upstream UI updates flowing in when we bump RESTREAMER_UI_REF. Overlay (deploy/truenas/core/ui-overlay/): public/index.html Wild Dragon title, theme color #0d0e12 public/manifest.json PWA name/short_name/colors public/favicon.ico multi-res ICO (16/32/64) generated from a 'WD' monogram in orange #ff6633 on dark public/logo192.png Apple touch icon public/logo512.png PWA install icon src/misc/Logo/images/ rs-logo.svg (square mark, used in the Header) and logo.svg (wordmark, used in the Footer) — both Wild-Dragon-themed src/misc/Logo/{index,rsLogo}.js link the logos to forge.wilddragon.net instead of datarhei.com apply-overlay.sh runs in the Docker ui-builder stage just after the upstream git clone and just before yarn install. Two phases: 1. rsync the overlay's public/ and src/ on top of the cloned upstream tree 2. Targeted in-place patches for one-line UI strings (header title, two welcome captions). Each patch is anchored to a unique surrounding context and the script fails loudly if the anchor isn't present — so a future upstream rename surfaces immediately rather than silently shipping un-rebranded UI. Image size: ~+50KB (the overlay assets), no measurable build-time delta. PWA installs and OS bookmarks now show Wild Dragon. The remaining 'Restreamer'/'datarhei' references in views/Welcome.js, views/Login.js, views/Settings.js, etc. are deeper-page strings that aren't worth a one-off overlay; they'll go away when we fork the UI repo properly for the WebRTC tab milestone. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-03 09:14:41 -04:00
# Wild Dragon UI fork: overlay files + apply-overlay.sh
RUN git clone --depth=1 --branch ${WD_UI_REF} \
https://forge.wilddragon.net/zgaetano/wilddragon-restreamer-ui.git /wd-ui
# Upstream React SPA at the pinned version
RUN git clone --depth=1 --branch ${RESTREAMER_UI_REF} \
https://github.com/datarhei/restreamer-ui.git /ui
WORKDIR /ui
RUN yarn install --frozen-lockfile --network-timeout 600000
feat(ui): Wild Dragon reskin overlay on the Restreamer UI Layers Wild Dragon branding on top of upstream restreamer-ui v1.14.0 without forking the whole repo — keeps upstream UI updates flowing in when we bump RESTREAMER_UI_REF. Overlay (deploy/truenas/core/ui-overlay/): public/index.html Wild Dragon title, theme color #0d0e12 public/manifest.json PWA name/short_name/colors public/favicon.ico multi-res ICO (16/32/64) generated from a 'WD' monogram in orange #ff6633 on dark public/logo192.png Apple touch icon public/logo512.png PWA install icon src/misc/Logo/images/ rs-logo.svg (square mark, used in the Header) and logo.svg (wordmark, used in the Footer) — both Wild-Dragon-themed src/misc/Logo/{index,rsLogo}.js link the logos to forge.wilddragon.net instead of datarhei.com apply-overlay.sh runs in the Docker ui-builder stage just after the upstream git clone and just before yarn install. Two phases: 1. rsync the overlay's public/ and src/ on top of the cloned upstream tree 2. Targeted in-place patches for one-line UI strings (header title, two welcome captions). Each patch is anchored to a unique surrounding context and the script fails loudly if the anchor isn't present — so a future upstream rename surfaces immediately rather than silently shipping un-rebranded UI. Image size: ~+50KB (the overlay assets), no measurable build-time delta. PWA installs and OS bookmarks now show Wild Dragon. The remaining 'Restreamer'/'datarhei' references in views/Welcome.js, views/Login.js, views/Settings.js, etc. are deeper-page strings that aren't worth a one-off overlay; they'll go away when we fork the UI repo properly for the WebRTC tab milestone. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-03 09:14:41 -04:00
# Apply Wild Dragon branding + WebRTC controls.
# chmod is required because git may clone the script without +x.
RUN chmod +x /wd-ui/apply-overlay.sh && \
OVERLAY=/wd-ui/overlay UI=/ui /wd-ui/apply-overlay.sh
feat(ui): Wild Dragon reskin overlay on the Restreamer UI Layers Wild Dragon branding on top of upstream restreamer-ui v1.14.0 without forking the whole repo — keeps upstream UI updates flowing in when we bump RESTREAMER_UI_REF. Overlay (deploy/truenas/core/ui-overlay/): public/index.html Wild Dragon title, theme color #0d0e12 public/manifest.json PWA name/short_name/colors public/favicon.ico multi-res ICO (16/32/64) generated from a 'WD' monogram in orange #ff6633 on dark public/logo192.png Apple touch icon public/logo512.png PWA install icon src/misc/Logo/images/ rs-logo.svg (square mark, used in the Header) and logo.svg (wordmark, used in the Footer) — both Wild-Dragon-themed src/misc/Logo/{index,rsLogo}.js link the logos to forge.wilddragon.net instead of datarhei.com apply-overlay.sh runs in the Docker ui-builder stage just after the upstream git clone and just before yarn install. Two phases: 1. rsync the overlay's public/ and src/ on top of the cloned upstream tree 2. Targeted in-place patches for one-line UI strings (header title, two welcome captions). Each patch is anchored to a unique surrounding context and the script fails loudly if the anchor isn't present — so a future upstream rename surfaces immediately rather than silently shipping un-rebranded UI. Image size: ~+50KB (the overlay assets), no measurable build-time delta. PWA installs and OS bookmarks now show Wild Dragon. The remaining 'Restreamer'/'datarhei' references in views/Welcome.js, views/Login.js, views/Settings.js, etc. are deeper-page strings that aren't worth a one-off overlay; they'll go away when we fork the UI repo properly for the WebRTC tab milestone. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-03 09:14:41 -04:00
RUN PUBLIC_URL="./" GENERATE_SOURCEMAP=false yarn build
# ---- runtime ----
# Alpine with ffmpeg (Core shells out to it for every restream process).
# Scratch isn't an option here because the process manager needs ffmpeg
# on PATH.
FROM alpine:3.20 AS runtime
RUN apk add --no-cache ffmpeg tini ca-certificates
# make release's `-o core` lands the binary inside the core/ Go
# package directory (Go cannot overwrite a directory with a file, so
# it places the output file _inside_ it). The `import` and `ffmigrate`
# Makefile targets cd into app/<name> and write the binary back up to
# the repo root with a relative path, so those end up at /src/import
# and /src/ffmigrate.
COPY --from=builder /src/core/core /core/bin/core
COPY --from=builder /src/import /core/bin/import
COPY --from=builder /src/ffmigrate /core/bin/ffmigrate
COPY --from=builder /src/mime.types /core/mime.types
COPY --from=builder /src/run.sh /core/bin/run.sh
# Static content for /core/data, seeded on first boot by seed-data.sh.
# Stacking order:
# 1. Restreamer UI bundle (the React SPA — gives us index.html)
# 2. Dragon Fork extras (whep-player.html, etc.) — won't overwrite
# the UI's index.html (seed-data is no-clobber).
#
# The result: GET / serves the Wild Dragon dashboard, and
# /whep-player.html serves the standalone WHEP smoke player.
COPY --from=ui-builder /ui/build/ /core/static/
COPY --from=builder /src/deploy/truenas/core/static/ /core/static/
COPY --from=builder /src/deploy/truenas/core/seed-data.sh /core/bin/seed-data.sh
RUN chmod +x /core/bin/seed-data.sh && mkdir -p /core/config /core/data
ENV CORE_CONFIGFILE=/core/config/config.json
ENV CORE_STORAGE_DISK_DIR=/core/data
ENV CORE_DB_DIR=/core/config
VOLUME ["/core/data", "/core/config"]
EXPOSE 8080/tcp
# Seed /core/data on first boot, then exec the upstream run.sh which
# handles imports, ffmpeg migrations, and the core binary. tini reaps
# child PIDs and forwards signals.
ENTRYPOINT ["/sbin/tini", "--", "/bin/sh", "-c", "/core/bin/seed-data.sh && exec /core/bin/run.sh"]
WORKDIR /core