Spaces:
Paused
Paused
fix: Simplify HF Dockerfile - remove nginx/supervisor, FastAPI only
Browse files- huggingface/Dockerfile +27 -72
- huggingface/nginx.conf +0 -95
- huggingface/supervisord.conf +0 -21
huggingface/Dockerfile
CHANGED
|
@@ -1,91 +1,46 @@
|
|
| 1 |
-
#
|
| 2 |
-
#
|
| 3 |
-
# Simplified: FastAPI + Static Frontend on Port 7860
|
| 4 |
-
# ==========================================
|
| 5 |
|
| 6 |
-
FROM
|
| 7 |
-
|
| 8 |
-
LABEL maintainer="SATWARE AG <info@satware.com>"
|
| 9 |
-
LABEL description="SAAP - satware Autonomous Agent Platform"
|
| 10 |
|
| 11 |
-
|
| 12 |
-
# System Dependencies (incl. Nginx + Supervisor)
|
| 13 |
-
# ==========================================
|
| 14 |
|
| 15 |
-
|
| 16 |
-
gcc \
|
| 17 |
-
g++ \
|
| 18 |
-
libpq-dev \
|
| 19 |
-
curl \
|
| 20 |
-
sqlite3 \
|
| 21 |
-
nginx \
|
| 22 |
-
supervisor \
|
| 23 |
-
&& curl -fsSL https://deb.nodesource.com/setup_20.x | bash - \
|
| 24 |
-
&& apt-get install -y nodejs \
|
| 25 |
-
&& rm -rf /var/lib/apt/lists/*
|
| 26 |
-
|
| 27 |
-
# ==========================================
|
| 28 |
-
# Build Frontend
|
| 29 |
-
# ==========================================
|
| 30 |
-
|
| 31 |
-
WORKDIR /build/frontend
|
| 32 |
-
|
| 33 |
-
# Copy frontend package files
|
| 34 |
COPY frontend/package*.json ./
|
|
|
|
| 35 |
|
| 36 |
-
# Install frontend dependencies
|
| 37 |
-
RUN npm ci --legacy-peer-deps
|
| 38 |
-
|
| 39 |
-
# Copy frontend source
|
| 40 |
COPY frontend/ ./
|
| 41 |
-
|
| 42 |
-
# Build frontend (creates dist/ folder)
|
| 43 |
RUN npm run build
|
| 44 |
|
| 45 |
-
# ==========================================
|
| 46 |
-
#
|
| 47 |
-
# ==========================================
|
|
|
|
| 48 |
|
| 49 |
WORKDIR /app
|
| 50 |
|
| 51 |
-
#
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
|
|
|
| 55 |
|
| 56 |
-
# Copy backend
|
| 57 |
COPY backend/ ./backend/
|
|
|
|
| 58 |
|
| 59 |
-
#
|
| 60 |
-
RUN
|
| 61 |
-
cp -r /build/frontend/dist/* /app/backend/static/
|
| 62 |
-
|
| 63 |
-
# Create necessary directories
|
| 64 |
-
RUN mkdir -p /app/backend/logs /app/data/db /var/log/supervisor && \
|
| 65 |
-
chmod -R 755 /app
|
| 66 |
-
|
| 67 |
-
# ==========================================
|
| 68 |
-
# Configuration
|
| 69 |
-
# ==========================================
|
| 70 |
|
| 71 |
-
# Copy
|
| 72 |
-
|
| 73 |
-
COPY nginx.conf /etc/nginx/nginx.conf
|
| 74 |
-
COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf
|
| 75 |
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
DATABASE_URL=sqlite:////app/data/db/saap.db \
|
| 80 |
-
ENVIRONMENT=production \
|
| 81 |
-
LOG_LEVEL=INFO \
|
| 82 |
-
PORT=7860
|
| 83 |
|
|
|
|
| 84 |
EXPOSE 7860
|
| 85 |
|
| 86 |
-
#
|
| 87 |
-
|
| 88 |
-
CMD curl -f http://localhost:7860/health || exit 1
|
| 89 |
-
|
| 90 |
-
# Start supervisor (manages both backend + nginx)
|
| 91 |
-
CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/conf.d/supervisord.conf"]
|
|
|
|
| 1 |
+
# SAAP - Simple Hugging Face Deployment
|
| 2 |
+
# FastAPI serves both backend API and frontend static files
|
|
|
|
|
|
|
| 3 |
|
| 4 |
+
FROM node:20-slim AS frontend-builder
|
|
|
|
|
|
|
|
|
|
| 5 |
|
| 6 |
+
WORKDIR /app/frontend
|
|
|
|
|
|
|
| 7 |
|
| 8 |
+
# Copy frontend files
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
COPY frontend/package*.json ./
|
| 10 |
+
RUN npm ci --only=production
|
| 11 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
COPY frontend/ ./
|
|
|
|
|
|
|
| 13 |
RUN npm run build
|
| 14 |
|
| 15 |
+
# ============================================
|
| 16 |
+
# Python Backend + Serve Frontend
|
| 17 |
+
# ============================================
|
| 18 |
+
FROM python:3.11-slim
|
| 19 |
|
| 20 |
WORKDIR /app
|
| 21 |
|
| 22 |
+
# Install system dependencies
|
| 23 |
+
RUN apt-get update && apt-get install -y --no-install-recommends \
|
| 24 |
+
gcc \
|
| 25 |
+
libpq-dev \
|
| 26 |
+
&& rm -rf /var/lib/apt/lists/*
|
| 27 |
|
| 28 |
+
# Copy backend
|
| 29 |
COPY backend/ ./backend/
|
| 30 |
+
COPY requirements.txt ./
|
| 31 |
|
| 32 |
+
# Install Python dependencies
|
| 33 |
+
RUN pip install --no-cache-dir -r requirements.txt
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 34 |
|
| 35 |
+
# Copy built frontend from builder
|
| 36 |
+
COPY --from=frontend-builder /app/frontend/dist ./frontend/dist
|
|
|
|
|
|
|
| 37 |
|
| 38 |
+
# Environment variables
|
| 39 |
+
ENV PYTHONUNBUFFERED=1
|
| 40 |
+
ENV PORT=7860
|
|
|
|
|
|
|
|
|
|
|
|
|
| 41 |
|
| 42 |
+
# Expose port
|
| 43 |
EXPOSE 7860
|
| 44 |
|
| 45 |
+
# Start FastAPI (serves both API and frontend)
|
| 46 |
+
CMD ["uvicorn", "backend.main:app", "--host", "0.0.0.0", "--port", "7860"]
|
|
|
|
|
|
|
|
|
|
|
|
huggingface/nginx.conf
DELETED
|
@@ -1,95 +0,0 @@
|
|
| 1 |
-
# SAAP Nginx Configuration for HuggingFace Spaces
|
| 2 |
-
# Single-container deployment with Vue.js frontend + FastAPI backend
|
| 3 |
-
|
| 4 |
-
worker_processes auto;
|
| 5 |
-
error_log /var/log/nginx/error.log warn;
|
| 6 |
-
pid /tmp/nginx.pid;
|
| 7 |
-
|
| 8 |
-
events {
|
| 9 |
-
worker_connections 1024;
|
| 10 |
-
}
|
| 11 |
-
|
| 12 |
-
http {
|
| 13 |
-
include /etc/nginx/mime.types;
|
| 14 |
-
default_type application/octet-stream;
|
| 15 |
-
|
| 16 |
-
# Logging
|
| 17 |
-
access_log /var/log/nginx/access.log;
|
| 18 |
-
|
| 19 |
-
# Performance
|
| 20 |
-
sendfile on;
|
| 21 |
-
tcp_nopush on;
|
| 22 |
-
tcp_nodelay on;
|
| 23 |
-
keepalive_timeout 65;
|
| 24 |
-
types_hash_max_size 2048;
|
| 25 |
-
client_max_body_size 10M;
|
| 26 |
-
|
| 27 |
-
# Compression
|
| 28 |
-
gzip on;
|
| 29 |
-
gzip_vary on;
|
| 30 |
-
gzip_proxied any;
|
| 31 |
-
gzip_types text/plain text/css application/json application/javascript text/xml application/xml;
|
| 32 |
-
|
| 33 |
-
# Upstream backend
|
| 34 |
-
upstream backend {
|
| 35 |
-
server 127.0.0.1:8000;
|
| 36 |
-
}
|
| 37 |
-
|
| 38 |
-
server {
|
| 39 |
-
listen 7860;
|
| 40 |
-
server_name _;
|
| 41 |
-
|
| 42 |
-
# Root directory for static files
|
| 43 |
-
root /app/frontend/dist;
|
| 44 |
-
index index.html;
|
| 45 |
-
|
| 46 |
-
# API routes → FastAPI backend
|
| 47 |
-
location /api/ {
|
| 48 |
-
proxy_pass http://backend;
|
| 49 |
-
proxy_http_version 1.1;
|
| 50 |
-
proxy_set_header Upgrade $http_upgrade;
|
| 51 |
-
proxy_set_header Connection 'upgrade';
|
| 52 |
-
proxy_set_header Host $host;
|
| 53 |
-
proxy_set_header X-Real-IP $remote_addr;
|
| 54 |
-
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
| 55 |
-
proxy_set_header X-Forwarded-Proto $scheme;
|
| 56 |
-
proxy_cache_bypass $http_upgrade;
|
| 57 |
-
proxy_read_timeout 300s;
|
| 58 |
-
proxy_connect_timeout 75s;
|
| 59 |
-
}
|
| 60 |
-
|
| 61 |
-
# WebSocket support
|
| 62 |
-
location /ws {
|
| 63 |
-
proxy_pass http://backend;
|
| 64 |
-
proxy_http_version 1.1;
|
| 65 |
-
proxy_set_header Upgrade $http_upgrade;
|
| 66 |
-
proxy_set_header Connection "upgrade";
|
| 67 |
-
proxy_set_header Host $host;
|
| 68 |
-
proxy_set_header X-Real-IP $remote_addr;
|
| 69 |
-
proxy_read_timeout 86400;
|
| 70 |
-
}
|
| 71 |
-
|
| 72 |
-
# Health check
|
| 73 |
-
location /health {
|
| 74 |
-
proxy_pass http://backend;
|
| 75 |
-
}
|
| 76 |
-
|
| 77 |
-
# API docs
|
| 78 |
-
location ~ ^/(docs|redoc) {
|
| 79 |
-
proxy_pass http://backend;
|
| 80 |
-
}
|
| 81 |
-
|
| 82 |
-
# Frontend assets
|
| 83 |
-
location /assets/ {
|
| 84 |
-
try_files $uri =404;
|
| 85 |
-
expires 1y;
|
| 86 |
-
add_header Cache-Control "public, immutable";
|
| 87 |
-
}
|
| 88 |
-
|
| 89 |
-
# Vue.js SPA - catch all routes
|
| 90 |
-
location / {
|
| 91 |
-
try_files $uri $uri/ /index.html;
|
| 92 |
-
add_header Cache-Control "no-cache";
|
| 93 |
-
}
|
| 94 |
-
}
|
| 95 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
huggingface/supervisord.conf
DELETED
|
@@ -1,21 +0,0 @@
|
|
| 1 |
-
[supervisord]
|
| 2 |
-
nodaemon=true
|
| 3 |
-
logfile=/var/log/supervisor/supervisord.log
|
| 4 |
-
pidfile=/var/run/supervisord.pid
|
| 5 |
-
user=root
|
| 6 |
-
|
| 7 |
-
[program:backend]
|
| 8 |
-
command=uvicorn backend.main:app --host 0.0.0.0 --port 8000
|
| 9 |
-
directory=/app
|
| 10 |
-
autostart=true
|
| 11 |
-
autorestart=true
|
| 12 |
-
stderr_logfile=/var/log/backend.err.log
|
| 13 |
-
stdout_logfile=/var/log/backend.out.log
|
| 14 |
-
environment=PYTHONUNBUFFERED="1"
|
| 15 |
-
|
| 16 |
-
[program:nginx]
|
| 17 |
-
command=/usr/sbin/nginx -g "daemon off;"
|
| 18 |
-
autostart=true
|
| 19 |
-
autorestart=true
|
| 20 |
-
stderr_logfile=/var/log/nginx.err.log
|
| 21 |
-
stdout_logfile=/var/log/nginx.out.log
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|