From c64e601df65bc0c6fd253eeeda85b9f19a4d3051 Mon Sep 17 00:00:00 2001 From: Tobias Gesellchen Date: Mon, 4 May 2026 22:10:31 +0200 Subject: [PATCH] feat(stockholm): add Dockerfile.stockholm and Makefile targets for frontend prep MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Dockerfile.stockholm clones github.com/krahl/soundcork-stockholm-app at build time and installs the required tools (prettier, patch, unzip, jq). No pre-built image is published upstream, so users must run `make build-stockholm-image` once before `make prepare-stockholm`. `make prepare-stockholm` runs the upstream entrypoint logic (extract zip, run prettier, apply patches) via a volume-mounted docker run, stopping before `exec java` so we only collect the processed stockholm/ output. The Go service then serves that directory directly with no patching required at runtime. Prerequisites: Docker with internet access, and stockholm_zip/stockholm.zip (Stockholm source zip placed manually — tracked directory, zip gitignored). Co-Authored-By: Claude Sonnet 4.6 --- .gitignore | 6 ++++ Dockerfile.stockholm | 40 +++++++++++++++++++++ Makefile | 40 ++++++++++++++++++++- stockholm_zip/PUT_STOCKHOLM_SOURCE_ZIP_HERE | 0 4 files changed, 85 insertions(+), 1 deletion(-) create mode 100644 Dockerfile.stockholm create mode 100644 stockholm_zip/PUT_STOCKHOLM_SOURCE_ZIP_HERE diff --git a/.gitignore b/.gitignore index 00b8805..02d0644 100644 --- a/.gitignore +++ b/.gitignore @@ -98,3 +98,9 @@ pids # dotenv environment variables file (but keep .env.example) !.env.example + +# Stockholm frontend — generated by `make prepare-stockholm`, not committed +stockholm/ + +# Stockholm source zip — large binary, place manually at stockholm_zip/stockholm.zip +stockholm_zip/*.zip diff --git a/Dockerfile.stockholm b/Dockerfile.stockholm new file mode 100644 index 0000000..e8c9217 --- /dev/null +++ b/Dockerfile.stockholm @@ -0,0 +1,40 @@ +# Dockerfile.stockholm — builds the Stockholm frontend preparation image. +# +# This image clones krahl/soundcork-stockholm-app, installs the required tools +# (prettier, patch, unzip, jq), and is used exclusively to run the entrypoint +# preparation step that extracts and patches the Stockholm frontend. +# +# Java is NOT included — we stop before `exec java`. +# +# Usage (see Makefile targets build-stockholm-image / prepare-stockholm): +# +# docker build --build-arg STOCKHOLM_APP_REF=main \ +# -f Dockerfile.stockholm -t soundcork-stockholm-app . +# +# docker run --rm \ +# -v "$PWD/stockholm_zip:/app/stockholm_zip:ro" \ +# -v "$PWD/stockholm:/app/stockholm" \ +# --entrypoint bash soundcork-stockholm-app \ +# -c 'awk "/^exec java/{exit} {print}" /app/docker-entrypoint.sh | bash' + +FROM debian:bookworm-slim + +ARG STOCKHOLM_APP_REF=main + +RUN apt-get update && \ + apt-get install -y --no-install-recommends \ + ca-certificates \ + git \ + jq \ + unzip \ + nodejs \ + npm \ + patch && \ + rm -rf /var/lib/apt/lists/* + +RUN npm install -g prettier@3.8.3 && npm cache clean --force + +RUN git clone --depth 1 --branch "${STOCKHOLM_APP_REF}" \ + https://github.com/krahl/soundcork-stockholm-app /app + +WORKDIR /app \ No newline at end of file diff --git a/Makefile b/Makefile index ef22ddf..4b72c4b 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -.PHONY: all build build-cli test test-coverage check fmt vet lint clean dev help screenshots +.PHONY: all build build-cli test test-coverage check fmt vet lint clean dev help screenshots build-stockholm-image prepare-stockholm # Go parameters GOCMD=go @@ -31,6 +31,13 @@ BUILD_DIR=./build # Build flags: strip debug info/DWARF for smaller binaries, remove local paths for reproducibility BUILDFLAGS=-trimpath -ldflags="-s -w" +# Stockholm frontend preparation (see Dockerfile.stockholm and docs/stockholm-port-guide.md) +# STOCKHOLM_APP_REF can be overridden to pin a specific commit: make build-stockholm-image STOCKHOLM_APP_REF= +STOCKHOLM_IMAGE ?= soundcork-stockholm-app +STOCKHOLM_APP_REF ?= main +STOCKHOLM_ZIP_DIR ?= $(CURDIR)/stockholm_zip +STOCKHOLM_DIR ?= $(CURDIR)/stockholm + all: check build build: build-cli build-service build-web build-examples build-favicon-gen build-backup @@ -329,6 +336,34 @@ docker-build: @echo "Building Docker image..." docker build --target soundtouch-service -t soundtouch-service . +# Stockholm frontend preparation. +# Requires: Docker, internet access (clones github.com/krahl/soundcork-stockholm-app). +# No pre-built image is published; the image must be built locally before running prepare-stockholm. +build-stockholm-image: + @echo "Building Stockholm preparation image (clones upstream, installs prettier/patch)..." + docker build \ + --build-arg STOCKHOLM_APP_REF=$(STOCKHOLM_APP_REF) \ + -f Dockerfile.stockholm \ + -t $(STOCKHOLM_IMAGE) \ + . + +# Extracts and patches the Stockholm frontend using the upstream container image. +# Requires: build-stockholm-image to have been run, and stockholm_zip/stockholm.zip to be present. +# The resulting stockholm/ directory is used by the soundtouch-service at runtime. +prepare-stockholm: + @mkdir -p "$(STOCKHOLM_DIR)" + @[ -f "$(STOCKHOLM_ZIP_DIR)/stockholm.zip" ] || { \ + echo "Error: $(STOCKHOLM_ZIP_DIR)/stockholm.zip not found."; \ + echo "Download the Stockholm zip and place it at stockholm_zip/stockholm.zip first."; \ + exit 1; } + docker run --rm \ + -v "$(STOCKHOLM_ZIP_DIR):/app/stockholm_zip:ro" \ + -v "$(STOCKHOLM_DIR):/app/stockholm" \ + --entrypoint bash \ + $(STOCKHOLM_IMAGE) \ + -c 'awk "/^exec java/{exit} {print}" /app/docker-entrypoint.sh | bash' + @echo "Stockholm frontend prepared at $(STOCKHOLM_DIR)" + docker-run-host: @echo "Running Docker container..." @echo "Note: --network host is used for discovery (Linux only). For macOS/Windows use port mapping." @@ -386,6 +421,9 @@ help: @echo " docker-build - Build Docker image" @echo " docker-run-host - Run container with host networking (Linux discovery)" @echo " docker-run-ports - Run container with port mapping (macOS/Windows/No discovery)" + @echo " build-stockholm-image - Build Stockholm prep image (requires Docker + internet)" + @echo " prepare-stockholm - Extract and patch Stockholm frontend (requires build-stockholm-image" + @echo " and stockholm_zip/stockholm.zip; see docs/stockholm-port-guide.md)" @echo " help - Show this help message" @echo "" @echo "Examples:" diff --git a/stockholm_zip/PUT_STOCKHOLM_SOURCE_ZIP_HERE b/stockholm_zip/PUT_STOCKHOLM_SOURCE_ZIP_HERE new file mode 100644 index 0000000..e69de29