# Use Python 3.12 slim image as base FROM python:3.12-slim # Set working directory WORKDIR /code # Copy requirements first to leverage Docker cache COPY requirements.txt . # Install dependencies RUN pip install --no-cache-dir -r requirements.txt # Create necessary directories and set permissions RUN mkdir -p /code/logs /code/hf_cache /code/app/.cache /code/models \ && chmod 777 /code/logs /code/hf_cache /code/app/.cache /code/models # Copy the application code COPY ./app /code/app COPY ./utils /code/utils # Set environment variables ENV PYTHONPATH=/app ENV PYTHONUNBUFFERED=1 ENV HF_HOME=/code/hf_cache # Expose the port (Hugging Face API runs on 7680) EXPOSE 7680 # Command to run the application CMD ["python", "-m", "app.main"]