sx-http: Docker compose overlay + auto-detect component dir

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) <noreply@anthropic.com>
This commit is contained in:
2026-03-28 17:20:27 +00:00
parent c8301c5947
commit 2ae42d3898
2 changed files with 22 additions and 2 deletions

View File

@@ -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

View File

@@ -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),