Spaces:
Runtime error
Runtime error
# Use Python 3.9 slim image | |
FROM python:3.9-slim | |
# Set the working directory | |
WORKDIR /app | |
# Install system dependencies required for OpenCV, pygame, and building packages. | |
RUN apt-get update && apt-get install -y \ | |
libgl1-mesa-glx \ | |
libglib2.0-0 \ | |
gcc \ | |
libcairo2-dev \ | |
pkg-config \ | |
python3-dev \ | |
libgirepository1.0-dev \ | |
gir1.2-gtk-3.0 \ | |
libsdl2-dev \ | |
libsdl2-image-dev \ | |
libsdl2-mixer-dev \ | |
libsdl2-ttf-dev \ | |
&& rm -rf /var/lib/apt/lists/* | |
# Create a writable directory for fontconfig cache and set environment variables | |
RUN mkdir -p /tmp/fontconfig && chmod -R 777 /tmp/fontconfig | |
ENV FC_CACHEDIR=/tmp/fontconfig | |
ENV XDG_CACHE_HOME=/tmp | |
# Copy requirements.txt first to leverage Docker cache | |
COPY requirements.txt . | |
# Upgrade pip and install Python dependencies | |
RUN pip install --upgrade pip && pip install --no-cache-dir -r requirements.txt | |
# Explicitly install pygame (if not already in requirements.txt) | |
RUN pip install pygame | |
# Copy the rest of the application code into the container | |
COPY . . | |
# Expose the port (Flask default is 5000) | |
EXPOSE 5000 | |
# Command to run the application | |
CMD ["python", "app.py"] | |