# The PD4ML conversion service: the base image (pd4ml-service-base) plus the engine you choose.
#
#   docker build -f engine.Dockerfile -t pd4ml-service --build-arg PD4ML_ENGINE=java .
#   docker build -f engine.Dockerfile -t pd4ml-service --build-arg PD4ML_ENGINE=dotnet .
#   docker build -t pd4ml-service --build-arg PD4ML_ENGINE=java https://pd4ml.com/docker/engine.Dockerfile
#
# PD4ML_VERSION: an engine version (default: the newest 4.2.0+ release, else the newest snapshot).
# BASE: the base image (default pd4ml-service-base:latest - docker load it from pd4ml-service-base-latest.tar.gz).
# Rebuild this to update the engine; the base stays.
ARG BASE=pd4ml-service-base:latest
FROM ${BASE}
ARG PD4ML_ENGINE=java
ARG PD4ML_VERSION=
# The repositories' indexes: when a new PD4ML build is published they change, and Docker's build cache
# no longer reuses the engine step below - without them a rebuild kept the first build's engine for good.
ADD https://pd4ml.tech/maven2/com/pd4ml/pd4ml/maven-metadata.xml /tmp/pd4ml-maven-metadata.xml
ADD https://pd4ml.com/v3-eval/dotnet/ /tmp/pd4ml-dotnet-index.html
RUN pd4ml-install "$PD4ML_ENGINE" "$PD4ML_VERSION" \
 && rm -f /tmp/pd4ml-maven-metadata.xml /tmp/pd4ml-dotnet-index.html
LABEL com.pd4ml.engine="${PD4ML_ENGINE}"
ENV PD4ML_ENGINE=${PD4ML_ENGINE}
