morphis / Dockerfile.back1
jkh32499's picture
Rename Dockerfile to Dockerfile.back1
0e1b551 verified
FROM python:3.9-slim
# Install system dependencies for building PyQt5 and OpenCV
RUN apt-get update && apt-get install -y \
build-essential \
libgl1-mesa-glx \
libglib2.0-0 \
&& rm -rf /var/lib/apt/lists/*
# Install dependencies and set up the environment for dependency installation
WORKDIR /code
COPY ./requirements.txt /code/requirements.txt
RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
# Create a non-root user (with UID 1000) to avoid permission issues
RUN useradd -m -u 1000 user
USER user
ENV HOME=/home/user \
PATH=/home/user/.local/bin:$PATH
# Set up the working directory for the application
WORKDIR $HOME/app
# Create writable directories for InsightFace models and Matplotlib config
RUN mkdir -p $HOME/app/insightface_models $HOME/app/.config/matplotlib
# Set environment variables so that InsightFace and Matplotlib use the writable directories
ENV INSIGHTFACE_HOME=$HOME/app/insightface_models
ENV MPLCONFIGDIR=$HOME/app/.config/matplotlib
ENV FLASK_APP=app.py
# Copy the application code (ensuring proper ownership)
COPY --chown=user . $HOME/app
# Expose the port your Flask app will run on
EXPOSE 7890
# Command to run the Flask application
CMD ["flask", "run", "--host=0.0.0.0", "--port", "7860"]