-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add support for bundled dockerfileSet
i.e. dockerprepare{ dockerfileSet '8u151-jre-alpine-buildlabels' }
- Loading branch information
Showing
8 changed files
with
281 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
src/main/resources/8u151-jre-alpine-buildlabels/Dockerfile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
FROM openjdk:8u151-jre-alpine | ||
# We choose this base image because: | ||
# 1. it is the latest Java 8 version on alpine as of March 2018 | ||
# 2. jre-alpine instead of jdk-alpine is much smaller but still enough to | ||
# run most microservice applications on the JVM | ||
# 3. jre-alpine has a smaller security footprint than other official Java docker images | ||
# 4. the explicit version number means the build will be repeatable | ||
# i.e. not dependent on what :latest version may have been pulled from a | ||
# docker registry before. | ||
|
||
RUN adduser -D -s /bin/sh springboot | ||
COPY ./bootrunner.sh /home/springboot/bootrunner.sh | ||
RUN chmod 755 /home/springboot/bootrunner.sh && chown springboot:springboot /home/springboot/bootrunner.sh | ||
WORKDIR /home/springboot | ||
USER springboot | ||
# We add a special springboot user for running our application. | ||
# Java applications do not need to be run as root | ||
|
||
ADD commonServiceDependenciesLayer1 /home/springboot/app/ | ||
# This layer is composed of all transitive dependencies of a | ||
# commonService, e.g in your build.gradle: | ||
# | ||
#dockerprepare { | ||
# commonService = ['org.springframework.boot:spring-boot-starter-web'] | ||
#} | ||
# | ||
# All 30 jar files pulled in from spring-boot-starter-web are added to this layer | ||
|
||
ADD dependenciesLayer2/ /home/springboot/app/ | ||
# This layer contains dependent jar files of the app that aren't a | ||
# commonService. Most of the time, | ||
# having dependencies in this layer will take advantage of the docker build | ||
# cache. This will give you faster build times, faster image | ||
# uploads/downloads and reduced storage requirements. | ||
# This layer is computed automatically from your spring boot application | ||
|
||
ADD classesLayer3/ /home/springboot/app/ | ||
# This layer contains your application classes. It will | ||
# likely change on each docker image build so we expect a docker cache miss. | ||
# This layer is computed automatically from your spring boot application | ||
|
||
ARG ORG_LABEL_SCHEMA_VCS_REF | ||
ARG ORG_LABEL_SCHEMA_VCS_URL | ||
ARG ORG_LABEL_SCHEMA_BUILD_DATE | ||
ARG ORG_LABEL_SCHEMA_VERSION | ||
ARG ORG_LABEL_SCHEMA_DESCRIPTION | ||
ARG MAINTAINER | ||
LABEL maintainer=${MAINTAINER:-"NA"} \ | ||
org.label-schema.vcs-ref=${ORG_LABEL_SCHEMA_VCS_REF} \ | ||
org.label-schema.vcs-url=${ORG_LABEL_SCHEMA_VCS_URL} \ | ||
org.label-schema.build-date=${ORG_LABEL_SCHEMA_BUILD_DATE} \ | ||
org.label-schema.version=${ORG_LABEL_SCHEMA_VERSION} \ | ||
org.label-schema.description=${ORG_LABEL_SCHEMA_DESCRIPTION} | ||
|
||
VOLUME /tmp | ||
EXPOSE 8080 | ||
ENV JAVA_OPTS="" \ | ||
SPRING_OUTPUT_ANSI_ENABLED=ALWAYS | ||
ENTRYPOINT ["./bootrunner.sh"] |
26 changes: 26 additions & 0 deletions
26
src/main/resources/8u151-jre-alpine-buildlabels/bootrunner.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#!/bin/sh | ||
date_echo(){ | ||
datestamp=$(date "+%F %T") | ||
echo "${datestamp} $*" | ||
} | ||
#exec the JVM so that it will get a SIGTERM signal and the app can shutdown gracefully | ||
|
||
if [ -d "${HOME}/app/WEB-INF" ]; then | ||
#execute springboot expanded war, which may have been constructed from several image layers | ||
date_echo "exec java ${JAVA_OPTS} -Djava.security.egd=file:/dev/./urandom -cp ${HOME}/app org.springframework.boot.loader.WarLauncher $*" | ||
# shellcheck disable=SC2086 | ||
exec java ${JAVA_OPTS} -Djava.security.egd=file:/dev/./urandom -cp "${HOME}/app" org.springframework.boot.loader.WarLauncher "$@" | ||
elif [ -d "${HOME}/app" ]; then | ||
#execute springboot expanded jar, which may have been constructed from several image layers | ||
date_echo "exec java ${JAVA_OPTS} -Djava.security.egd=file:/dev/./urandom -cp ${HOME}/app org.springframework.boot.loader.JarLauncher $*" | ||
# shellcheck disable=SC2086 | ||
exec java ${JAVA_OPTS} -Djava.security.egd=file:/dev/./urandom -cp "${HOME}/app" org.springframework.boot.loader.JarLauncher "$@" | ||
elif [ -f "${HOME}/app.jar" ]; then | ||
# execute springboot jar | ||
date_echo "exec java ${JAVA_OPTS} -Djava.security.egd=file:/dev/./urandom -jar ${HOME}/app.jar $*" | ||
# shellcheck disable=SC2086 | ||
exec java ${JAVA_OPTS} -Djava.security.egd=file:/dev/./urandom -jar "${HOME}/app.jar" "$@" | ||
else | ||
date_echo "springboot application not found in ${HOME}/app or ${HOME}/app.jar" | ||
exit 1 | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
FROM openjdk:9.0.1-11-jre-sid | ||
# We choose this base image because: | ||
# 1. it is the latest Java 9 version on alpine as of March 2018 | ||
|
||
RUN adduser --shell /bin/bash --home /home/springboot --gecos springboot --disabled-password springboot | ||
COPY ./bootrunner.sh /home/springboot/bootrunner.sh | ||
RUN chmod 755 /home/springboot/bootrunner.sh && chown springboot:springboot /home/springboot/bootrunner.sh | ||
WORKDIR /home/springboot | ||
USER springboot | ||
# We add a special springboot user for running our application. | ||
# Java applications do not need to be run as root | ||
|
||
ADD commonServiceDependenciesLayer1 /home/springboot/app/ | ||
# This layer is composed of all transitive dependencies of a | ||
# commonService, e.g in your build.gradle: | ||
# | ||
#dockerprepare { | ||
# commonService = ['org.springframework.boot:spring-boot-starter-web'] | ||
#} | ||
# | ||
# All 30 jar files pulled in from spring-boot-starter-web are added to this layer | ||
|
||
ADD dependenciesLayer2/ /home/springboot/app/ | ||
# This layer contains dependent jar files of the app that aren't a | ||
# commonService. Most of the time, | ||
# having dependencies in this layer will take advantage of the docker build | ||
# cache. This will give you faster build times, faster image | ||
# uploads/downloads and reduced storage requirements. | ||
# This layer is computed automatically from your spring boot application | ||
|
||
ADD classesLayer3/ /home/springboot/app/ | ||
# This layer contains your application classes. It will | ||
# likely change on each docker image build so we expect a docker cache miss. | ||
# This layer is computed automatically from your spring boot application | ||
|
||
ARG ORG_LABEL_SCHEMA_VCS_REF | ||
ARG ORG_LABEL_SCHEMA_VCS_URL | ||
ARG ORG_LABEL_SCHEMA_BUILD_DATE | ||
ARG ORG_LABEL_SCHEMA_VERSION | ||
ARG ORG_LABEL_SCHEMA_DESCRIPTION | ||
ARG MAINTAINER | ||
LABEL maintainer=${MAINTAINER:-"NA"} \ | ||
org.label-schema.vcs-ref=${ORG_LABEL_SCHEMA_VCS_REF} \ | ||
org.label-schema.vcs-url=${ORG_LABEL_SCHEMA_VCS_URL} \ | ||
org.label-schema.build-date=${ORG_LABEL_SCHEMA_BUILD_DATE} \ | ||
org.label-schema.version=${ORG_LABEL_SCHEMA_VERSION} \ | ||
org.label-schema.description=${ORG_LABEL_SCHEMA_DESCRIPTION} | ||
|
||
VOLUME /tmp | ||
EXPOSE 8080 | ||
ENV JAVA_OPTS="" \ | ||
SPRING_OUTPUT_ANSI_ENABLED=ALWAYS | ||
ENTRYPOINT ["./bootrunner.sh"] |
26 changes: 26 additions & 0 deletions
26
src/main/resources/90111-jre-sid-buildlabels/bootrunner.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#!/bin/sh | ||
date_echo(){ | ||
datestamp=$(date "+%F %T") | ||
echo "${datestamp} $*" | ||
} | ||
#exec the JVM so that it will get a SIGTERM signal and the app can shutdown gracefully | ||
|
||
if [ -d "${HOME}/app/WEB-INF" ]; then | ||
#execute springboot expanded war, which may have been constructed from several image layers | ||
date_echo "exec java ${JAVA_OPTS} -Djava.security.egd=file:/dev/./urandom -cp ${HOME}/app org.springframework.boot.loader.WarLauncher $*" | ||
# shellcheck disable=SC2086 | ||
exec java ${JAVA_OPTS} -Djava.security.egd=file:/dev/./urandom -cp "${HOME}/app" org.springframework.boot.loader.WarLauncher "$@" | ||
elif [ -d "${HOME}/app" ]; then | ||
#execute springboot expanded jar, which may have been constructed from several image layers | ||
date_echo "exec java ${JAVA_OPTS} -Djava.security.egd=file:/dev/./urandom -cp ${HOME}/app org.springframework.boot.loader.JarLauncher $*" | ||
# shellcheck disable=SC2086 | ||
exec java ${JAVA_OPTS} -Djava.security.egd=file:/dev/./urandom -cp "${HOME}/app" org.springframework.boot.loader.JarLauncher "$@" | ||
elif [ -f "${HOME}/app.jar" ]; then | ||
# execute springboot jar | ||
date_echo "exec java ${JAVA_OPTS} -Djava.security.egd=file:/dev/./urandom -jar ${HOME}/app.jar $*" | ||
# shellcheck disable=SC2086 | ||
exec java ${JAVA_OPTS} -Djava.security.egd=file:/dev/./urandom -jar "${HOME}/app.jar" "$@" | ||
else | ||
date_echo "springboot application not found in ${HOME}/app or ${HOME}/app.jar" | ||
exit 1 | ||
fi |