Hari15prasad commited on
Commit
e86a4d8
·
verified ·
1 Parent(s): 059a69a

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +41 -2
Dockerfile CHANGED
@@ -1,2 +1,41 @@
1
- FROM huggingface/autotrain-advanced:latest
2
- CMD pip uninstall -y autotrain-advanced && pip install -U autotrain-advanced && autotrain app --host 0.0.0.0 --port 7860 --workers 1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Use a multi-stage build to keep the image small
2
+ FROM node:20-alpine AS frontend-builder
3
+ WORKDIR /app/frontend
4
+ COPY frontend/package*.json ./
5
+ RUN npm install
6
+ COPY frontend/ ./
7
+ # We set the API URL to the relative path since they will share the same origin
8
+ ENV NEXT_PUBLIC_API_URL=/api
9
+ RUN npm run build
10
+
11
+ # Final stage: Python for the FastAPI backend
12
+ FROM python:3.10-slim
13
+ WORKDIR /app
14
+
15
+ # Install system dependencies
16
+ RUN apt-get update && apt-get install -y \
17
+ build-essential \
18
+ curl \
19
+ && rm -rf /var/lib/apt/lists/*
20
+
21
+ # Install Python dependencies
22
+ COPY requirements.txt .
23
+ RUN pip install --no-cache-dir -r requirements.txt
24
+ RUN pip install uvicorn gunicorn
25
+
26
+ # Copy backend code
27
+ COPY . .
28
+
29
+ # Copy built frontend to a public directory
30
+ COPY --from=frontend-builder /app/frontend/out /app/frontend_static
31
+
32
+ # Create a small script to serve the frontend and backend together
33
+ RUN echo '#!/bin/bash\n\
34
+ python -m uvicorn app:app --host 0.0.0.0 --port 7860\n\
35
+ ' > /app/start.sh
36
+ RUN chmod +x /app/start.sh
37
+
38
+ # HF Spaces uses 7860 by default
39
+ EXPOSE 7860
40
+
41
+ CMD ["/app/start.sh"]