DaCrow13 commited on
Commit ·
2b68a06
1
Parent(s): eb469ad
feat: Orchestrate application startup with `start_space.sh`, configure Nginx for container logging, and add `procps` to the Dockerfile.
Browse filesFiles changed (3)
- Dockerfile+1
- nginx.conf+10-8
- scripts/start_space.sh+22-4
11 unmodified lines12131415161711 unmodified linesgit \dos2unix \nginx \&& rm -rf /var/lib/apt/lists/*# Create a non-root user11 unmodified lines1213141516171811 unmodified linesgit \dos2unix \nginx \procps \&& rm -rf /var/lib/apt/lists/*# Create a non-root user
1234563 unmodified lines1011121314151615 unmodified lines32333435363724 unmodified lines62636465666768697071722 unmodified lines75767778798081worker_processes 1;pid /tmp/nginx.pid;error_log /tmp/nginx.error.log;events {worker_connections 1024;3 unmodified linesinclude /etc/nginx/mime.types;default_type application/octet-stream;access_log /tmp/nginx.access.log;client_body_temp_path /tmp/client_temp;proxy_temp_path /tmp/proxy_temp;fastcgi_temp_path /tmp/fastcgi_temp;15 unmodified lineslisten 7860;server_name localhost;# FastAPI Documentationlocation /docs {proxy_pass http://fastapi/docs;24 unmodified linesproxy_set_header Host $host;}location /health {proxy_pass http://fastapi/health;proxy_set_header Host $host;}# Streamlit (Catch-all)location / {proxy_pass http://streamlit;2 unmodified linesproxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;proxy_set_header X-Forwarded-Proto $scheme;# WebSocket supportproxy_http_version 1.1;proxy_set_header Upgrade $http_upgrade;proxy_set_header Connection "upgrade";1234563 unmodified lines101112131415161715 unmodified lines33343536373839404142434424 unmodified lines6970717273742 unmodified lines77787980818283worker_processes 1;pid /tmp/nginx.pid;error_log stderr info; # Log to stderr to see errors in HF Space Logsevents {worker_connections 1024;3 unmodified linesinclude /etc/nginx/mime.types;default_type application/octet-stream;# HF Space runs as non-root, use /tmp for everythingaccess_log /dev/stdout;client_body_temp_path /tmp/client_temp;proxy_temp_path /tmp/proxy_temp;fastcgi_temp_path /tmp/fastcgi_temp;15 unmodified lineslisten 7860;server_name localhost;# Health endpoint for HF readiness checklocation /health {proxy_pass http://fastapi/health;proxy_set_header Host $host;}# FastAPI Documentationlocation /docs {proxy_pass http://fastapi/docs;24 unmodified linesproxy_set_header Host $host;}# Streamlit (Catch-all)location / {proxy_pass http://streamlit;2 unmodified linesproxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;proxy_set_header X-Forwarded-Proto $scheme;# WebSocket support for Streamlitproxy_http_version 1.1;proxy_set_header Upgrade $http_upgrade;proxy_set_header Connection "upgrade";
33 unmodified lines34353637383940414243444546474849505133 unmodified lines# Create Nginx temp directoriesmkdir -p /tmp/client_temp /tmp/proxy_temp /tmp/fastcgi_temp /tmp/uwsgi_temp /tmp/scgi_tempecho "Starting FastAPI application in background..."uvicorn hopcroft_skill_classification_tool_competition.main:app --host 127.0.0.1 --port 8000 &# Wait for API to startecho "Waiting for API to start..."sleep 10echo "Starting Nginx reverse proxy..."nginx -c /app/nginx.conf -g "daemon off;" &echo "Waiting for Nginx to initialize..."sleep 2echo "Starting Streamlit application..."export API_BASE_URL="http://127.0.0.1:8000"33 unmodified lines34353637383940414243444546474849505152535455565758596061626364656667686933 unmodified lines# Create Nginx temp directoriesmkdir -p /tmp/client_temp /tmp/proxy_temp /tmp/fastcgi_temp /tmp/uwsgi_temp /tmp/scgi_tempecho "Checking models existence..."ls -la models/echo "Starting FastAPI application in background..."uvicorn hopcroft_skill_classification_tool_competition.main:app --host 127.0.0.1 --port 8000 >> /tmp/fastapi.log 2>&1 &# Wait for API to startecho "Waiting for API to start..."sleep 15echo "Starting Nginx reverse proxy..."# Check if nginx is in pathif ! command -v nginx &> /dev/null; thenecho "ERROR: nginx not found in PATH"exit 1finginx -c /app/nginx.conf -g "daemon off;" >> /tmp/nginx_startup.log 2>&1 &echo "Waiting for Nginx to initialize..."sleep 5# Check if Nginx is runningif ps aux | grep -v grep | grep -q "nginx"; thenecho "Nginx is running."elseecho "ERROR: Nginx failed to start. Logs:"cat /tmp/nginx_startup.log# Try to start it without the config to see if it's a binary issue# nginx -vfiecho "Starting Streamlit application..."export API_BASE_URL="http://127.0.0.1:8000"
Dockerfile+1
nginx.conf+10-8
scripts/start_space.sh+22-4