# Photon (Komoot) over the OpenStreetMap extract of ONE country, ready to serve
# GET /api?q=... . The search index is NOT built here: it is downloaded
# prebuilt (see entrypoint.sh), which turns hours of import into a download.
#
# UNTESTED REFERENCE: written against the Photon README at the time of writing
# and not run in this repository's CI. Check PHOTON_VERSION and INDEX_URL
# against https://github.com/komoot/photon before the first build.
FROM eclipse-temurin:21-jre

ARG PHOTON_VERSION=1.0.0
RUN apt-get update \
 && apt-get install -y --no-install-recommends curl lbzip2 tar ca-certificates \
 && rm -rf /var/lib/apt/lists/* \
 && mkdir -p /opt/photon /photon \
 && curl -fsSL -o /opt/photon/photon.jar \
      "https://github.com/komoot/photon/releases/download/${PHOTON_VERSION}/photon-${PHOTON_VERSION}.jar" \
 && useradd --system --home /photon photon \
 && chown -R photon /photon

COPY entrypoint.sh /opt/photon/entrypoint.sh
RUN chmod +x /opt/photon/entrypoint.sh
USER photon
VOLUME /photon
EXPOSE 2322
ENTRYPOINT ["/opt/photon/entrypoint.sh"]
