feat: Add container startup script for backend that conditionally manages OpenClaw gateway and starts the Uvicorn server.
This commit is contained in:
parent
deadc684c7
commit
a466e64247
@ -62,6 +62,10 @@ COPY --chown=foxy:foxy --from=frontend-build /build/dist ./static
|
||||
HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --retries=3 \
|
||||
CMD curl -f http://localhost:7000/api/health || exit 1
|
||||
|
||||
# Copy and prepare startup script
|
||||
COPY --chown=foxy:foxy backend/start-container.sh ./
|
||||
RUN chmod +x ./start-container.sh
|
||||
|
||||
# Runtime config
|
||||
ENV PYTHONUNBUFFERED=1 \
|
||||
PYTHONDONTWRITEBYTECODE=1 \
|
||||
@ -71,4 +75,4 @@ EXPOSE 7000
|
||||
|
||||
USER foxy
|
||||
|
||||
CMD ["python", "-m", "uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "7000"]
|
||||
CMD ["./start-container.sh"]
|
||||
|
||||
@ -6,11 +6,20 @@ TELEGRAM_BOT_TOKEN=your-telegram-bot-token
|
||||
TELEGRAM_CHAT_ID=your-chat-id
|
||||
|
||||
# ─── OpenClaw ──────────────────────────────────────────────
|
||||
# OpenClaw installation type (standalone or Shared)
|
||||
# Shared: OpenClaw is installed on the host and shared with the container
|
||||
# Standalone: OpenClaw is installed inside the container with gateway running
|
||||
OPENCLAW_TYPE=standalone
|
||||
# Root path on the HOST (contains agents/, workspace/, config.json)
|
||||
OPENCLAW_HOME=/home/openclaw/.openclaw
|
||||
# Root path in the CONTAINER (keep as is)
|
||||
FOXY_HOME=/home/foxy/.openclaw
|
||||
|
||||
# OpenClaw installation type (standalone or shared)
|
||||
# shared: OpenClaw gateway runs on the host (Default if empty)
|
||||
# standalone: OpenClaw gateway starts automatically inside the container
|
||||
OPENCLAW_TYPE=standalone
|
||||
|
||||
# ─── Gitea ─────────────────────────────────────────────────
|
||||
GITEA_SERVER=https://gitea.your.server
|
||||
GITEA_OPENCLAW_TOKEN=your-gitea-token
|
||||
|
||||
48
backend/start-container.sh
Normal file
48
backend/start-container.sh
Normal file
@ -0,0 +1,48 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
echo "🦊 Starting Foxy Dev Team API Container..."
|
||||
|
||||
# Defaults if not provided
|
||||
export FOXY_HOME="${FOXY_HOME:-/home/foxy/.openclaw}"
|
||||
export OPENCLAW_TYPE="${OPENCLAW_TYPE:-shared}"
|
||||
|
||||
if [ "$OPENCLAW_TYPE" = "standalone" ]; then
|
||||
echo "🔧 OPENCLAW_TYPE is standalone. Setting up OpenClaw..."
|
||||
|
||||
# Initialize OpenClaw default configuration if it doesn't exist
|
||||
if [ ! -f "$FOXY_HOME/config.json" ] && [ ! -f "$FOXY_HOME/config.yaml" ]; then
|
||||
echo "📦 Initializing default OpenClaw config at $FOXY_HOME..."
|
||||
mkdir -p "$FOXY_HOME/workspace"
|
||||
mkdir -p "$FOXY_HOME/agents"
|
||||
|
||||
# Write a simple default config if OpenClaw hasn't been onboarded
|
||||
cat <<EOF > "$FOXY_HOME/config.json"
|
||||
{
|
||||
"theme": "dark",
|
||||
"logLevel": "info",
|
||||
"gatewayPort": 20124,
|
||||
"gatewayHost": "127.0.0.1",
|
||||
"workspaceDir": "$FOXY_HOME/workspace",
|
||||
"agentsDir": "$FOXY_HOME/agents"
|
||||
}
|
||||
EOF
|
||||
echo "✅ Default configuration created."
|
||||
else
|
||||
echo "👍 OpenClaw configuration already exists at $FOXY_HOME."
|
||||
fi
|
||||
|
||||
echo "🚀 Starting OpenClaw Gateway in the background..."
|
||||
# Starting OpenClaw gateway in the background so it doesn't block FastAPI
|
||||
if command -v openclaw >/dev/null 2>&1; then
|
||||
nohup openclaw gateway start > "$FOXY_HOME/logs/gateway.log" 2>&1 &
|
||||
echo "✅ OpenClaw Gateway started."
|
||||
else
|
||||
echo "❌ 'openclaw' command not found, unable to start gateway!"
|
||||
fi
|
||||
else
|
||||
echo "🔗 OPENCLAW_TYPE is shared. Assuming OpenClaw Gateway is managed by the host."
|
||||
fi
|
||||
|
||||
echo "🚀 Starting Uvicorn API Server..."
|
||||
exec python -m uvicorn app.main:app --host 0.0.0.0 --port 7000
|
||||
@ -22,6 +22,9 @@ services:
|
||||
- "${API_PORT:-7000}:7000"
|
||||
env_file:
|
||||
- backend/.env
|
||||
environment:
|
||||
- FOXY_WORKSPACE=${FOXY_WORKSPACE:-/home/foxy/.openclaw/workspace}
|
||||
- OPENCLAW_TYPE=${OPENCLAW_TYPE:-standalone}
|
||||
volumes:
|
||||
- foxy-data:/app/data
|
||||
- "${OPENCLAW_HOME:-/home/openclaw/.openclaw}:${FOXY_HOME:-/home/foxy/.openclaw}"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user