# The ogr image is based on ubuntu 20.04 because later ubuntu versions do
# not have libgdal-java
# So this image needs to install everything needed for riskscape and ogr
FROM harbor.catalyst.net.nz/catalyst/ubuntu:20.04

# Dockerfile for building and running an example riskscape cli variant with:
# - ogr

# Install library deps
RUN apt-get update && \
    apt-get install -y openjdk-17-jdk-headless gdal-bin libgdal-java && \
    rm -rf /var/lib/apt/lists/*

# Install riskscape
RUN mkdir /opt/riskscape-cli
COPY engine/app/build/install/riskscape /opt/riskscape-cli
RUN ln -s /opt/riskscape-cli/bin/riskscape /usr/bin/riskscape

RUN mkdir -p /home/riskscape
WORKDIR /home/riskscape

# Link the system install gdal.jar into the ogr plugin. The OGR plugin need
# a gdal.jar that matches the gdal library that is actually installed, so best
# to use the jar from that library
RUN ln -s /usr/share/java/gdal.jar /opt/riskscape-cli/plugins-optional/ogr/

# Link the OGR plugin into plugins. This image needs to have the ogr plugin
# enabled by default
RUN ln -s /opt/riskscape-cli/plugins-optional/ogr /opt/riskscape-cli/plugins/


ENTRYPOINT ["/opt/riskscape-cli/bin/riskscape"]
CMD ["--help"]
