HUB
Sign inSign up
springboot-runner logo

marcellodesales/springboot-runner

By marcellodesales

•Updated about 8 years ago

Springboot Executable Runner

Image
0

409

marcellodesales/springboot-runner repository overview

⁠Spring Boot Docker Images

⁠Description

⁠Builder

Implementation of a set of ONBUILD instructions that are reusable for any SpringBoot Application:

  • Injection of env vars such as GIT_SHA, GIT_BRANCH and BUILD_NUMBER for versioning.
  • Supports the following builders:
    • Gradle 4.x.x + openjdk 1.8
    • Maven 3.x.x + openjdk 1.8
    • Gradle 4.x.x + openjdk 1.10
    • Maven 3.x.x + openjdk 1.10
    • Gradle 4.x.x + openjdk 1.11
    • Maven 3.x.x + openjdk 1.11

⁠Runner

Implementation of all tasks to execute a runnable WAR from a SpringBoot application.

  • Uses the built executable file to the appropriate directory.
  • Prepares the image with underlying capabilities to make TLS calls.
  • Uses small JRE images.
  • Supports the following Runners:
    • JRE Slim 1.8
    • JRE Slim 1.10
    • JRE Slim 1.11

⁠Samples

Implementation of samples using the Docker Images for both builder and runner. Look at the directory samples for details.

  • Samples with the following:
    • Java/Gradle SpringBoot 2.x with JRE Slim 1.8
    • Java/Gradle SpringBoot 2.x with JRE Slim 1.10
    • Java/Gradle SpringBoot 2.x with JRE Slim 1.11
    • Kotlin/Gradle SpringBoot 2.x with JRE Slim 1.8
    • Kotlin/Gradle SpringBoot 2.x with JRE Slim 1.10
    • Kotlin/Gradle SpringBoot 2.x with JRE Slim 1.11

⁠Gradle Builder

  • 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 file
    • settings.gradle: Project settings
    • src/build/gradle: Individual tasks implementation linked at build.gradle
  • Regular Java project using maven structure

    • src/main/java: java project

⁠Gradle Builder Args

Requires the use of the following build args

⁠Gradle Builder Dockerfile

  • The builder should be the first image of the Dockerfile
    • It can also include additional steps required by the builder such as installing new dependencies, etc.
FROM 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"

⁠Maven Builder

  • Maven version is 3.2.5 with OpenJDK 1.8
  • Uses Maven as the builder tool and requires:
    • pom.xml: Main build file
    • settings.xml: Project settings
    • src/build/gradle: Individual tasks implementation linked at build.gradle
  • Regular Java project using maven structure
    • src/main/java: java project

⁠Maven Builder Args

Requires the use of the following build args

  • BUILDER_GIT_SHA: the current sha of the project
  • BUILDER_GIT_BRANCH: the current branch of the project
  • BUILDER_BUILD_NUMBER: the current builder number of CI Server
  • BUILDER_MAVEN_DOWNLOAD_DEPENDENCIES_CMD: the intermediate step to pull dependencies from the build
  • BUILDER_MAVEN_BUILD_CMD: the command used to build the executable jar or war
    • mvn -s settings.xml install -P embedded

⁠Generic Runner

  • The runner image is the same for any builder supported
    • Gradle
    • Maven
  • The single image simplifies the whole process and requires a couple of args
  • Entrypoint defined as start.sh with the following capabilities
    • Sources a group of files under the /runtime/sources/*.sh dir
    • Creates JAVA_OPTS based on values under /runtime/java-opts/*.opt
    • Executes a default command provided, showing debug information

Those 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 hooks
  • You can use side-cars during Kubernetes deployments
  • runtime/java-opts are values that comes from sidecars or secret values

⁠Runner Args

Requires the use of the following build args to build, providing optional values.

  • RUNNER_DIR: The directory containing the executable file.
    • Default Gradle directory is build/libs
    • Default Maven directory is target
  • RUNNER_EXTENSION: the extension of the executable binary
    • Gradle has plenty of examples with jar and war files.
  • RUNNER_PORT: the port to use in the EXPOSE instruction in the final Docker Image
  • RUNNER_HOOKS_DIR_SOURCES: the sources directory to be executed before executing
  • RUNNER_ENV_HOOK_VAR: the name of the env to be populated with contents from RUNNER_HOOKS_ENV_VAR_DIR
    • Defaults to JAVA_OPTS
  • RUNNER_HOOKS_ENV_VAR_DIR: the directory with contents to be concatenated as value for RUNNER_ENV_HOOK_VAR
    • Those values for mem, agents, etc.
  • RUNNER_CMD_EXEC: The command to execute after the sources and var has been processed.
    1. source RUNNER_HOOKS_DIR_SOURCES/*.sh
    2. RUNNER_ENV_HOOK_VAR=concat of all RUNNER_HOOKS_ENV_VAR_DIR/*.opt
    3. RUNNER_CMD_EXEC is executed, already set for runnable springboot apps

This runnable image will require any stage of the Dockerfile to be named as marcellodesales-springboot-builder as shown above.

⁠Runner Dockerfile

  • The runner is the last image in the Dockerfile without any stage name.
    • It also should be specified the tag referring to the supported runtime.
  • The version supported is the tag with the kind of JRE to use.
...
...

FROM marcellodesales/springboot-runner:openjdk-8-jre-slim

RUN echo "You can include more libraries or anything in the Runnable image"

⁠Gradle Sample

  • Provide the build args as needed.
  • You can use the default images.
    • Runnable supports calling TLS services (certs)
    • See the samples for details
    • See the runner Dockerfile for details
### 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.

⁠Contributing

  • Send a PR
Tag summary
Recent tags
Content type
Image
Digest
Size
115 MB
Last updated
about 8 years ago
docker pull marcellodesales/springboot-runner:latest