moodify_model / Dockerfile
vancyferns
updated dockerfile
583097f
# Use a lightweight official Python image as the base
FROM python:3.10-slim
# Install system-level dependencies for computer vision libraries
RUN apt-get update && apt-get install -y \
libgl1 \
libglib2.0-0 \
libsm6 \
libxext6 \
libfontconfig1 \
libxrender1 \
&& rm -rf /var/lib/apt/lists/*
# Set the working directory inside the container
WORKDIR /app
# Create a non-root user and give them ownership of the working directory
RUN useradd -m -s /bin/bash appuser
RUN chown -R appuser:appuser /app
# Switch to the new user for all subsequent commands
USER appuser
# Set the DEEPFACE_HOME environment variable to a writable directory
ENV DEEPFACE_HOME=/app
# Copy the requirements file from the 'model' directory
COPY model/requirements.txt .
# Install Python dependencies, including gunicorn
RUN pip install --no-cache-dir -r requirements.txt
# Copy the rest of the 'model' directory's contents
COPY model/ .
# Expose the port where the Flask API will run
EXPOSE 7860
# Use ENTRYPOINT to make the container run as a specific executable
# This is more reliable than CMD for a consistent startup
ENTRYPOINT ["python3", "-m", "gunicorn"]
# Define the default arguments for the ENTRYPOINT
CMD ["--bind", "0.0.0.0:7860", "app:app"]