GraziePrego commited on
Commit
361629c
·
verified ·
1 Parent(s): 246cb17

Add Dockerfile for HF Space deployment

Browse files
Files changed (1) hide show
  1. Dockerfile +45 -0
Dockerfile ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM python:3.11-slim
2
+
3
+ # Install system dependencies
4
+ RUN apt-get update && apt-get install -y \
5
+ git \
6
+ curl \
7
+ && apt-get clean \
8
+ && rm -rf /var/lib/apt/lists/*
9
+
10
+ # Set working directory
11
+ WORKDIR /app
12
+
13
+ # Install uv for fast dependency management
14
+ COPY --from=ghcr.io/astral-sh/uv:latest /uv /bin/
15
+
16
+ # Copy requirements first for better caching
17
+ COPY requirements.txt .
18
+ COPY pyproject.toml .
19
+
20
+ # Install dependencies
21
+ RUN uv pip install --system -r requirements.txt
22
+ RUN uv pip install --system -e .
23
+
24
+ # Copy the rest of the application
25
+ COPY . .
26
+
27
+ # Install Playwright browsers
28
+ RUN playwright install chromium
29
+ RUN playwright install-deps chromium
30
+
31
+ # Create non-root user
32
+ RUN useradd -m -u 1000 user && \
33
+ chown -R user:user /app
34
+
35
+ USER user
36
+
37
+ # Expose port
38
+ EXPOSE 7860
39
+
40
+ # Set environment variables
41
+ ENV PYTHONUNBUFFERED=1 \
42
+ PLAYWRIGHT_BROWSERS_PATH=/home/user/.cache/ms-playwright
43
+
44
+ # Start the FastAPI server with Gradio UI
45
+ CMD ["uvicorn", "api:app", "--host", "0.0.0.0", "--port", "7860"]