| # Use Python 3.10 slim image as the base image | |
| FROM python:3.10-slim | |
| # Set the working directory inside the container | |
| WORKDIR /app | |
| # Install system dependencies (optional, depending on the need for certain Python packages) | |
| RUN apt-get update && apt-get install -y build-essential git && rm -rf /var/lib/apt/lists/* | |
| # Copy all project files into the working directory | |
| COPY . . | |
| RUN useradd user | |
| USER user | |
| ENV HOME=/home/user \ | |
| PATH=/home/user/.local/bin:$PATH | |
| WORKDIR $HOME/app | |
| COPY --chown=user ./ $HOME/app | |
| RUN pip install -r requirements.txt | |
| CMD fastapi run --reload --host=0.0.0.0 --port=7860 | |