Spaces:
Sleeping
Sleeping
| # Agenta on Hugging Face Spaces - Fixed typo in supervisor config | |
| # Uses official Agenta images with SQLite instead of PostgreSQL | |
| FROM ghcr.io/agenta-ai/agenta-api:latest AS api-base | |
| USER root | |
| # Install Python dependencies for SQLite and other tools | |
| RUN apt-get update && apt-get install -y \ | |
| sqlite3 \ | |
| redis-server \ | |
| nginx \ | |
| supervisor \ | |
| curl \ | |
| && rm -rf /var/lib/apt/lists/* | |
| # Setup directories | |
| RUN mkdir -p /app/data /var/log/supervisor /var/run/redis | |
| # Copy web assets from web image | |
| FROM ghcr.io/agenta-ai/agenta-web:latest AS web-source | |
| WORKDIR /app | |
| # Final stage | |
| FROM api-base | |
| # Copy web files | |
| COPY --from=web-source /app /app/web | |
| # Setup environment for SQLite and single container | |
| ENV PORT=7860 | |
| ENV HOSTNAME=0.0.0.0 | |
| ENV AGENTA_MODE=oss | |
| # Use SQLite instead of PostgreSQL | |
| ENV DATABASE_URL=sqlite:////app/data/agenta.db | |
| ENV REDIS_URL=redis://localhost:6379/0 | |
| # API and Web URLs | |
| ENV AGENTA_API_URL=http://localhost:7860/api | |
| ENV AGENTA_WEB_URL=http://localhost:7860 | |
| ENV AGENTA_SERVICES_URL=http://localhost:7860/services | |
| # Additional config for Agenta | |
| ENV ENVIRONMENT=production | |
| ENV FEATURE_FLAG=oss | |
| # Create supervisor config - FIXED TYPO HERE | |
| RUN cat > /etc/supervisor/conf.d/supervisord.conf << 'EOF' | |
| [supervisord] | |
| nodaemon=true | |
| user=root | |
| logfile=/var/log/supervisor/supervisord.log | |
| pidfile=/var/run/supervisord.pid | |
| [program:redis] | |
| command=/usr/bin/redis-server --daemonize no --bind 127.0.0.1 --port 6379 | |
| autostart=true | |
| autorestart=true | |
| priority=1 | |
| stdout_logfile=/var/log/supervisor/redis.log | |
| stderr_logfile=/var/log/supervisor/redis.err | |
| [program:api] | |
| command=bash -c "sleep 5 && cd /app && uvicorn agenta_backend.main:app --host 0.0.0.0 --port 8080" | |
| directory=/app | |
| autostart=true | |
| autorestart=true | |
| priority=2 | |
| stdout_logfile=/var/log/supervisor/api.log | |
| stderr_logfile=/var/log/supervisor/api.err | |
| environment=DATABASE_URL="%(ENV_DATABASE_URL)s",REDIS_URL="%(ENV_REDIS_URL)s",ENVIRONMENT="production" | |
| [program:web] | |
| command=bash -c "sleep 10 && cd /app/web && npm start" | |
| directory=/app/web | |
| autostart=true | |
| autorestart=true | |
| priority=3 | |
| stdout_logfile=/var/log/supervisor/web.log | |
| stderr_logfile=/var/log/supervisor/web.err | |
| [program:nginx] | |
| command=/usr/sbin/nginx -g 'daemon off;' | |
| autostart=true | |
| autorestart=true | |
| priority=4 | |
| stdout_logfile=/var/log/supervisor/nginx.log | |
| stderr_logfile=/var/log/supervisor/nginx.err | |
| EOF | |
| # Nginx config for port 7860 | |
| RUN cat > /etc/nginx/sites-available/default << 'EOF' | |
| server { | |
| listen 7860; | |
| server_name _; | |
| client_max_body_size 100M; | |
| location / { | |
| proxy_pass http://127.0.0.1:3000; | |
| proxy_http_version 1.1; | |
| proxy_set_header Upgrade $http_upgrade; | |
| proxy_set_header Connection 'upgrade'; | |
| proxy_set_header Host $host; | |
| proxy_set_header X-Real-IP $remote_addr; | |
| proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | |
| proxy_set_header X-Forwarded-Proto $scheme; | |
| proxy_cache_bypass $http_upgrade; | |
| } | |
| location /api/ { | |
| proxy_pass http://127.0.0.1:8080/; | |
| proxy_http_version 1.1; | |
| proxy_set_header Upgrade $http_upgrade; | |
| proxy_set_header Connection 'upgrade'; | |
| proxy_set_header Host $host; | |
| proxy_set_header X-Real-IP $remote_addr; | |
| proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | |
| proxy_set_header X-Forwarded-Proto $scheme; | |
| proxy_cache_bypass $http_upgrade; | |
| } | |
| } | |
| EOF | |
| # Remove default nginx site if exists | |
| RUN rm -f /etc/nginx/sites-enabled/default && \ | |
| ln -s /etc/nginx/sites-available/default /etc/nginx/sites-enabled/default | |
| # Init script | |
| RUN cat > /init.sh << 'EOF' | |
| #!/bin/bash | |
| set -e | |
| # Ensure data directory exists | |
| mkdir -p /app/data | |
| chmod 777 /app/data | |
| # Initialize SQLite database if not exists | |
| if [ ! -f /app/data/agenta.db ]; then | |
| echo "Initializing SQLite database..." | |
| touch /app/data/agenta.db | |
| chmod 666 /app/data/agenta.db | |
| fi | |
| # Export environment variables for supervisor | |
| export DATABASE_URL=${DATABASE_URL} | |
| export REDIS_URL=${REDIS_URL} | |
| echo "Starting Agenta services..." | |
| echo "Database: $DATABASE_URL" | |
| echo "Redis: $REDIS_URL" | |
| # Start supervisor | |
| exec /usr/bin/supervisord -c /etc/supervisor/conf.d/supervisord.conf | |
| EOF | |
| RUN chmod +x /init.sh | |
| EXPOSE 7860 | |
| HEALTHCHECK --interval=30s --timeout=10s --start-period=60s --retries=3 \ | |
| CMD curl -f http://localhost:7860 || exit 1 | |
| ENTRYPOINT ["/init.sh"] |