TestAPI / Dockerfile
Adedoyinjames's picture
Update Dockerfile
30f15fa verified
FROM python:3.10-slim
# Prevent Python from writing .pyc files and buffer outputs
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1
# Working directory
WORKDIR /app
# Create cache directory with full permissions
RUN mkdir -p /app/.cache && chmod -R 777 /app/.cache
# Environment variables for Hugging Face caching
ENV HF_HOME=/app/.cache
ENV TRANSFORMERS_CACHE=/app/.cache
ENV HF_DATASETS_CACHE=/app/.cache
ENV XDG_CACHE_HOME=/app/.cache
# Copy and install dependencies
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
# Copy application code
COPY . .
# Expose FastAPI default port
EXPOSE 7860
# Command to run the FastAPI app via Uvicorn
CMD ["python", "app.py"]