# Official Python image
FROM python:3.12-slim

# Set workdir
WORKDIR /app

# Install system dependence (libmagic)
RUN apt-get update && apt-get install -y libmagic1

# Copy the file with the requirements
COPY requirements.txt .

# Install the package dependencies in the requirements file.
RUN pip install --no-cache-dir --upgrade -r requirements.txt

# Copy the FastAPI app folder in the container
COPY . .

# Expose API port
EXPOSE 80

# Runs the stub script & launches the uvicorn server (command from offical FastAPI documentation)
CMD ["sh", "-c", "python3 app/stub.py && fastapi run --port 80"]