Spaces:
Runtime error
Runtime error
# Step 1: Use an official Python base image | |
FROM python:3.9-slim | |
# Step 2: Set environment variables to prevent Python from writing .pyc files and to ensure the app runs in the background | |
ENV PYTHONDONTWRITEBYTECODE 1 | |
ENV PYTHONUNBUFFERED 1 | |
# Step 3: Set environment variables for torch cache directory and disable caching | |
ENV TORCH_HOME=/app/.cache | |
ENV TORCH_HUB_NO_CACHE=1 | |
# Step 4: Install system dependencies | |
RUN apt-get update && apt-get install -y \ | |
gcc \ | |
g++ \ | |
make \ | |
libgl1-mesa-glx \ | |
libglib2.0-0 \ | |
&& rm -rf /var/lib/apt/lists/* | |
# Step 5: Set the working directory inside the container | |
WORKDIR /app | |
# Step 6: Create the cache directory and ensure it's writable | |
RUN mkdir -p /app/.cache && chmod -R 777 /app/.cache | |
# Step 7: Copy the requirements file into the container | |
COPY requirements.txt /app/ | |
# Step 8: Install the Python dependencies | |
RUN pip install --no-cache-dir -r requirements.txt | |
# Step 9: Copy the rest of the application files into the container | |
COPY . /app/ | |
# Step 10: Expose the port that the Flask app will run on | |
EXPOSE 5000 | |
# Step 11: Set the entry point to start the Flask application | |
CMD ["python", "app.py"] | |