# Use a lightweight Python image | |
FROM python:3.9-slim | |
# Set the working directory in the container | |
WORKDIR /app | |
# Copy the project files into the container | |
COPY . /app | |
# Install system dependencies for required Python packages | |
RUN apt-get update && apt-get install -y \ | |
libgl1 \ | |
libglib2.0-0 \ | |
&& rm -rf /var/lib/apt/lists/* | |
# Install Python dependencies | |
RUN pip install --no-cache-dir -r requirements.txt | |
# Créer le répertoire `static` s'il n'existe pas | |
RUN mkdir -p /app/tmp | |
# Modifier les permissions pour autoriser l'écriture | |
RUN chmod -R 777 /app/tmp | |
# Ajouter un utilisateur non-root (facultatif) | |
RUN useradd -ms /bin/bash appuser | |
RUN chown -R appuser:appuser /app | |
# Passer à l'utilisateur non-root | |
USER appuser | |
# Expose the port used by Flask | |
EXPOSE 7860 | |
# Command to start the application | |
CMD ["python", "app.py"] |