From 98c86c46344334011fa0f6296e2e58c97c436487 Mon Sep 17 00:00:00 2001 From: Louis Bergelson Date: Wed, 29 Nov 2023 15:01:23 -0500 Subject: [PATCH] Update Dockerfile and build_push_docker.sh (#1921) * This adjust for the lack of picard cloud jar and properly sets the picard version so it's not listed as "snapshot" * Update the docker build to use staged builds. This reduces the build size from about 1.7gb to about 650mb --- Dockerfile | 46 +++++++++++++++++++++++++------------------- build_push_docker.sh | 2 +- 2 files changed, 27 insertions(+), 21 deletions(-) diff --git a/Dockerfile b/Dockerfile index 15a5768eed..dea43070fb 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,31 +1,37 @@ -FROM eclipse-temurin:17-jdk -MAINTAINER Broad Institute DSDE +ARG BASE_DOCKER=eclipse-temurin:17-jdk +ARG release=false -ARG build_command=shadowJar -ARG jar_name=picard.jar +FROM ${BASE_DOCKER} as build +LABEL stage=buildStage -# Install ant, git for building +# Install git for building RUN apt-get update && \ apt-get --no-install-recommends install -y \ - git \ - r-base \ - ant && \ - apt-get clean autoclean && \ - apt-get autoremove -y + git # Assumes Dockerfile lives in root of the git repo. Pull source files into container COPY / /usr/picard/ WORKDIR /usr/picard -# Build the distribution jar, clean up everything else -RUN ./gradlew ${build_command} && \ - mv build/libs/${jar_name} picard.jar && \ - ./gradlew clean && \ - rm -rf src && \ - rm -rf gradle && \ - rm -rf .git && \ - rm gradlew && \ - rm build.gradle +# download gradle then build +RUN ./gradlew -Drelease=${release} \ + clean \ + printVersion \ + shadowJar + +FROM ${BASE_DOCKER} as final +MAINTAINER Broad Institute DSDE + +# Install R +RUN apt-get update && \ + apt-get --no-install-recommends install -y \ + r-base &&\ + apt-get clean autoclean && \ + apt-get autoremove -y + +RUN mkdir /usr/picard/ + +COPY --from=build /usr/picard/build/libs/picard.jar /usr/picard/ RUN mkdir /usr/working -WORKDIR /usr/working \ No newline at end of file +WORKDIR /usr/working diff --git a/build_push_docker.sh b/build_push_docker.sh index fe6d37520c..d5b042db7c 100755 --- a/build_push_docker.sh +++ b/build_push_docker.sh @@ -20,6 +20,6 @@ read -p "Is this really what you want to do? " -n 1 -r echo # (optional) move to a new line if [[ $REPLY =~ ^[Yy]$ ]] then - docker build -t ${PICARD_CLOUD_TAG} --build-arg build_command=cloudJar --build-arg jar_name=picardcloud.jar . + docker build -t ${PICARD_CLOUD_TAG} --build-arg release=true . docker push ${PICARD_CLOUD_TAG} fi