Quick Start
- Backend:
http://localhost:8000(FastAPI) - Frontend:
http://localhost:5175(Vite dev server)
Docker Compose Configuration
OpenShorts uses a two-service architecture defined indocker-compose.yml:
Service Details
Backend API server running FastAPI with Uvicorn.
- Port:
8000(mapped to host8000) - Technology: Python 3.11, FastAPI, Uvicorn
- Volume mounts: Source code hot-reload in development
- Restart policy:
unless-stoppedfor production resilience
Frontend dashboard with Vite development server and HMR.
- Port:
5173(mapped to host5175) - Technology: React 18, Vite 4, Tailwind CSS
- Volume mounts: Source code hot-reload, isolated node_modules
- Dependencies: Waits for backend to be ready
Backend Dockerfile
OpenShorts uses a multi-stage build for smaller final images and security.Stage 1: Builder
- Install build tools (gcc, g++) needed for compiling Python packages
- Create isolated virtual environment
- Compile all Python dependencies
- Build artifacts are copied to final stage (build tools are discarded)
- Smaller final image (no build toolchain)
- Faster subsequent builds (layer caching)
- Secure supply chain (pinned dependencies)
Stage 2: Final Runtime
- FFmpeg: Video processing, cutting, encoding, subtitle burning
- OpenCV deps:
libgl1,libglib2.0-0, etc. for computer vision - Node.js: Required by yt-dlp for bypassing YouTube JavaScript challenges
Non-Root User Execution
- Principle of least privilege: App runs with minimal permissions
- Container escape protection: If container is compromised, attacker has limited privileges
- File system isolation: User cannot write to system directories
/app: Application code, uploads, output files/tmp/Ultralytics: YOLOv8 model cache (required for AI cropping)
Volume Mounts Explained
Backend Volumes
- Development mode: Code changes trigger auto-reload without rebuilding
- Production mode: Remove volume mounts and bake code into image
__pycache__?
Prevents host Python cache conflicts with container Python version. Container generates its own cache.
Frontend Volumes
node_modules?
- Cross-platform compatibility: Host OS may have incompatible binaries (e.g., macOS vs Linux)
- Performance: Native container filesystem is faster than bind-mount
- Avoid conflicts: Prevents host and container dependency version mismatches
Production Deployment
Optimizations for Production
1. Remove development volumes:.env file for production:
Resource Limits
Prevent resource exhaustion:- Minimum: 2 CPU cores, 4GB RAM
- Recommended: 4 CPU cores, 8GB RAM
- High-performance: 8+ CPU cores, 16GB+ RAM
Reverse Proxy Setup
Use Nginx or Traefik for HTTPS and load balancing:Troubleshooting
Build Failures
Symptom:ERROR: failed to solve: process "/bin/sh -c pip install..." did not complete successfully
Solutions:
- Clear Docker cache:
docker builder prune -a - Check network connectivity
- Verify
requirements.txtsyntax - Increase Docker memory limit in Docker Desktop settings
Permission Denied Errors
Symptom:PermissionError: [Errno 13] Permission denied: '/app/uploads'
Solutions:
- Verify directory ownership:
ls -lainside container - Check Dockerfile
chowncommands - SELinux/AppArmor: Add
:zflag to volumes:- ./uploads:/app/uploads:z
Port Already in Use
Symptom:Error starting userland proxy: listen tcp4 0.0.0.0:8000: bind: address already in use
Solutions:
- Kill process using port:
lsof -ti:8000 | xargs kill - Change port mapping:
"8001:8000" - Stop conflicting container:
docker psthendocker stop <container>
YOLOv8 Model Not Found
Symptom:FileNotFoundError: yolov8n.pt not found
Solutions:
- Rebuild image:
docker compose build --no-cache - Verify model download step in Dockerfile
- Check
/tmp/Ultralyticspermissions
Frontend Cannot Reach Backend
Symptom:ERR_CONNECTION_REFUSED or Network Error
Solutions:
- Verify backend is running:
docker compose logs backend - Check Vite proxy config in
dashboard/vite.config.js - Use backend container name in proxy:
http://openshorts-backend:8000 - Ensure frontend
depends_on: [backend]is set