FROM openjdk:19-jdk-alpine
# With alpine images the testpod creation is ~2x faster

# Env for running simple junit5 tests

RUN apk update && apk add bash wget
WORKDIR /app


RUN wget --quiet https://repo1.maven.org/maven2/org/junit/platform/junit-platform-console-standalone/1.8.2/junit-platform-console-standalone-1.8.2.jar
RUN mkdir out


# TESTFILES_DL_URL environment variable will be added automatically in worker.
# This points to the worker's server.
RUN echo "#!/bin/bash" > start.sh
# downloads the directory with test files, compiles and runs tests with junit
RUN echo "wget -r -nH -np --reject='index.html*' --quiet \$TESTFILES_DL_URL \
&& javac -d out -cp out:junit-platform-console-standalone-1.8.2.jar *.java \
&& java -jar junit-platform-console-standalone-1.8.2.jar --class-path out --scan-class-path --disable-banner --disable-ansi-colors --details-theme=ascii" >> start.sh
RUN chmod 777 start.sh

# Running the script like so allows to avoid rebuilding the image in worker.
CMD ./start.sh