# GNU runtime: Free release currently permits GLIBC <= 2.39, not musl/scratch.
FROM ubuntu:24.04@sha256:73b999393d07f2bf65a40373778a44dc9a6d54ad7718d29247d8ff9413c4d6a8
ARG RELEASE_SHA256
ARG RELEASE_VERSION
LABEL org.opencontainers.image.title="HOBA Free local evaluation" \
      org.opencontainers.image.version="${RELEASE_VERSION}"
RUN apt-get update && apt-get install -y --no-install-recommends \
      ca-certificates libssl3t64 libgcc-s1 curl \
    && rm -rf /var/lib/apt/lists/* \
    && groupadd --gid 10001 hoba && useradd --uid 10001 --gid hoba --no-create-home hoba \
    && install -d -m 0700 -o hoba -g hoba /var/lib/hoba \
      /var/lib/hoba/config /var/lib/hoba/media /var/lib/hoba/runtime \
    && install -d /opt/hoba
COPY release.tar.gz /tmp/release.tar.gz
RUN test "${#RELEASE_SHA256}" = 64 \
    && echo "$RELEASE_SHA256  /tmp/release.tar.gz" | sha256sum --check --status \
    && tar --extract --gzip --file /tmp/release.tar.gz --directory /opt/hoba --no-same-owner \
    && rm /tmp/release.tar.gz \
    && test -f /opt/hoba/admin/index.html && test -f /opt/hoba/composer/index.html \
    && /opt/hoba/hoba-agent --product-identity | grep -Fx '{"schema_version":1,"product":"hoba-core","mode":"product-free","arch":"x86_64","os":"linux"}' \
    && ldd /opt/hoba/hoba-agent > /opt/hoba/ldd.txt \
    && ! grep -q 'not found' /opt/hoba/ldd.txt
COPY entrypoint.sh /usr/local/bin/hoba-entrypoint
RUN chmod 0755 /usr/local/bin/hoba-entrypoint
USER 10001:10001
WORKDIR /var/lib/hoba/runtime
ENTRYPOINT ["/usr/local/bin/hoba-entrypoint"]
CMD ["serve"]
