diff --git a/README.md b/README.md index 5f28e2e..eee405f 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,7 @@ # docker-openjdk-javafx-sbt -Docker files for OpenJDK with JavaFX and SBT +Docker files for OpenJDK with JavaFX and SBT. Inspired by https://github.com/hseeberger/scala-sbt/ but simpler and is primarily intented for **building** your projects, eg CI and so on. + +There are three options: +- image-amazon = [Amazon Corretto](https://docs.aws.amazon.com/corretto/latest/corretto-8-ug/docker-install.html) (which already includes OpenJFX) + SBT +- image-debian = pure Debian + OpenJDK JDK + OpenJFX + SBT, **recommended** +- image-openjdk = similar to image-debian but based on official openjdk image, however OpenJFX installation is hacky diff --git a/image-amazon/Dockerfile b/image-amazon/Dockerfile new file mode 100644 index 0000000..09460ed --- /dev/null +++ b/image-amazon/Dockerfile @@ -0,0 +1,25 @@ +# Amazon Corretto 8 provides JavaFX out-of-the-box +FROM amazoncorretto:8u222 + +# The following is inspired by https://github.com/hseeberger/scala-sbt/blob/master/oracle/Dockerfile +ENV SCALA_VERSION 2.13.0 +ENV SBT_VERSION 1.3.0 + +# Install sbt +RUN \ + curl -L -o /root/sbt-${SBT_VERSION}.rpm https://bintray.com/sbt/rpm/download_file?file_path=sbt-${SBT_VERSION}.rpm && \ + yum install -y /root/sbt-${SBT_VERSION}.rpm && \ + yum clean all && \ + rm /root/sbt-${SBT_VERSION}.rpm + +# Prepare sbt and Scala, verify compilation including JavaFX classes +WORKDIR /root/dummy +RUN \ + mkdir -p project && \ + echo "scalaVersion := \"${SCALA_VERSION}\"" > build.sbt && \ + echo "sbt.version=${SBT_VERSION}" > project/build.properties && \ + echo -e 'import java.nio.file.Path\nimport javafx.application.Application\ncase object Temp' > Temp.scala && \ + sbt compile && \ + rm -rf /root/dummy + +WORKDIR /root diff --git a/image-debian/Dockerfile b/image-debian/Dockerfile new file mode 100644 index 0000000..919c366 --- /dev/null +++ b/image-debian/Dockerfile @@ -0,0 +1,25 @@ +# Debian Stretch provides proper openjfx version for Java 8 +FROM buildpack-deps:stretch-scm + +# Install OpenJDK JDK and OpenJFX +RUN apt-get update && apt-get install -y --no-install-recommends openjdk-8-jdk openjfx && rm -rf /var/lib/apt/lists/* + +# The following is inspired by https://github.com/hseeberger/scala-sbt/blob/master/debian/Dockerfile +ENV SCALA_VERSION 2.13.0 +ENV SBT_VERSION 1.3.0 +RUN \ + curl -L -o /root/sbt-${SBT_VERSION}.deb https://dl.bintray.com/sbt/debian/sbt-${SBT_VERSION}.deb && \ + apt-get install -y /root/sbt-${SBT_VERSION}.deb && \ + rm /root/sbt-${SBT_VERSION}.deb + +# Prepare sbt and Scala, verify compilation including JavaFX classes +WORKDIR /root/dummy +RUN \ + mkdir -p project && \ + echo "scalaVersion := \"${SCALA_VERSION}\"" > build.sbt && \ + echo "sbt.version=${SBT_VERSION}" > project/build.properties && \ + echo 'import java.nio.file.Path\nimport javafx.application.Application\ncase object Temp' > Temp.scala && \ + sbt compile && \ + rm -rf /root/dummy + +WORKDIR /root diff --git a/image-openjdk/Dockerfile b/image-openjdk/Dockerfile new file mode 100644 index 0000000..98edf25 --- /dev/null +++ b/image-openjdk/Dockerfile @@ -0,0 +1,30 @@ +# Debian Stretch provides proper openjfx version for Java 8 +FROM openjdk:8u222-jdk-stretch + +# Install OpenJFX as per https://github.com/docker-library/openjdk/issues/158 +RUN apt-get update && apt-get install -y --no-install-recommends openjfx && rm -rf /var/lib/apt/lists/* + +# The following is inspired by https://github.com/hseeberger/scala-sbt/blob/master/debian/Dockerfile +ENV SCALA_VERSION 2.13.0 +ENV SBT_VERSION 1.3.0 +RUN \ + curl -L -o /root/sbt-${SBT_VERSION}.deb https://dl.bintray.com/sbt/debian/sbt-${SBT_VERSION}.deb && \ + apt-get install -y /root/sbt-${SBT_VERSION}.deb && \ + rm /root/sbt-${SBT_VERSION}.deb + +# Fix OpenJFX installation for local JDK +RUN \ + ln -s -t "$JAVA_HOME/jre/lib/" $(find /usr/share/java/openjfx/jre/lib/ -maxdepth 1 -type f) && \ + ln -s -t "$JAVA_HOME/jre/lib/ext/" $(find /usr/share/java/openjfx/jre/lib/ext/ -maxdepth 1 -type f) + +# Prepare sbt and Scala, verify compilation including JavaFX classes +WORKDIR /root/dummy +RUN \ + mkdir -p project && \ + echo "scalaVersion := \"${SCALA_VERSION}\"" > build.sbt && \ + echo "sbt.version=${SBT_VERSION}" > project/build.properties && \ + echo 'import java.nio.file.Path\nimport javafx.application.Application\ncase object Temp' > Temp.scala && \ + sbt compile && \ + rm -rf /root/dummy + +WORKDIR /root