Skip to content

Commit

Permalink
Merge pull request #728 from MrCreosote/dev-gradle2
Browse files Browse the repository at this point in the history
Build docker image with gradle
  • Loading branch information
MrCreosote authored Apr 12, 2024
2 parents 602fbdb + ae3922a commit b1bdb86
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 20 deletions.
32 changes: 23 additions & 9 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,16 +1,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
Expand Down Expand Up @@ -39,11 +50,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
Expand All @@ -54,6 +65,9 @@ LABEL org.label-schema.build-date=$BUILD_DATE \
us.kbase.vcs-branch=$BRANCH \
maintainer="KBase developers [email protected]"

# 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
Expand Down
26 changes: 15 additions & 11 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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" }
}
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit b1bdb86

Please sign in to comment.