rabiyulfahim's picture
Update Dockerfile
ad901ae verified
raw
history blame contribute delete
964 Bytes
# 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"]