Spaces:
Running
Running
File size: 964 Bytes
8a59b74 993ecaa cfc0aae 04d0e70 cfc0aae 8a59b74 cfc0aae 8a59b74 cfc0aae 04d0e70 cfc0aae |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
FROM python:3.9-slim
WORKDIR /code
# Redirect HF cache to /tmp/.cache for better performance
ENV HF_HOME=/tmp/.cache
ENV TRANSFORMERS_CACHE=/tmp/.cache
# Add additional environment variables for optimization
ENV PYTHONUNBUFFERED=1
ENV PYTHONDONTWRITEBYTECODE=1
# Install system dependencies if needed (uncomment if you need curl for health checks)
# RUN apt-get update && apt-get install -y curl && rm -rf /var/lib/apt/lists/*
# Copy and install Python dependencies first (better Docker layer caching)
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
# Copy the app directory with your main.py file
COPY app ./app
# Add health check to monitor container health
HEALTHCHECK --interval=30s --timeout=10s --start-period=60s --retries=3 \
CMD python -c "import requests; requests.get('http://localhost:7860/health', timeout=5)" || exit 1
# Start the application
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "7860"] |