Spaces:
Sleeping
Sleeping
fix: OpenCV libs
Browse files- Dockerfile +33 -10
Dockerfile
CHANGED
|
@@ -1,16 +1,39 @@
|
|
| 1 |
-
|
|
|
|
| 2 |
|
| 3 |
-
#
|
| 4 |
-
|
|
|
|
| 5 |
|
| 6 |
-
#
|
| 7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
|
| 9 |
-
#
|
| 10 |
-
RUN
|
| 11 |
|
| 12 |
-
#
|
| 13 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
|
| 15 |
# Run the application
|
| 16 |
-
|
|
|
|
| 1 |
+
# Base image: python:3.11.7-slim-bookworm
|
| 2 |
+
FROM python:3.11.7-slim-bookworm
|
| 3 |
|
| 4 |
+
# Set environment variables
|
| 5 |
+
ENV CLOUD_HOME=/home/user \
|
| 6 |
+
PATH=/home/user/.local/bin:$PATH
|
| 7 |
|
| 8 |
+
# Install libgl1-mesa-glx for opencv
|
| 9 |
+
RUN apt-get update -y
|
| 10 |
+
RUN apt install libgl1-mesa-glx -y
|
| 11 |
+
RUN apt-get install 'ffmpeg'\
|
| 12 |
+
'libsm6'\
|
| 13 |
+
'libxext6' -y
|
| 14 |
|
| 15 |
+
# Setup new user named user with UID 1000
|
| 16 |
+
RUN useradd -m -u 1000 user
|
| 17 |
|
| 18 |
+
# Define working directory
|
| 19 |
+
WORKDIR $CLOUD_HOME/app
|
| 20 |
+
|
| 21 |
+
# Switch to user
|
| 22 |
+
USER user
|
| 23 |
+
|
| 24 |
+
# Copy requirements.txt to the image
|
| 25 |
+
COPY --chown=user:user ./requirements.txt /app/requirements.txt
|
| 26 |
+
|
| 27 |
+
# Install python dependencies
|
| 28 |
+
RUN pip install --no-cache-dir --upgrade pip
|
| 29 |
+
RUN pip install --user -r /app/requirements.txt
|
| 30 |
+
|
| 31 |
+
# Copy the rest of the code to the image
|
| 32 |
+
COPY --chown=user:user . $CLOUD_HOME/app
|
| 33 |
+
|
| 34 |
+
# Expose port 7860
|
| 35 |
+
EXPOSE 7860/tcp
|
| 36 |
+
EXPOSE 7860/udp
|
| 37 |
|
| 38 |
# Run the application
|
| 39 |
+
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]
|