Spaces:
Running
Running
Update Dockerfile
Browse files- Dockerfile +38 -31
Dockerfile
CHANGED
@@ -1,31 +1,38 @@
|
|
1 |
-
# Use an official Python runtime as a parent image
|
2 |
-
FROM python:3.10-slim
|
3 |
-
|
4 |
-
# Set the working directory in the container
|
5 |
-
WORKDIR /app
|
6 |
-
|
7 |
-
# Copy the requirements file into the container at /app
|
8 |
-
COPY requirements.txt .
|
9 |
-
|
10 |
-
# Install any needed system dependencies (if any - bs4, requests usually don't need much)
|
11 |
-
# RUN apt-get update && apt-get install -y --no-install-recommends some-package && rm -rf /var/lib/apt/lists/*
|
12 |
-
# For this bot, we likely don't need extra apt packages currently.
|
13 |
-
|
14 |
-
# Install Python dependencies
|
15 |
-
# Using --no-cache-dir reduces image size slightly
|
16 |
-
RUN pip install --no-cache-dir -r requirements.txt
|
17 |
-
|
18 |
-
#
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
#
|
29 |
-
|
30 |
-
|
31 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Use an official Python runtime as a parent image
|
2 |
+
FROM python:3.10-slim
|
3 |
+
|
4 |
+
# Set the working directory in the container
|
5 |
+
WORKDIR /app
|
6 |
+
|
7 |
+
# Copy the requirements file into the container at /app
|
8 |
+
COPY requirements.txt .
|
9 |
+
|
10 |
+
# Install any needed system dependencies (if any - bs4, requests usually don't need much)
|
11 |
+
# RUN apt-get update && apt-get install -y --no-install-recommends some-package && rm -rf /var/lib/apt/lists/*
|
12 |
+
# For this bot, we likely don't need extra apt packages currently.
|
13 |
+
|
14 |
+
# Install Python dependencies
|
15 |
+
# Using --no-cache-dir reduces image size slightly
|
16 |
+
RUN pip install --no-cache-dir -r requirements.txt
|
17 |
+
|
18 |
+
# Install crawl4ai dependencies (Playwright browsers)
|
19 |
+
# Needs to run *after* pip install and requires system dependencies installed by playwright itself
|
20 |
+
# Using --with-deps installs necessary browser dependencies like fonts, libs etc.
|
21 |
+
RUN crawl4ai-setup
|
22 |
+
RUN python -m playwright install --with-deps chromium
|
23 |
+
|
24 |
+
# Copy the rest of the application code into the container at /app
|
25 |
+
COPY . .
|
26 |
+
|
27 |
+
# Make port defined by PORT env var (default 7860) available
|
28 |
+
# Hugging Face Spaces typically expect apps to run on port 7860
|
29 |
+
EXPOSE ${PORT:-7860}
|
30 |
+
|
31 |
+
# Define environment variable to ensure Python output is sent straight to logs
|
32 |
+
ENV PYTHONUNBUFFERED=1
|
33 |
+
|
34 |
+
# Command to run the application using Gunicorn
|
35 |
+
# It will run the Starlette 'app' object found in the 'main' module (main.py)
|
36 |
+
# Listen on all interfaces (0.0.0.0) on the port specified by HF/env var (usually 7860)
|
37 |
+
# Using environment variable expansion for port binding
|
38 |
+
CMD ["gunicorn", "-k", "uvicorn.workers.UvicornWorker", "--bind", "0.0.0.0:${PORT:-7860}", "main:app"]
|