FROM eclipse-temurin:11-jdk-alpine

# install system-level utilities
RUN apk add --no-cache curl vim git

# configure & install maven
ENV MAVEN_VERSION 3.5.4
ENV MAVEN_HOME /usr/lib/mvn
ENV PATH $MAVEN_HOME/bin:$PATH

RUN wget http://archive.apache.org/dist/maven/maven-3/$MAVEN_VERSION/binaries/apache-maven-$MAVEN_VERSION-bin.tar.gz && \
  tar -zxvf apache-maven-$MAVEN_VERSION-bin.tar.gz && \
  rm apache-maven-$MAVEN_VERSION-bin.tar.gz && \
  mv apache-maven-$MAVEN_VERSION /usr/lib/mvn

# clone escrito git repo and remove pulled parent pom.xml
RUN git clone https://github.com/catalpa-cl/escrito.git /escrito && \
    rm /escrito/de.unidue.ltl.escrito/pom.xml
# copy pom.xml from host
COPY pom.xml /escrito/de.unidue.ltl.escrito
# compy local.models package from host
COPY ./local /escrito/de.unidue.ltl.escrito/de.unidue.ltl.escrito.examples/src/main/java/de/unidue/ltl/escrito/examples/local
# compy some more directories from host
COPY ./dkpro_target /dkpro_target
COPY ./.m2 /.m2
COPY ./scripts /scripts

WORKDIR /escrito/de.unidue.ltl.escrito

RUN mvn compile -Dmaven.repo.local=/.m2/repository -DskipTests -e

WORKDIR /

ENTRYPOINT ["/bin/sh", "-c", "while true; do sleep 1; done"] # infinite loop