From 73e2f7a4b6f0ce7d3e38c610fd456f02ed3b8730 Mon Sep 17 00:00:00 2001 From: Gavin Date: Mon, 25 Mar 2024 17:44:32 -0700 Subject: [PATCH 1/2] Build docker image with gradle --- Dockerfile | 31 +++++++++++++++++++++++-------- build.gradle | 26 +++++++++++++++----------- 2 files changed, 38 insertions(+), 19 deletions(-) diff --git a/Dockerfile b/Dockerfile index 27a655ea..d84ef703 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,15 +2,27 @@ FROM eclipse-temurin:11-jdk as build WORKDIR /tmp RUN apt update -y && \ - apt install -y ant git ca-certificates python3-sphinx && \ - git clone https://github.com/kbase/jars + apt install -y git ca-certificates python3-sphinx -COPY . /tmp/workspace_deluxe +WORKDIR /tmp/workspace -RUN cd workspace_deluxe && \ - make docker_deps +# dependencies take a while to D/L, so D/L & cache before the build so code changes don't cause +# a new D/L +# can't glob *gradle because of the .gradle dir +COPY build.gradle gradlew settings.gradle /tmp/workspace/ +COPY gradle/ /tmp/workspace/gradle/ +RUN ./gradlew dependencies + +# Now build the code +COPY workspace.spec /tmp/workspace/workspace.spec +COPY deployment/ /tmp/workspace/deployment/ +COPY docshtml /tmp/workspace/docshtml/ +COPY docsource /tmp/workspace/docsource/ +COPY lib /tmp/workspace/lib/ +COPY src /tmp/workspace/src/ +COPY war /tmp/workspace/war/ +RUN ./gradlew war -# updated/slimmed down version of what's in kbase/kb_jre FROM ubuntu:18.04 # These ARGs values are passed in via the docker build command @@ -39,11 +51,11 @@ RUN mkdir -p /var/lib/apt/lists/partial && \ tar xvzf dockerize-${DOCKERIZE_VERSION}.tar.gz && \ rm dockerize-${DOCKERIZE_VERSION}.tar.gz -COPY --from=build /tmp/workspace_deluxe/deployment/ /kb/deployment/ +COPY --from=build /tmp/workspace/deployment/ /kb/deployment/ RUN /usr/bin/${TOMCAT_VERSION}-instance-create /kb/deployment/services/workspace/tomcat && \ - mv /kb/deployment/services/workspace/WorkspaceService.war /kb/deployment/services/workspace/tomcat/webapps/ROOT.war && \ rm -rf /kb/deployment/services/workspace/tomcat/webapps/ROOT +COPY --from=build /tmp/workspace/build/libs/workspace_deluxe.war /kb/deployment/services/workspace/tomcat/webapps/ROOT.war # The BUILD_DATE value seem to bust the docker cache when the timestamp changes, move to # the end @@ -54,6 +66,9 @@ LABEL org.label-schema.build-date=$BUILD_DATE \ us.kbase.vcs-branch=$BRANCH \ maintainer="KBase developers engage@kbase.us" +# TODO BUILD update to no longer use dockerize and take env vars (e.g. like Collections). +# TODO BUILD Use subsections in the ini file / switch to TOML + EXPOSE 7058 ENTRYPOINT [ "/kb/deployment/bin/dockerize" ] WORKDIR /kb/deployment/services/workspace/tomcat diff --git a/build.gradle b/build.gradle index b4ea4ded..d7b8fcc6 100644 --- a/build.gradle +++ b/build.gradle @@ -22,17 +22,16 @@ var BUILD_OTHER_DOC_DIR = "$BUILD_DOC_ROOT/otherdoc/" // in deploy.cfg as well // TODO DOCS just get rid of configuring this in the DocServer, make things hardcoded // or pass in constructor when we subume into a Jersey style service -var IN_JAR_DOCS_DIR = "/server_docs" +var IN_JAR_DOC_DIR = "/server_docs" +var IN_JAR_JAVA_DOC_DIR = "$IN_JAR_DOC_DIR/javadoc" -// TODO NOW test shadow jar works in groups - need test controller - commit 2 -// TODO NOW get docserver working in WAR and test in docker-compose <- edit to start test server - commit 3 // TODO NOW client jar - commit 4 -// TODO NOW client jar javadoc - needs java_common source - commit 4 // TODO NOW schema updater script - commit 5 // TODO NOW sdk-compile all, java, and docs - commit 6 // TODO NOW handle the git commit the same way as auth does - commit 7 -// TODO NOW delete build.xml, , and Makefile - commit 8 +// TODO NOW delete build.xml and Makefile - commit 8 // TODO NOW run tests from Eclipse w/o specifying classpath manually & remove sourceSets & claspath - commit 9 +// TODO NOW update any ant refs in docs to gradle repositories { mavenCentral() @@ -70,18 +69,20 @@ task buildDocs { dependsOn javadoc doLast { // need to make sure we remove any docs that no longer exist in the source - delete "$BUILD_OTHER_DOC_DIR" + delete BUILD_OTHER_DOC_DIR + // not needed locally, fails w/o it in docker build. *shrug* + mkdir BUILD_OTHER_DOC_DIR copy { - from "$rootDir/workspace.spec" into "$BUILD_OTHER_DOC_DIR" + from "$rootDir/workspace.spec" into BUILD_OTHER_DOC_DIR } copy { - from "$rootDir/docshtml/" into "$BUILD_OTHER_DOC_DIR" include "*" + from "$rootDir/docshtml/" into BUILD_OTHER_DOC_DIR include "*" } exec { commandLine "pod2html", "--infile=$rootDir/lib/Bio/KBase/workspace/Client.pm", "--outfile=$BUILD_OTHER_DOC_DIR/workspace_perl.html" } exec { - commandLine "sphinx-build", "$rootDir/docsource/", "$BUILD_OTHER_DOC_DIR" + commandLine "sphinx-build", "$rootDir/docsource/", BUILD_OTHER_DOC_DIR } delete fileTree(".").matching { include "pod2htm*.tmp" } } @@ -155,8 +156,8 @@ shadowJar { mergeServiceFiles() - from(BUILD_JAVA_DOC_DIR) { into "$IN_JAR_DOCS_DIR/javadoc" } - from(BUILD_OTHER_DOC_DIR) { into IN_JAR_DOCS_DIR } + from(BUILD_JAVA_DOC_DIR) { into IN_JAR_JAVA_DOC_DIR } + from(BUILD_OTHER_DOC_DIR) { into IN_JAR_DOC_DIR } } // Custom java project layout @@ -190,7 +191,10 @@ sourceSets { } war { + dependsOn buildDocs webXml = file('war/web.xml') + from(BUILD_JAVA_DOC_DIR) { into "/WEB-INF/classes/$IN_JAR_JAVA_DOC_DIR" } + from(BUILD_OTHER_DOC_DIR) { into "/WEB-INF/classes/$IN_JAR_DOC_DIR" } } configurations { From ae3922af4ac942181eaefe4efc1a5dc3999641d4 Mon Sep 17 00:00:00 2001 From: Gavin Date: Wed, 10 Apr 2024 12:00:01 -0700 Subject: [PATCH 2/2] Remove unnecessary WORKDIR line --- Dockerfile | 1 - 1 file changed, 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index d84ef703..d46802d8 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,5 @@ FROM eclipse-temurin:11-jdk as build -WORKDIR /tmp RUN apt update -y && \ apt install -y git ca-certificates python3-sphinx