Update Dockerfile
Browse files- Dockerfile +56 -54
Dockerfile
CHANGED
|
@@ -1,54 +1,56 @@
|
|
| 1 |
-
# Use an official Python runtime as a parent image
|
| 2 |
-
FROM python:3.10-slim
|
| 3 |
-
|
| 4 |
-
# Set environment variables
|
| 5 |
-
ENV PYTHONDONTWRITEBYTECODE 1
|
| 6 |
-
ENV PYTHONUNBUFFERED 1
|
| 7 |
-
ENV PORT 7860
|
| 8 |
-
|
| 9 |
-
# Install system dependencies for OpenCV and face_recognition
|
| 10 |
-
RUN apt-get update && apt-get install -y \
|
| 11 |
-
build-essential \
|
| 12 |
-
cmake \
|
| 13 |
-
libopenblas-dev \
|
| 14 |
-
liblapack-dev \
|
| 15 |
-
libx11-dev \
|
| 16 |
-
libgtk-3-dev \
|
| 17 |
-
libboost-python-dev \
|
| 18 |
-
python3-dev \
|
| 19 |
-
libgl1
|
| 20 |
-
libglib2.0-0 \
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
|
|
|
|
|
|
|
|
| 1 |
+
# Use an official Python runtime as a parent image
|
| 2 |
+
FROM python:3.10-slim
|
| 3 |
+
|
| 4 |
+
# Set environment variables
|
| 5 |
+
ENV PYTHONDONTWRITEBYTECODE 1
|
| 6 |
+
ENV PYTHONUNBUFFERED 1
|
| 7 |
+
ENV PORT 7860
|
| 8 |
+
|
| 9 |
+
# Install system dependencies for OpenCV and face_recognition
|
| 10 |
+
RUN apt-get update && apt-get install -y \
|
| 11 |
+
build-essential \
|
| 12 |
+
cmake \
|
| 13 |
+
libopenblas-dev \
|
| 14 |
+
liblapack-dev \
|
| 15 |
+
libx11-dev \
|
| 16 |
+
libgtk-3-dev \
|
| 17 |
+
libboost-python-dev \
|
| 18 |
+
python3-dev \
|
| 19 |
+
libgl1 \
|
| 20 |
+
libglib2.0-0 \
|
| 21 |
+
libsm6 \
|
| 22 |
+
libxext6 \
|
| 23 |
+
&& apt-get clean && rm -rf /var/lib/apt/lists/*
|
| 24 |
+
|
| 25 |
+
# Set the working directory in the container
|
| 26 |
+
WORKDIR /app
|
| 27 |
+
|
| 28 |
+
# Copy the requirements file into the container
|
| 29 |
+
COPY requirements.txt .
|
| 30 |
+
|
| 31 |
+
# Install gunicorn for production
|
| 32 |
+
RUN pip install --no-cache-dir gunicorn
|
| 33 |
+
|
| 34 |
+
# Install any needed packages specified in requirements.txt
|
| 35 |
+
RUN pip install --no-cache-dir -r requirements.txt
|
| 36 |
+
|
| 37 |
+
# Copy the rest of the application code into the container
|
| 38 |
+
COPY . .
|
| 39 |
+
|
| 40 |
+
# Ensure upload directory exists and has permissions
|
| 41 |
+
RUN mkdir -p uploads/face_encodings && chmod -R 777 uploads
|
| 42 |
+
|
| 43 |
+
# Create a non-root user (Hugging Face requirement)
|
| 44 |
+
RUN useradd -m -u 1000 user
|
| 45 |
+
USER user
|
| 46 |
+
ENV HOME=/home/user \
|
| 47 |
+
PATH=/home/user/.local/bin:$PATH
|
| 48 |
+
|
| 49 |
+
WORKDIR $HOME/app
|
| 50 |
+
COPY --chown=user . $HOME/app
|
| 51 |
+
|
| 52 |
+
# Expose the port the app runs on
|
| 53 |
+
EXPOSE 7860
|
| 54 |
+
|
| 55 |
+
# Define the command to run the application
|
| 56 |
+
CMD ["gunicorn", "--bind", "0.0.0.0:7860", "app:app", "--timeout", "120"]
|