oci: run script can enable/disable bundled demo tool web UIs

The image's demo tool UIs (video editor :8420, videogen :7790, township :7788,
parler TTS :8123) are now individually toggleable at container start — no
rebuild. supervisord.conf drives each program's autostart from a CODERAI_TOOL_*
env var; the entrypoint seeds defaults (three UIs on, parler off) so the
%(ENV_...)s expansion always resolves. run_oci.sh (shipped as the dist
coderai-docker runner) gains:

  --no-tools            disable all three demo UIs
  --enable-tool NAME    force-enable one (also turns on parler)
  --disable-tool NAME   disable one; explicit toggles override --no-tools

NAME ∈ {video-editor, videogen, township, parler}. README + --help updated.
Co-Authored-By: 's avatarClaude Opus 4.8 <noreply@anthropic.com>
parent 6517dfbe
......@@ -43,6 +43,12 @@ Useful options (see --help)
--debug[=engine,ws,...] Run with coderai debug flags + a host-tailable file log.
--log-file PATH In-container log path (default /cache/logs/coderai.log,
visible on the host under the cache mount).
--no-tools Disable the bundled demo tool web UIs (video editor,
videogen, township). They're on by default.
--enable-tool NAME Force-enable a demo tool (also turns on parler TTS,
which is off by default). NAME: video-editor | videogen
| township | parler. Repeatable.
--disable-tool NAME Disable a single demo tool. Repeatable.
-d, --detach Run in the background.
Manual image load (without install.sh)
......
......@@ -17,6 +17,15 @@ set -eu
export TMPDIR="$CODERAI_TMP" TMP="$CODERAI_TMP" TEMP="$CODERAI_TMP"
# Don't write .pyc into the read-only /opt/coderai tree (esp. when run as --user).
export PYTHONDONTWRITEBYTECODE=1
# Demo tool web-UI autostart toggles, consumed by supervisord.conf's
# autostart=%(ENV_CODERAI_TOOL_*)s. Default the three UIs ON and parler OFF; the
# run script (or any `-e CODERAI_TOOL_*=true|false`) overrides these. supervisord
# fails to start if a referenced ENV var is undefined, so always export them.
: "${CODERAI_TOOL_VIDEO_EDITOR:=true}"
: "${CODERAI_TOOL_VIDEOGEN:=true}"
: "${CODERAI_TOOL_TOWNSHIP:=true}"
: "${CODERAI_TOOL_PARLER:=false}"
export CODERAI_TOOL_VIDEO_EDITOR CODERAI_TOOL_VIDEOGEN CODERAI_TOOL_TOWNSHIP CODERAI_TOOL_PARLER
export CODERAI_CONFIG_DIR CODERAI_MODELS_DIR CODERAI_CACHE_DIR CODERAI_PARLER_MODEL CODERAI_TMP
mkdir -p \
......
......@@ -27,6 +27,21 @@ MAPS=()
# volume so it's tailable on the host).
DEBUG_SPEC=""
LOG_FILE_CONT=""
# Demo tool web UIs (video editor, videogen, township, parler). Empty = image
# default (the three UIs on, parler off). Keyed by CODERAI_TOOL_* env var.
declare -A TOOL_STATE=()
DISABLE_ALL_TOOLS=0
# Map a friendly tool name to its CODERAI_TOOL_* env var (or fail).
tool_env_var() {
case "$1" in
video-editor|video_editor|editor) echo CODERAI_TOOL_VIDEO_EDITOR ;;
videogen|video-gen) echo CODERAI_TOOL_VIDEOGEN ;;
township|fighters) echo CODERAI_TOOL_TOWNSHIP ;;
parler|tts) echo CODERAI_TOOL_PARLER ;;
*) return 1 ;;
esac
}
usage() {
cat <<'EOF'
......@@ -57,6 +72,13 @@ Options:
--log-file PATH In-container log path (default /cache/logs/coderai.log,
visible on the host under the cache mount). Implies a file
log even without --debug. tee'd, so `docker logs` still works.
--no-tools Disable ALL bundled demo tool web UIs (video editor,
videogen, township). They're on by default.
--enable-tool NAME Force-enable a demo tool. Repeatable. NAME is one of:
video-editor | videogen | township | parler
(parler TTS is off by default; this turns it on.)
--disable-tool NAME Disable a single demo tool. Repeatable. Same NAMEs as above.
Explicit --enable/--disable-tool overrides --no-tools.
-- ARGS Extra args passed to the container engine before the image name.
-h, --help Show this help.
......@@ -95,6 +117,15 @@ while [[ $# -gt 0 ]]; do
--log-file)
[[ $# -ge 2 ]] || { echo "Error: --log-file requires a path" >&2; exit 2; }
LOG_FILE_CONT="$2"; shift 2 ;;
--no-tools) DISABLE_ALL_TOOLS=1; shift ;;
--enable-tool)
[[ $# -ge 2 ]] || { echo "Error: --enable-tool requires a tool name" >&2; exit 2; }
_v="$(tool_env_var "$2")" || { echo "Error: unknown tool '$2' (video-editor|videogen|township|parler)" >&2; exit 2; }
TOOL_STATE["$_v"]=true; shift 2 ;;
--disable-tool)
[[ $# -ge 2 ]] || { echo "Error: --disable-tool requires a tool name" >&2; exit 2; }
_v="$(tool_env_var "$2")" || { echo "Error: unknown tool '$2' (video-editor|videogen|township|parler)" >&2; exit 2; }
TOOL_STATE["$_v"]=false; shift 2 ;;
-d|--detach) DETACH=1; shift ;;
--)
shift
......@@ -187,6 +218,24 @@ if [[ -n "$DEBUG_SPEC" || -n "$LOG_FILE_CONT" ]]; then
esac
fi
# Demo tool toggles → CODERAI_TOOL_* env. --no-tools turns the three UIs off
# (unless a specific --enable-tool re-enabled one); explicit toggles always win.
if [[ "$DISABLE_ALL_TOOLS" == "1" ]]; then
for _v in CODERAI_TOOL_VIDEO_EDITOR CODERAI_TOOL_VIDEOGEN CODERAI_TOOL_TOWNSHIP; do
[[ -n "${TOOL_STATE[$_v]:-}" ]] || TOOL_STATE["$_v"]=false
done
fi
TOOLS_NOTE="image defaults (video-editor, videogen, township on; parler off)"
if [[ "${#TOOL_STATE[@]}" -gt 0 ]]; then
TOOLS_NOTE=""
for _v in "${!TOOL_STATE[@]}"; do
args+=(-e "$_v=${TOOL_STATE[$_v]}")
_label="${_v#CODERAI_TOOL_}"
TOOLS_NOTE+="$(echo "$_label" | tr 'A-Z_' 'a-z-')=${TOOL_STATE[$_v]} "
done
TOOLS_NOTE="${TOOLS_NOTE% }"
fi
args+=("${EXTRA_ARGS[@]}" "$IMAGE_TAG")
cat <<EOF
......@@ -199,6 +248,7 @@ Starting CoderAI OCI container
config: $CONFIG_NOTE
debug: ${DEBUG_SPEC:-off}
log: $LOG_HOST_NOTE
tools: $TOOLS_NOTE
EOF
if [[ "$LOG_HOST_NOTE" != "(none)" ]]; then
......
......@@ -46,12 +46,15 @@ stdout_logfile=/dev/fd/1
stdout_logfile_maxbytes=0
redirect_stderr=true
; Bundled demo tool web UIs. Each program's autostart is driven by an env var
; (CODERAI_TOOL_*) seeded with a default in the entrypoint, so the run script (or
; any `docker run -e`) can enable/disable individual demos at startno rebuild.
[program:video_editor]
command=/usr/local/bin/with-env /opt/coderai/python/bin/python3 /opt/coderai/app/tools/video_editor.py
--no-browser --host 127.0.0.1 --port 8420
--base-url http://127.0.0.1:18776
directory=/opt/coderai/app
autostart=true
autostart=%(ENV_CODERAI_TOOL_VIDEO_EDITOR)s
autorestart=true
startsecs=5
startretries=5
......@@ -66,7 +69,7 @@ command=/usr/local/bin/with-env /opt/coderai/python/bin/python3 /opt/coderai/app
--base-url http://127.0.0.1:18776
--out-dir /cache/videogen_output
directory=/opt/coderai/app
autostart=true
autostart=%(ENV_CODERAI_TOOL_VIDEOGEN)s
autorestart=true
startsecs=5
startretries=5
......@@ -81,7 +84,7 @@ command=/usr/local/bin/with-env /opt/coderai/python/bin/python3 /opt/coderai/app
--base-url http://127.0.0.1:18776
--out-dir /cache/township_output
directory=/opt/coderai/app
autostart=true
autostart=%(ENV_CODERAI_TOOL_TOWNSHIP)s
autorestart=true
startsecs=5
startretries=5
......@@ -95,14 +98,15 @@ redirect_stderr=true
; the rest resolve from the standalone Python's site-packages underneathexactly
; the local --system-site-packages layering. Internal-only (not proxied by nginx);
; coderai reaches it via a TTS model config { "service_url": "http://127.0.0.1:8123" }.
; Disabled by default: set autostart=true (or start it from supervisorctl) once a
; parler model is configured. Won't be fatal if the model isn't present.
; Disabled by default (CODERAI_TOOL_PARLER=false): enable with the run script's
; --enable-tool parler (or -e CODERAI_TOOL_PARLER=true) once a parler model is
; configured. Won't be fatal if the model isn't present.
[program:parler]
command=/usr/local/bin/with-env /opt/coderai/python/bin/python3 /opt/coderai/app/tools/parler_tts_service.py
--model %(ENV_CODERAI_PARLER_MODEL)s --port 8123
environment=PYTHONPATH="/opt/coderai/parler-venv/site-packages"
directory=/opt/coderai/app
autostart=false
autostart=%(ENV_CODERAI_TOOL_PARLER)s
autorestart=true
startsecs=10
startretries=3
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment