# Dockerfile for Python API application
#
# This Dockerfile sets up a Python runtime environment with the necessary
# dependencies for running the FastAPI application. It copies the
# application code into the container, installs the required packages,
# exposes the API port, and sets the entrypoint to run the server.

# Base image
FROM python:3.12-slim

ENV PYTHONUNBUFFERED 1
ENV APP_HOME=/app

# Set the working directory in the container
WORKDIR ${APP_HOME}

# Copy only the necessary files
COPY . .

RUN apt-get clean
RUN apt -y update
RUN apt-get -y update
RUN apt-get -y upgrade --fix-missing
RUN apt-get -y install libpq-dev python3-dev gcc
RUN apt-get clean

# Install any needed packages specified in requirements.txt
RUN pip install --no-cache-dir -r /app/requirements.txt

# Expose the API port to the outside world
EXPOSE ${API_PORT}

# Set the entrypoint to run the server with auto-reload enabled
ENTRYPOINT ["python", "runserver.py", "--auto-reload-server"]
