diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..15f5646 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,11 @@ +.git +.github +.DS_Store + +docker-data + +README-DEV.md +changelog-beta.md + +*.log +*.tmp diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..3f7db6a --- /dev/null +++ b/Dockerfile @@ -0,0 +1,42 @@ +# syntax=docker/dockerfile:1.7 + +FROM --platform=$BUILDPLATFORM golang:1.22-alpine AS builder +WORKDIR /src + +RUN apk add --no-cache ca-certificates tzdata + +COPY go.mod go.sum ./ +RUN go mod download + +COPY . . + +ARG TARGETOS +ARG TARGETARCH +RUN CGO_ENABLED=0 GOOS=$TARGETOS GOARCH=$TARGETARCH \ + go build -trimpath -ldflags='-s -w' -o /out/xteve ./xteve.go + +FROM alpine:3.20 + +RUN apk add --no-cache ca-certificates tzdata \ + && addgroup -S xteve \ + && adduser -S -G xteve xteve \ + && mkdir -p /xteve/config \ + && chown -R xteve:xteve /xteve + +WORKDIR /xteve + +COPY --from=builder /out/xteve /usr/local/bin/xteve +COPY docker/entrypoint.sh /usr/local/bin/docker-entrypoint.sh + +USER xteve + +EXPOSE 34400/tcp +VOLUME ["/xteve/config"] + +ENV XTEVE_CONFIG=/xteve/config +ENV XTEVE_PORT=34400 + +HEALTHCHECK --interval=30s --timeout=5s --start-period=30s --retries=3 \ + CMD wget -qO- "http://127.0.0.1:${XTEVE_PORT}/lineup_status.json" > /dev/null || exit 1 + +ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"] diff --git a/README.md b/README.md index 51dec72..6120df4 100644 --- a/README.md +++ b/README.md @@ -48,6 +48,59 @@ Documentation for setup and configuration is [here](https://github.com/xteve-pro --- +## Project Analysis (UI + Operations) + +The core architecture is strong: a Go backend with websocket-driven UI updates, filesystem-based state, and very low runtime overhead. +The weakest points are mostly operational and UX-focused: + +* UI was historically utility-first and desktop-biased, with limited responsive behavior and visual hierarchy. +* Container usage was documented externally but there was no first-party Dockerfile/compose setup in this repository. +* Static web assets are generated into `src/webUI.go`, which works, but creates large diffs and a heavier edit/build cycle. + +### Recommended next technical improvements + +1. Replace generated `src/webUI.go` with Go `embed` for simpler static asset management and cleaner PR diffs. +2. Add CI checks (`go test ./...`, build on Linux/arm64/amd64, docker build smoke test). +3. Add a dedicated health endpoint (for example `/healthz`) to decouple health checks from HDHomeRun endpoints. +4. Add integration tests around websocket commands that mutate settings/files to reduce regression risk. + +--- + +## Container-First Run (Included In This Repo) + +### Build image +```bash +docker build -t xteve:local . +``` + +### Run with Docker Compose (bridge mode) +```bash +docker compose up -d +``` + +Compose file: `docker-compose.yml` +Persistent config volume: `./docker-data/config:/xteve/config` + +### Run with Docker Compose (host networking, Linux recommended for discovery) +```bash +docker compose -f docker-compose.host.yml up -d +``` + +Host networking improves LAN discovery behavior (SSDP/DLNA) for Plex/Emby in many setups. + +### Container environment variables + +* `XTEVE_CONFIG` (default: `/xteve/config`) +* `XTEVE_PORT` (default: `34400`) + +### Image details + +* Multi-stage build (Go builder + minimal Alpine runtime) +* Runs as non-root user (`xteve`) +* Built-in healthcheck against `http://127.0.0.1:${XTEVE_PORT}/lineup_status.json` + +--- + ## Downloads v2 | 64 Bit only #### 64 Bit Intel / AMD @@ -156,4 +209,3 @@ var GitHub = GitHubStruct{Branch: "master", User: "xteve-project", Repo: "xTeVe- ``` - diff --git a/docker-compose.host.yml b/docker-compose.host.yml new file mode 100644 index 0000000..fee6a00 --- /dev/null +++ b/docker-compose.host.yml @@ -0,0 +1,13 @@ +services: + xteve: + build: + context: . + dockerfile: Dockerfile + container_name: xteve + restart: unless-stopped + network_mode: host + environment: + XTEVE_CONFIG: /xteve/config + XTEVE_PORT: "34400" + volumes: + - ./docker-data/config:/xteve/config diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..4649620 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,15 @@ +services: + xteve: + build: + context: . + dockerfile: Dockerfile + container_name: xteve + restart: unless-stopped + environment: + XTEVE_CONFIG: /xteve/config + XTEVE_PORT: "34400" + ports: + - "34400:34400/tcp" + - "1900:1900/udp" + volumes: + - ./docker-data/config:/xteve/config diff --git a/docker/entrypoint.sh b/docker/entrypoint.sh new file mode 100755 index 0000000..b87d94c --- /dev/null +++ b/docker/entrypoint.sh @@ -0,0 +1,9 @@ +#!/bin/sh +set -eu + +CONFIG_DIR="${XTEVE_CONFIG:-/xteve/config}" +PORT="${XTEVE_PORT:-34400}" + +mkdir -p "${CONFIG_DIR}" + +exec /usr/local/bin/xteve -config "${CONFIG_DIR}" -port "${PORT}" "$@" diff --git a/html/configuration.html b/html/configuration.html index c8bea21..0f61abd 100644 --- a/html/configuration.html +++ b/html/configuration.html @@ -13,7 +13,7 @@ -
+