Spaces:
Runtime error
Runtime error
Update Dockerfile
Browse files- Dockerfile +13 -3
Dockerfile
CHANGED
|
@@ -1,21 +1,31 @@
|
|
| 1 |
FROM python:3.12-slim
|
| 2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
# Set the working directory in the container
|
| 4 |
WORKDIR /app
|
| 5 |
|
| 6 |
# Copy the requirements file into the container
|
| 7 |
COPY requirements.txt .
|
| 8 |
|
| 9 |
-
# Install all Python dependencies
|
| 10 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 11 |
|
| 12 |
# Install gunicorn to run the Flask app
|
| 13 |
RUN pip install gunicorn
|
| 14 |
|
| 15 |
# Copy all application code into the current directory (/app)
|
| 16 |
-
# This is the line that must be simple: COPY <source> <destination>
|
| 17 |
COPY . .
|
| 18 |
|
| 19 |
# Define the default command to run the application using gunicorn.
|
| 20 |
# The 'app:app' assumes your Flask app instance is named 'app' inside 'app.py'.
|
| 21 |
-
|
|
|
|
|
|
| 1 |
FROM python:3.12-slim
|
| 2 |
|
| 3 |
+
# Install system dependencies required by OpenCV (cv2)
|
| 4 |
+
# libgl1 is required for libGL.so.1
|
| 5 |
+
# libsm6 and libxext6 are also commonly needed by imaging libraries in a headless environment.
|
| 6 |
+
RUN apt-get update && \
|
| 7 |
+
apt-get install -y --no-install-recommends \
|
| 8 |
+
libgl1 \
|
| 9 |
+
libsm6 \
|
| 10 |
+
libxext6 && \
|
| 11 |
+
rm -rf /var/lib/apt/lists/*
|
| 12 |
+
|
| 13 |
# Set the working directory in the container
|
| 14 |
WORKDIR /app
|
| 15 |
|
| 16 |
# Copy the requirements file into the container
|
| 17 |
COPY requirements.txt .
|
| 18 |
|
| 19 |
+
# Install all Python dependencies, including opencv-python, which now finds its system libraries.
|
| 20 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 21 |
|
| 22 |
# Install gunicorn to run the Flask app
|
| 23 |
RUN pip install gunicorn
|
| 24 |
|
| 25 |
# Copy all application code into the current directory (/app)
|
|
|
|
| 26 |
COPY . .
|
| 27 |
|
| 28 |
# Define the default command to run the application using gunicorn.
|
| 29 |
# The 'app:app' assumes your Flask app instance is named 'app' inside 'app.py'.
|
| 30 |
+
# The port is set to 7860 as required by Hugging Face Spaces.
|
| 31 |
+
CMD exec gunicorn --bind :7860 --workers 1 --threads 8 app:app
|