# Use an official Python runtime as a parent image FROM python:3.11-slim # Create and switch to a new user RUN useradd -m -u 1000 user USER user ENV PATH="/home/user/.local/bin:$PATH" # Set work directory WORKDIR /app # Copy requirements COPY --chown=user ./requirements.txt requirements.txt # Install Python dependencies RUN pip install --no-cache-dir --upgrade -r requirements.txt # Copy application code COPY --chown=user . /app # Expose port for Flask EXPOSE 7860 # Start the application CMD ["python", "ai_server.py"]