From 2ae42d38985e4b6319d932647acaaa068f1205b4 Mon Sep 17 00:00:00 2001 From: giles Date: Sat, 28 Mar 2026 17:20:27 +0000 Subject: [PATCH] sx-http: Docker compose overlay + auto-detect component dir MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit docker-compose.dev-sx-native.yml overrides entrypoint to run OCaml HTTP server inside Docker container (Caddy on externalnet can reach it). Auto-detect sx component directory: checks /app/sx (Docker) first, falls back to /project/sx/sx (dev). SX_COMPONENTS_DIR env override. Live on sx.rose-ash.com via Caddy → Docker → OCaml HTTP server. Co-Authored-By: Claude Opus 4.6 (1M context) --- docker-compose.dev-sx-native.yml | 14 ++++++++++++++ hosts/ocaml/bin/sx_server.ml | 10 ++++++++-- 2 files changed, 22 insertions(+), 2 deletions(-) create mode 100644 docker-compose.dev-sx-native.yml diff --git a/docker-compose.dev-sx-native.yml b/docker-compose.dev-sx-native.yml new file mode 100644 index 00000000..7e5b4959 --- /dev/null +++ b/docker-compose.dev-sx-native.yml @@ -0,0 +1,14 @@ +# Native OCaml HTTP server for sx_docs — no Python, no Quart +# Overrides dev-sx.yml entrypoint to use sx_server --http +# +# Usage: +# docker compose -p sx-dev -f docker-compose.dev-sx.yml -f docker-compose.dev-sx-native.yml up + +services: + sx_docs: + entrypoint: ["/app/bin/sx_server", "--http", "8000"] + environment: + SX_PROJECT_DIR: /app + SX_SPEC_DIR: /app/spec + SX_LIB_DIR: /app/lib + SX_WEB_DIR: /app/web diff --git a/hosts/ocaml/bin/sx_server.ml b/hosts/ocaml/bin/sx_server.ml index d3bdcfe7..5c5c0fe6 100644 --- a/hosts/ocaml/bin/sx_server.ml +++ b/hosts/ocaml/bin/sx_server.ml @@ -1695,8 +1695,14 @@ let http_mode port = project_dir ^ "/lib" in let web_base = try Sys.getenv "SX_WEB_DIR" with Not_found -> project_dir ^ "/web" in - let shared_sx = project_dir ^ "/shared/sx/templates" in - let sx_sx = project_dir ^ "/sx/sx" in + let shared_sx = try Sys.getenv "SX_SHARED_DIR" with Not_found -> + project_dir ^ "/shared/sx/templates" in + let sx_sx = try Sys.getenv "SX_COMPONENTS_DIR" with Not_found -> + (* Docker: /app/sx, dev: /project/sx/sx *) + let docker_path = project_dir ^ "/sx" in + let dev_path = project_dir ^ "/sx/sx" in + if Sys.file_exists (docker_path ^ "/page-functions.sx") then docker_path + else dev_path in let t0 = Unix.gettimeofday () in (* Core spec + adapters. Skip: primitives.sx (declarative metadata — all prims native in OCaml),