FROM python:3.12-slim-bullseye as build

ENV PIP_DEFAULT_TIMEOUT=100 \
    PYTHONUNBUFFERED=1 \
    PIP_DISABLE_PIP_VERSION_CHECK=1 \
    PIP_NO_CACHE_DIR=1

WORKDIR /app

COPY requirements.* ./
COPY terraform /bin

RUN pip install --no-cache-dir -r requirements.txt
RUN ansible-galaxy collection install -fr requirements.yml
RUN chmod 755 /bin/terraform

COPY ./app ./

EXPOSE 80

CMD ["gunicorn", "main:portal", "--workers", "4", "--worker-class", "uvicorn.workers.UvicornWorker", "--bind", "0.0.0.0:80"]
