# Use an official Python runtime as the base image FROM python:3.8-slim # Prevent Python from writing .pyc files and buffering stdout/stderr ENV PYTHONDONTWRITEBYTECODE=1 ENV PYTHONUNBUFFERED=1 # Set the working directory in the container WORKDIR /app # Create multiple cache directories and set proper permissions RUN mkdir -p /app/cache && \ mkdir -p /tmp/cache && \ mkdir -p /.cache && \ chmod -R 777 /app/cache && \ chmod -R 777 /tmp/cache && \ chmod -R 777 /.cache # Set environment variables for Hugging Face cache ENV TRANSFORMERS_CACHE=/app/cache ENV HF_HOME=/app/cache ENV HUGGINGFACE_HUB_CACHE=/app/cache # Copy over the requirements file first (for better Docker layer caching) COPY requirements.txt /app/requirements.txt # Install the Python dependencies RUN pip install --upgrade pip && \ pip install --no-cache-dir -r /app/requirements.txt # Copy the rest of the application code COPY . /app # Expose the port that the app runs on EXPOSE 7860 # Command to run the application CMD ["python", "app.py"]