Spaces:
Runtime error
Runtime error
Create Dockerfile
Browse files- Dockerfile +44 -0
Dockerfile
ADDED
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Use official Python slim image
|
2 |
+
FROM python:3.9-slim
|
3 |
+
|
4 |
+
# Set working directory
|
5 |
+
WORKDIR /app
|
6 |
+
|
7 |
+
# Install system dependencies for Chrome + headless operation
|
8 |
+
RUN apt-get update && apt-get install -y \
|
9 |
+
wget \
|
10 |
+
unzip \
|
11 |
+
xvfb \
|
12 |
+
libgtk-3-0 \
|
13 |
+
libdbus-glib-1-2 \
|
14 |
+
libx11-xcb1 \
|
15 |
+
libxtst6 \
|
16 |
+
libxrandr2 \
|
17 |
+
libasound2 \
|
18 |
+
&& rm -rf /var/lib/apt/lists/*
|
19 |
+
|
20 |
+
# Copy and install Python dependencies
|
21 |
+
COPY requirements.txt .
|
22 |
+
RUN pip install --no-cache-dir -r requirements.txt
|
23 |
+
|
24 |
+
# Copy your application code
|
25 |
+
COPY . .
|
26 |
+
|
27 |
+
# Install Google Chrome
|
28 |
+
RUN wget -q -O /tmp/chrome.deb https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb \
|
29 |
+
&& apt-get update \
|
30 |
+
&& apt-get install -y /tmp/chrome.deb \
|
31 |
+
&& rm /tmp/chrome.deb
|
32 |
+
|
33 |
+
# Install matching Chromedriver
|
34 |
+
RUN CHROMEDRIVER_VERSION=$(curl -sS chromedriver.storage.googleapis.com/LATEST_RELEASE) \
|
35 |
+
&& wget -q -O /tmp/chromedriver.zip "https://chromedriver.storage.googleapis.com/${CHROMEDRIVER_VERSION}/chromedriver_linux64.zip" \
|
36 |
+
&& unzip /tmp/chromedriver.zip -d /usr/local/bin/ \
|
37 |
+
&& chmod +x /usr/local/bin/chromedriver \
|
38 |
+
&& rm /tmp/chromedriver.zip
|
39 |
+
|
40 |
+
# Expose port for FastAPI ping
|
41 |
+
EXPOSE 7860
|
42 |
+
|
43 |
+
# Launch the FastAPI app on container start
|
44 |
+
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
|