Update Dockerfile
Browse files123456789101112131415161718192021222324252627282930# Use Python 3.10 slim image as the base imageFROM python:3.10-slim# Set the working directory inside the containerWORKDIR /app# Install system dependenciesRUN apt-get update && apt-get install -y --no-install-recommends \build-essential \git \&& rm -rf /var/lib/apt/lists/*# Create a non-root userRUN useradd -m userUSER user# Set environment variablesENV HOME=/home/user \PATH=/home/user/.local/bin:$PATH# Set up app directoryWORKDIR $HOME/appCOPY --chown=user . $HOME/app# Install Python dependenciesRUN pip install --no-cache-dir --upgrade pip \&& pip install --no-cache-dir -r requirements.txt# Run the FastAPI server using uvicornCMD ["uvicorn", "app:app", "--reload", "--host", "0.0.0.0", "--port", "7860"]123456789101112131415161718192021222324252627282930313233# Use the latest slim Python 3.11 imageFROM python:3.11-slim# Set environment variablesENV HOME=/home/user \PATH=/home/user/.local/bin:$PATH \PYTHONDONTWRITEBYTECODE=1 \PYTHONUNBUFFERED=1# Install system dependenciesRUN 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 safetyRUN useradd -ms /bin/bash userUSER userWORKDIR $HOME/app# Copy app source codeCOPY --chown=user . .# Install Python dependenciesRUN pip install --no-cache-dir --upgrade pip \&& pip install --no-cache-dir -r requirements.txt# Expose portEXPOSE 7860# Start the FastAPI app using uvicornCMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
Dockerfile+19-16