Dmitry Beresnev commited on
Commit ·
66a2fe2
1
Parent(s): edd7841
add openclaw and streamlit ui like separate services
Browse filesFiles changed (4)
- CaddyfileAdded+9
- Dockerfile+6-2
- app.py+16-2
- supervisord.confAdded+26
123456789:{$PORT}
handle_path /openclaw/* { reverse_proxy 127.0.0.1:{$OPENCLAW_PORT}}
handle { reverse_proxy 127.0.0.1:8501}112342 unmodified lines7891011121314151616 unmodified lines333435363738394041423943FROM python:3.13-slimFROM python:3.11-slim
WORKDIR /app
2 unmodified lines bash \ curl \ ca-certificates \ caddy \ ffmpeg \ git \ supervisor \ && curl -fsSL https://deb.nodesource.com/setup_22.x | bash - \ && apt-get install -y --no-install-recommends nodejs \ && npm install -g openclaw \16 unmodified linesENV OPENCLAW_HOME=/app/.openclawENV OPENCLAW_STATE_DIR=/app/.openclaw/stateENV AUTO_START_GATEWAY=0ENV EXTERNAL_GATEWAY_MANAGED=1ENV OPENCLAW_STANDARD_UI_PUBLIC_URL=/openclaw/
RUN mkdir -p /app/vault /app/.openclaw/state
EXPOSE 7860
CMD ["sh", "-c", "${OPENCLAW_BIN} gateway run --port ${OPENCLAW_PORT} --allow-unconfigured > /tmp/openclaw-gateway.log 2>&1 & exec uv run streamlit run app.py --server.address=0.0.0.0 --server.port=7860"]CMD ["supervisord", "-c", "/app/supervisord.conf"]27 unmodified lines282930313132333435363781 unmodified lines11912012112212312412512667 unmodified lines19419519619719819920020141 unmodified lines24324424524624724824925025125225325483 unmodified lines33833934034133034234334434515 unmodified lines36136236336436536636736827 unmodified linesOPENCLAW_STANDARD_UI_URL = os.getenv( "OPENCLAW_STANDARD_UI_URL", f"http://127.0.0.1:{OPENCLAW_PORT}/")OPENCLAW_STANDARD_UI_PUBLIC_URL = os.getenv("OPENCLAW_STANDARD_UI_PUBLIC_URL", "")OPENCLAW_STANDARD_UI_PUBLIC_URL = os.getenv("OPENCLAW_STANDARD_UI_PUBLIC_URL", "/openclaw/")OPENCLAW_GATEWAY_TOKEN = os.getenv("OPENCLAW_GATEWAY_TOKEN", "")GATEWAY_BOOT_LOG_PATH = Path(os.getenv("OPENCLAW_GATEWAY_LOG_PATH", "/tmp/openclaw-gateway.log"))EXTERNAL_GATEWAY_MANAGED = os.getenv("EXTERNAL_GATEWAY_MANAGED", "0") == "1"
def resolve_openclaw_bin() -> str | None:81 unmodified lines
def start_gateway() -> tuple[bool, str]: if EXTERNAL_GATEWAY_MANAGED: return True, "Gateway is managed by supervisor from Docker startup." if gateway_process() is not None: return True, "Gateway is already running."
67 unmodified lines
def stop_gateway() -> tuple[bool, str]: if EXTERNAL_GATEWAY_MANAGED: return False, "Gateway is managed by supervisor; stop it via container config." proc = gateway_process() if proc is None: return True, "Gateway is not running."41 unmodified lines return f"Gateway request failed: {exc}"
def is_gateway_port_open(timeout: float = 0.5) -> bool: with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as sock: sock.settimeout(timeout) return sock.connect_ex(("127.0.0.1", OPENCLAW_PORT)) == 0
def with_token(url: str, token: str) -> str: if not token: return url83 unmodified linesstatus_col, action_col = st.columns([2, 3])with status_col: proc = gateway_process() running = is_gateway_port_open() or (proc is not None) st.metric("Gateway Status", "Running" if proc else "Stopped") st.metric("Gateway Status", "Running" if running else "Stopped") st.write(f"UI port: `{HF_PORT}`") st.write(f"Gateway port: `{OPENCLAW_PORT}`") st.write(f"Vault path: `{VAULT_PATH}`")15 unmodified lines (st.success if ok else st.error)(msg) if c4.button("Refresh", use_container_width=True): st.rerun() if EXTERNAL_GATEWAY_MANAGED: st.caption("Gateway controls are informational only (managed by Docker supervisor).")
st.divider()
1234567891011121314151617181920212223242526[supervisord]nodaemon=truelogfile=/tmp/supervisord.logpidfile=/tmp/supervisord.pid
[program:openclaw]command=/bin/sh -lc "%(ENV_OPENCLAW_BIN)s gateway run --port %(ENV_OPENCLAW_PORT)s --allow-unconfigured"autorestart=truestartsecs=2stdout_logfile=/tmp/openclaw-gateway.logstderr_logfile=/tmp/openclaw-gateway.err.logenvironment=HOME="/root"
[program:streamlit]command=/bin/sh -lc "cd /app && uv run streamlit run app.py --server.address=0.0.0.0 --server.port=8501"autorestart=truestartsecs=2stdout_logfile=/tmp/streamlit.logstderr_logfile=/tmp/streamlit.err.log
[program:caddy]command=/bin/sh -lc "caddy run --config /app/Caddyfile --adapter caddyfile"autorestart=truestartsecs=2stdout_logfile=/tmp/caddy.logstderr_logfile=/tmp/caddy.err.logCaddyfileAdded+9
Dockerfile+6-2
app.py+16-2
supervisord.confAdded+26