AI-API / Dockerfile
Pujan-Dev's picture
Update Dockerfile
56f6940 verified
raw
history blame contribute delete
819 Bytes
# Use the latest slim Python 3.11 image
FROM python:3.11-slim
# Set environment variables
ENV HOME=/home/user \
PATH=/home/user/.local/bin:$PATH \
PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1
# Install system dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
git \
curl \
&& rm -rf /var/lib/apt/lists/*
# Create a non-root user for safety
RUN useradd -ms /bin/bash user
USER user
WORKDIR $HOME/app
# Copy app source code
COPY --chown=user . .
# Install Python dependencies
RUN pip install --no-cache-dir --upgrade pip \
&& pip install --no-cache-dir -r requirements.txt
# Expose port
EXPOSE 7860
# Start the FastAPI app using uvicorn with 4 workers
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860", "--workers", "4"]