sushilideaclan01 commited on
Commit
aec470c
·
1 Parent(s): b5e952c

Add Dockerfile for Hugging Face detection

Browse files
Files changed (2) hide show
  1. Dockerfile +64 -0
  2. README.md +0 -1
Dockerfile ADDED
@@ -0,0 +1,64 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Hugging Face Spaces Dockerfile
2
+ # Multi-stage build for Hugging Face deployment
3
+
4
+ # Stage 1: Build frontend
5
+ FROM node:20-alpine AS frontend-builder
6
+
7
+ WORKDIR /app/frontend
8
+
9
+ # Copy package files
10
+ COPY frontend/package*.json ./
11
+
12
+ # Install dependencies
13
+ RUN npm ci
14
+
15
+ # Copy frontend source
16
+ COPY frontend/ ./
17
+
18
+ # Build arguments for environment variables
19
+ # Hugging Face Spaces will provide the public URL
20
+ ARG VITE_API_BASE_URL
21
+ ENV VITE_API_BASE_URL=${VITE_API_BASE_URL}
22
+
23
+ # Build frontend
24
+ RUN npm run build
25
+
26
+ # Stage 2: Python backend with frontend
27
+ FROM python:3.11-slim
28
+
29
+ # Set working directory
30
+ WORKDIR /app
31
+
32
+ # Install system dependencies including ffmpeg
33
+ RUN apt-get update && \
34
+ apt-get install -y --no-install-recommends \
35
+ ffmpeg \
36
+ && rm -rf /var/lib/apt/lists/*
37
+
38
+ # Copy requirements first for better caching
39
+ COPY requirements.txt .
40
+
41
+ # Install Python dependencies
42
+ RUN pip install --no-cache-dir -r requirements.txt
43
+
44
+ # Copy application code
45
+ COPY . .
46
+
47
+ # Copy built frontend from builder stage
48
+ COPY --from=frontend-builder /app/frontend/dist ./frontend/dist
49
+
50
+ # Create storage directories
51
+ RUN mkdir -p storage/images storage/videos
52
+
53
+ # Hugging Face Spaces uses port 7860 by default
54
+ # But we'll use PORT env var if provided, or default to 7860
55
+ EXPOSE 7860
56
+
57
+ # Health check
58
+ HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
59
+ CMD python -c "import urllib.request; urllib.request.urlopen('http://localhost:7860/health')"
60
+
61
+ # Run the application
62
+ # Hugging Face Spaces provides PORT env var, default to 7860
63
+ CMD python -c "import os; port = int(os.getenv('PORT', 7860)); import uvicorn; uvicorn.run('main:app', host='0.0.0.0', port=port)"
64
+
README.md CHANGED
@@ -5,7 +5,6 @@ colorFrom: blue
5
  colorTo: purple
6
  sdk: docker
7
  sdk_version: latest
8
- app_file: Dockerfile.hf
9
  pinned: false
10
  license: mit
11
  ---
 
5
  colorTo: purple
6
  sdk: docker
7
  sdk_version: latest
 
8
  pinned: false
9
  license: mit
10
  ---