From d52de3679ed83e97e494954f23f6517ce2c34b1b Mon Sep 17 00:00:00 2001 From: James Brechtel Date: Tue, 19 May 2026 07:29:04 -0400 Subject: [PATCH] scripts/run: mount recipe directory and publish port - scripts/run now takes a recipe directory as its first argument, resolves it to an absolute path, and mounts it at /recipes in the Docker container - Parses --port flag to map container port 8080 to the requested host port (default 8080) - Passes --recipe-dir /recipes --port 8080 to the server - Passes --host and any additional args through to the server - Exits with an error if the recipe directory doesn't exist - Also accept --host flag and pass remaining args through Example: ./scripts/run ~/my-recipes --port 9090 --- scripts/run | 60 +++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 58 insertions(+), 2 deletions(-) diff --git a/scripts/run b/scripts/run index 547018b..9002c48 100755 --- a/scripts/run +++ b/scripts/run @@ -1,4 +1,60 @@ #!/usr/bin/env bash +# Run the roux-server in Docker, mounting a local recipe directory. +# +# Usage: ./scripts/run [--host HOST] [--port PORT] +# +# The server listens on port 8080 inside the container, mapped to PORT +# on the host (default 8080). Pass --port to change the host-side port. +# +# Examples: +# ./scripts/run ~/recipes +# ./scripts/run ./cooklang-examples --port 9090 set -euo pipefail -cd "$(dirname "${BASH_SOURCE[0]}")/.." -./hs stack exec roux-server -- "$@" + +PROJECT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" + +if [ $# -lt 1 ]; then + echo "Usage: $0 [--host HOST] [--port PORT]" >&2 + exit 1 +fi + +# Resolve the recipe directory to an absolute path so Docker can mount it. +RECIPE_DIR="$(cd "$1" && pwd)" +shift + +# Parse --port from remaining args; everything else is passed to the server. +HOST_PORT=8080 +SERVER_ARGS=() +while [ $# -gt 0 ]; do + case "$1" in + --port) + HOST_PORT="$2" + shift 2 + ;; + --host) + SERVER_ARGS+=("$1" "$2") + shift 2 + ;; + *) + SERVER_ARGS+=("$1") + shift + ;; + esac +done + +IMAGE="${HAWAT_HASKELL_TOOLS_IMAGE:-ghcr.io/flipstone/haskell-tools:debian-ghc-9.10.3-5d6640d}" +STACK_ROOT_HOST="${PROJECT_DIR}/.stack-root" +mkdir -p "${STACK_ROOT_HOST}" + +echo "[roux] mounting recipes from ${RECIPE_DIR}" +echo "[roux] listening on http://127.0.0.1:${HOST_PORT}/" + +exec docker run --rm -i $([ -t 0 ] && printf -- -t) \ + -v "${PROJECT_DIR}:/work" \ + -v "${STACK_ROOT_HOST}:/stack-root" \ + -v "${RECIPE_DIR}:/recipes" \ + -e STACK_ROOT=/stack-root \ + -w /work \ + -p "${HOST_PORT}:8080" \ + "${IMAGE}" \ + stack exec roux-server -- --recipe-dir /recipes --port 8080 "${SERVER_ARGS[@]}"