File size: 587 Bytes
197bff9 bcede05 197bff9 bcede05 197bff9 bcede05 bc21236 7a27450 197bff9 bcede05 6cfd530 197bff9 5c20eb3 197bff9 |
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 29 |
# Use lightweight Python base
FROM python:3.10-slim
# Set working directory
WORKDIR /app
# Copy files
COPY . .
# Install dependencies
RUN pip install --no-cache-dir -r requirements.txt
# Create cache directory and make it writable for non-root
RUN mkdir -p /app/hf_cache && chmod -R 777 /app/hf_cache
# Set environment variables for Hugging Face cache
ENV HF_HOME=/app/hf_cache
ENV TRANSFORMERS_CACHE=/app/hf_cache
# Expose Space port
EXPOSE 7860
# Switch to non-root user
RUN useradd -m appuser
USER appuser
# Run Flask directly (no Gunicorn)
CMD ["python", "api_inference.py"]
|