diff --git a/exomiser-cli/exomiser b/exomiser-cli/exomiser new file mode 100644 index 000000000..55212607d --- /dev/null +++ b/exomiser-cli/exomiser @@ -0,0 +1,71 @@ +#!/bin/bash + +# ========================================== +# Exomiser executable launch script +# ========================================== + +# Determine the Java command to use to start the JVM. +if [[ -n "$EXOMISER_JAVA_HOME" ]]; then + JAVA_CMD="$EXOMISER_JAVA_HOME/bin/java" +elif [[ -n "$JAVA_HOME" ]]; then + JAVA_CMD="$JAVA_HOME/bin/java" +elif [ -x /usr/libexec/java_home ]; then + JAVA_CMD="$(/usr/libexec/java_home -v 17+ 2>/dev/null)/bin/java" || JAVA_CMD=java +else + JAVA_CMD="$(which java)" || JAVA_CMD=java +fi + +if [ ! -x "$JAVA_CMD" ] && ! command -v "$JAVA_CMD" &> /dev/null; then + echo "ERROR: Cannot find 'java'. Please make sure Java 17+ is installed." >&2 + exit 1 +fi + +declare -a JVM_OPTS=() +declare -a ARGS=() + +# Parse command line arguments to split JVM options from Exomiser arguments +while [[ $# -gt 0 ]]; do + case $1 in + -D*|-X*) + JVM_OPTS+=("$1") + ;; + *) + ARGS+=("$1") + ;; + esac + shift +done + +# Mix in global JAVA_OPTS and EXOMISER_OPTS if they are set +if [[ -n "$JAVA_OPTS" ]]; then + read -a GLOBAL_JAVA_OPTS <<< "$JAVA_OPTS" + JVM_OPTS+=("${GLOBAL_JAVA_OPTS[@]}") +fi +if [[ -n "$EXOMISER_OPTS" ]]; then + read -a GLOBAL_EXO_OPTS <<< "$EXOMISER_OPTS" + JVM_OPTS+=("${GLOBAL_EXO_OPTS[@]}") +fi + +# Determine the path to the jar +# It could be explicitly defined by EXOMISER_JAR +if [ -z "$EXOMISER_JAR" ]; then + # Default location inside the Docker container + if [ -f "/app/exomiser-cli.jar" ]; then + EXOMISER_JAR="/app/exomiser-cli.jar" + else + # Fallback: resolve relative to this script + SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" + if [ -f "$SCRIPT_DIR/../exomiser-cli.jar" ]; then + EXOMISER_JAR="$SCRIPT_DIR/../exomiser-cli.jar" + elif [ -f "$SCRIPT_DIR/exomiser-cli.jar" ]; then + EXOMISER_JAR="$SCRIPT_DIR/exomiser-cli.jar" + else + echo "ERROR: Cannot find exomiser-cli.jar." >&2 + echo "Please set EXOMISER_JAR to the location of the jar file." >&2 + exit 1 + fi + fi +fi + +# Execute the application +exec "$JAVA_CMD" "${JVM_OPTS[@]}" -jar "$EXOMISER_JAR" "${ARGS[@]}" diff --git a/exomiser-cli/exomiser-bash.dockerfile b/exomiser-cli/exomiser-bash.dockerfile new file mode 100644 index 000000000..bb2b083f1 --- /dev/null +++ b/exomiser-cli/exomiser-bash.dockerfile @@ -0,0 +1,33 @@ +# Stage 1: Build the exomiser-cli application +FROM eclipse-temurin:21-jdk AS builder + +# Set the working directory +WORKDIR /build + +# Copy the maven wrapper and pom files +COPY mvnw . +COPY . . + +# Build and install phenix-repository to local maven repo first +RUN ./mvnw install -DskipTests -pl phenix-repository -am + +# Build only the CLI and its dependencies +RUN ./mvnw clean package -DskipTests -pl exomiser-cli -am + +# Stage 2: Create the runtime bash image +# Use eclipse-temurin:25.0.2_10-jre as requested +FROM eclipse-temurin:25.0.2_10-jre + +# Define volumes +VOLUME ["/exomiser-data", "/exomiser", "/results"] + +# Set the working directory +WORKDIR /app + +# Copy the built jar and its dependencies +COPY --from=builder /build/exomiser-cli/target/exomiser-cli-*.jar /app/exomiser-cli.jar +COPY --from=builder /build/exomiser-cli/target/lib /app/lib + +# Copy executable exomiser script and make it available on the PATH +COPY exomiser-cli/exomiser /usr/local/bin/exomiser +RUN chmod +x /usr/local/bin/exomiser diff --git a/exomiser-cli/exomiser-distroless.dockerfile b/exomiser-cli/exomiser-distroless.dockerfile new file mode 100644 index 000000000..d932fb80b --- /dev/null +++ b/exomiser-cli/exomiser-distroless.dockerfile @@ -0,0 +1,32 @@ +# Stage 1: Build the exomiser-cli application +FROM eclipse-temurin:21-jdk AS builder + +# Set the working directory +WORKDIR /build + +# Copy the maven wrapper and pom files +COPY mvnw . +COPY . . + +# Build and install phenix-repository to local maven repo first +RUN ./mvnw install -DskipTests -pl phenix-repository -am + +# Build only the CLI and its dependencies +RUN ./mvnw clean package -DskipTests -pl exomiser-cli -am + +# Stage 2: Create the runtime distroless image +# Use the base image defined in pom.xml docker.base.image +FROM gcr.io/distroless/java25-debian13@sha256:4eadd00d3bff73e6a7491dd36653c1d318ac93fb1fb2cd5eef768fd2b4238408 + +# Define volumes +VOLUME ["/exomiser-data", "/exomiser", "/results"] + +# Set the working directory +WORKDIR /app + +# Copy the built jar and its dependencies +COPY --from=builder /build/exomiser-cli/target/exomiser-cli-*.jar /app/exomiser-cli.jar +COPY --from=builder /build/exomiser-cli/target/lib /app/lib + +# Run the jar +ENTRYPOINT ["java", "-jar", "/app/exomiser-cli.jar"] diff --git a/exomiser-cli/pom.xml b/exomiser-cli/pom.xml index 2782cea93..8566b0e00 100644 --- a/exomiser-cli/pom.xml +++ b/exomiser-cli/pom.xml @@ -215,63 +215,28 @@ - com.google.cloud.tools - jib-maven-plugin + org.codehaus.mojo + exec-maven-plugin + 3.5.0 build-docker-image package - build + exec - - - ${docker.base.image} - - - - linux - arm64 - - - - - - - - linux - amd64 - - - - - - ${docker.registry}/${docker.repository}/${project.artifactId}:${project.parent.version}-bash - - - latest-bash - ${project.parent.version}-bash - - - - - /bin/bash - - - /exomiser-data - /exomiser - /results - - - - - - /entrypoint.sh - 755 - - - + docker + + build + -t + ${docker.registry}/${docker.repository}/${project.artifactId}:${project.parent.version}-bash + -t + ${docker.registry}/${docker.repository}/${project.artifactId}:latest-bash + -f + exomiser-bash.dockerfile + .. + @@ -284,48 +249,32 @@ - com.google.cloud.tools - jib-maven-plugin + org.codehaus.mojo + exec-maven-plugin + 3.5.0 build-docker-image package - build + exec - - - ${docker.base.image} - - - - linux - arm64 - - - linux - amd64 - - - - - - ${docker.registry}/${docker.repository}/${project.artifactId}:${project.parent.version} - - - latest - latest-distroless - ${project.parent.version}-distroless - - - - - /exomiser-data - /exomiser - /results - - + docker + + build + -t + ${docker.registry}/${docker.repository}/${project.artifactId}:${project.parent.version} + -t + ${docker.registry}/${docker.repository}/${project.artifactId}:latest + -t + ${docker.registry}/${docker.repository}/${project.artifactId}:latest-distroless + -t + ${docker.registry}/${docker.repository}/${project.artifactId}:${project.parent.version}-distroless + -f + exomiser-distroless.dockerfile + .. + diff --git a/exomiser-cli/src/main/jib/enable_exomiser.sh b/exomiser-cli/src/main/jib/enable_exomiser.sh deleted file mode 100755 index 8027a37bb..000000000 --- a/exomiser-cli/src/main/jib/enable_exomiser.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/bash - -# Assumes `java` is on PATH in the base image. -alias exomiser="exec java $JAVA_OPTS -cp $( cat /app/jib-classpath-file ) $( cat /app/jib-main-class-file )" diff --git a/mvnw b/mvnw old mode 100644 new mode 100755