FROM registry.access.redhat.com/ubi9/python-312:latest
USER 0
RUN echo -e "[almalinux9-appstream]" \
 "\nname = almalinux9-appstream" \
 "\nbaseurl = https://repo.almalinux.org/almalinux/9/AppStream/\$basearch/os/" \
 "\nenabled = 1" \
 "\ngpgcheck = 0" > /etc/yum.repos.d/almalinux.repo

RUN dnf -y install postgresql && dnf clean all
USER 1001

COPY --chown=1001:1001 . /kai

RUN pip install --no-cache -r /kai/requirements.txt
RUN pip install --no-cache -e /kai

RUN cd /kai/samples && ./fetch_apps.py
COPY build/entrypoint.sh /usr/local/bin/entrypoint.sh
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]
