Spaces:
Runtime error
Runtime error
File size: 964 Bytes
8cdef72 ba43a18 8cdef72 ba43a18 8cdef72 ba43a18 ad901ae ba43a18 ad901ae ba43a18 247f998 3fc6ddb 8cdef72 247f998 |
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 30 31 32 33 34 35 36 37 38 39 |
# Use lightweight Python image
FROM python:3.10-slim
# Set working directory
WORKDIR /app
# Install system dependencies (git needed for Hugging Face)
RUN apt-get update && apt-get install -y git && rm -rf /var/lib/apt/lists/*
# Copy requirements and install
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
# Copy application code
COPY . .
# # Set environment variables for cache dirs (Docker-friendly)
# ENV HF_HOME=/tmp
# ENV TRANSFORMERS_CACHE=/tmp
# ENV TORCHINDUCTOR_CACHE_DIR=/tmp/torch_inductor_cache
# # Create cache folder
# RUN mkdir -p /tmp/torch_inductor_cache
# Add a user
RUN useradd -m -u 1000 appuser
USER appuser
WORKDIR /app
# Set env variables for torch caches
ENV TORCH_HOME=/tmp/torch_home
ENV TORCHINDUCTOR_CACHE_DIR=/tmp/torch_inductor_cache
RUN mkdir -p /tmp/torch_home /tmp/torch_inductor_cache
# Expose port
EXPOSE 7860
# Start FastAPI
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]
|