Spaces:
Sleeping
Sleeping
Update Dockerfile
Browse files- Dockerfile +39 -28
Dockerfile
CHANGED
|
@@ -1,29 +1,40 @@
|
|
| 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 |
-
#
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 29 |
CMD ["python", "app.py", "--host", "0.0.0.0", "--port", "7860"]
|
|
|
|
| 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 |
+
# Install system dependencies for OpenCV and other packages
|
| 8 |
+
RUN apt-get update && apt-get install -y \
|
| 9 |
+
libgl1-mesa-glx \
|
| 10 |
+
libglib2.0-0 \
|
| 11 |
+
libsm6 \
|
| 12 |
+
libxext6 \
|
| 13 |
+
libxrender-dev \
|
| 14 |
+
libgomp1 \
|
| 15 |
+
libgthread-2.0-0 \
|
| 16 |
+
&& rm -rf /var/lib/apt/lists/*
|
| 17 |
+
|
| 18 |
+
# Copy the requirements file
|
| 19 |
+
COPY requirements.txt requirements.txt
|
| 20 |
+
|
| 21 |
+
# Install Python packages
|
| 22 |
+
RUN pip install --no-cache-dir -r requirements.txt
|
| 23 |
+
|
| 24 |
+
# Copy application code
|
| 25 |
+
COPY . /app
|
| 26 |
+
|
| 27 |
+
# Create a non-root user
|
| 28 |
+
RUN useradd -m -u 1000 user
|
| 29 |
+
|
| 30 |
+
# Change ownership
|
| 31 |
+
RUN chown -R user:user /app
|
| 32 |
+
|
| 33 |
+
# Switch to the non-root user
|
| 34 |
+
USER user
|
| 35 |
+
|
| 36 |
+
# Expose the port Gunicorn will run on (Using 7860 as in CMD)
|
| 37 |
+
EXPOSE 7860
|
| 38 |
+
|
| 39 |
+
# Command to run the app
|
| 40 |
CMD ["python", "app.py", "--host", "0.0.0.0", "--port", "7860"]
|