File size: 1,011 Bytes
abd4592 333f30c 961c50b 333f30c ca0e42c 333f30c abd4592 961c50b ca0e42c abd4592 961c50b ca0e42c abd4592 ca0e42c abd4592 961c50b ca0e42c 333f30c 961c50b abd4592 333f30c abd4592 961c50b | 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 40 41 42 43 44 | FROM python:3.11-slim
# Set environment variables
ENV PYTHONUNBUFFERED=1 \
PYTHONDONTWRITEBYTECODE=1 \
PORT=7860 \
HOME=/home/user
# Create user
RUN useradd -m -u 1000 user
# Install system dependencies
RUN apt-get update && apt-get install -y \
build-essential \
curl \
libpq-dev \
ffmpeg \
git \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app
# Upgrade pip
RUN pip install --no-cache-dir --upgrade pip
# Step 1: Install CPU-only Torch first (Heavy)
# This prevents OOM by not resolving everything at once
RUN pip install --no-cache-dir torch --index-url https://download.pytorch.org/whl/cpu
# Step 2: Install remaining requirements
COPY --chown=user:user requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
# Copy everything else
COPY --chown=user:user . .
# Final permissions check
RUN chown -R 1000:1000 /app
USER user
EXPOSE 7860
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "7860"]
|