Springboot Executable Runner
409
marcellodesales/springboot-builder: Base Docker Image with Gradle that builds a SpringBoot project locally.
marcellodesales-springboot-builder: Intermediate stage to generate an executable JAR or WAR for the app.marcellodesales/springboot-runner: Docker Image to run any executable generated by the builder.
Implementation of a set of ONBUILD instructions that are reusable for any SpringBoot Application:
GIT_SHA, GIT_BRANCH and BUILD_NUMBER for versioning.Implementation of all tasks to execute a runnable WAR from a SpringBoot application.
Implementation of samples using the Docker Images for both builder and runner.
Look at the directory samples for details.
Gradle version is latest, currently at 4.10.1 with OpenJDK 1.8
Uses Gradle as the builder tool and requires:
build.gradle: Main build filesettings.gradle: Project settingssrc/build/gradle: Individual tasks implementation linked at build.gradleRegular Java project using maven structure
src/main/java: java projectRequires the use of the following build args
BUILDER_GIT_SHA: the current sha of the projectBUILDER_GIT_BRANCH: the current branch of the projectBUILDER_BUILD_NUMBER: the current builder number of CI ServerBUILDER_GRADLE_DOWNLOAD_DEPENDENCIES_CMD: the intermediate step to pull dependencies from the build
downloadDependencies can be implementedBUILDER_GRADLE_BUILD_CMD: the command used to build the executable jar or war
gradle bootRepackage or gradle buildFROM marcellodesales/springboot-builder:gradle-4.10.1-jdk-8 as marcellodesales-springboot-builder
RUN echo "You can add extra packages or anything needed to the final image for building"
pom.xml: Main build filesettings.xml: Project settingssrc/build/gradle: Individual tasks implementation linked at build.gradlesrc/main/java: java projectRequires the use of the following build args
BUILDER_GIT_SHA: the current sha of the projectBUILDER_GIT_BRANCH: the current branch of the projectBUILDER_BUILD_NUMBER: the current builder number of CI ServerBUILDER_MAVEN_DOWNLOAD_DEPENDENCIES_CMD: the intermediate step to pull dependencies from the build
maven-dependency-plugin:3.0.2:go-offline can be usedBUILDER_MAVEN_BUILD_CMD: the command used to build the executable jar or war
mvn -s settings.xml install -P embeddedstart.sh with the following capabilities
/runtime/sources/*.sh dir/runtime/java-opts/*.optThose are the runtime information important when deploying springboot in Docker/Kubernetes environments. In addition:
/runtime/sources gives you a mount path to execute additional app-based hooksruntime/java-opts are values that comes from sidecars or secret valuesRequires the use of the following build args to build, providing optional values.
RUNNER_DIR: The directory containing the executable file.
build/libstargetRUNNER_EXTENSION: the extension of the executable binary
jar and war files.RUNNER_PORT: the port to use in the EXPOSE instruction in the final Docker ImageRUNNER_HOOKS_DIR_SOURCES: the sources directory to be executed before executingRUNNER_ENV_HOOK_VAR: the name of the env to be populated with contents from RUNNER_HOOKS_ENV_VAR_DIR
JAVA_OPTSRUNNER_HOOKS_ENV_VAR_DIR: the directory with contents to be concatenated as value for RUNNER_ENV_HOOK_VAR
mem, agents, etc.RUNNER_CMD_EXEC: The command to execute after the sources and var has been processed.
RUNNER_HOOKS_DIR_SOURCES/*.shRUNNER_ENV_HOOK_VAR=concat of all RUNNER_HOOKS_ENV_VAR_DIR/*.optRUNNER_CMD_EXEC is executed, already set for runnable springboot appsThis runnable image will require any stage of the Dockerfile to be named as marcellodesales-springboot-builder as shown above.
Dockerfile without any stage name.
...
...
FROM marcellodesales/springboot-runner:openjdk-8-jre-slim
RUN echo "You can include more libraries or anything in the Runnable image"
### Builder Arguments
ARG BUILDER_GIT_SHA=${GIT_SHA:-0101010}
ARG BUILDER_GIT_BRANCH=${GIT_BRANCH:-develop}
ARG BUILDER_BUILD_NUMBER=${BUILD_NUMBER:-0223}
ARG BUILDER_GRADLE_DOWNLOAD_DEPENDENCIES_CMD="gradle downloadDependencies"
ARG BUILDER_GRADLE_BUILD_CMD="gradle build -x test"
### Runner Arguments
ARG RUNNER_DIR="build/libs"
ARG RUNNER_EXTENSION="jar"
ARG RUNNER_PORT="8080"
FROM marcellodesales/springboot-builder:gradle-4.10.1-jdk-8 as marcellodesales-springboot-builder
FROM marcellodesales/springboot-runner:openjdk-8-jre-slim
Go to the directory sample directory for more details.
docker pull marcellodesales/springboot-runner:latest