# Empty placeholder for heaserver-accounts's sdist and wheel, which the pip step below installs from when present.
# docker build --build-context dist=<dir> replaces it with <dir>; CI passes the package job's dist/.
FROM scratch AS dist

FROM registry.gitlab.com/huntsman-cancer-institute/risr/hea/hea-python-base:3.12.9
RUN useradd --create-home --uid 1000 app
WORKDIR /home/app
COPY docker-entrypoint.sh .
RUN dos2unix ./docker-entrypoint.sh
ENV HEASERVER_ACCOUNTS_URL=https://localhost:8443/api
ARG PROJECT_VERSION
# Grab heaserver-accounts and dependencies (if they're present) from ./dist.
# --no-cache-dir keeps pip's download cache out of the image.
RUN --mount=type=bind,from=dist,target=/tmp/dist \
    pip install --no-cache-dir --find-links /tmp/dist heaserver-accounts==$PROJECT_VERSION
# app's UID (see useradd above): numeric so that Kubernetes' runAsNonRoot can verify it isn't root.
USER 1000
ENTRYPOINT [ "sh", "docker-entrypoint.sh" ]
EXPOSE 8080
