Spaces:
Sleeping
Sleeping
# Use Python as the base image | |
FROM python:3.8 | |
# Set the working directory | |
WORKDIR /app | |
# Copy the project files | |
COPY . /app | |
# Ensure writable directories exist at build time | |
RUN mkdir -p /app/static && chmod -R 777 /app/static | |
# Install system dependencies for OpenCV, GL, and FontConfig | |
RUN apt-get update && apt-get install -y \ | |
libgl1-mesa-glx \ | |
libglib2.0-0 \ | |
fontconfig && \ | |
rm -rf /var/lib/apt/lists/* # Clean up to reduce image size | |
# Set environment variables to fix Matplotlib cache errors | |
ENV MPLCONFIGDIR=/app/matplotlib_cache | |
RUN mkdir -p /app/matplotlib_cache && chmod -R 777 /app/matplotlib_cache | |
# Install Python dependencies | |
RUN pip install --no-cache-dir -r requirements.txt | |
# Expose port 7860 | |
EXPOSE 7860 | |
# Run the Flask app | |
CMD ["python", "app.py"] | |