FROM python:3.10-slim WORKDIR /app COPY requirements.txt /app/requirements.txt RUN pip install --no-cache-dir --upgrade -r /app/requirements.txt COPY . /app # Create a script to set up the directory and environment variable RUN echo "#!/bin/bash" > /app/setup.sh && \ echo "mkdir -p /app/.cache" > /app/setup.sh && \ echo "export TRANSFORMERS_CACHE=/app/.cache" >> /app/setup.sh && \ chmod +x /app/setup.sh EXPOSE 7860 # Run the script as part of the CMD CMD ["/app/setup.sh", "&&", "uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]