Deployment Manual / Version 2101
Table Of ContentsEach Spring-Boot applications has the following Maven module structure involved in building Docker images:
Filesystem Layout.
apps `- <application name> |- docker | |- <application name> | | |- Dockerfile | | |- src | | | `- docker | | `- pom.xml | `- pom.xml `- pom.xml
The
Dockerfile
defines the Docker build process. In it, all available Dockerfile directives are available. Please visit Dockerfile Reference for more details. Be aware, that only files beside and beneath the folder where theDockerfile
resides, can be copied or added to the Docker image.The contents of the
src/docker
folder will be copied as-is into the/coremedia
within the image. This copying is done by the Dockerfile directive:COPY --chown=coremedia:coremedia src/docker /coremedia
apps/<application name>/docker/<application naem>/pom.xml
This is the Maven module that build the image. It should define the plugin executions to copy artifact to the Maven build dir to be processed from there by the
Dockerfile
. For the cae-live application this looks like the following snippets:Maven
pom.xml
- dependencies.<dependencies> <dependency> <groupId>${blueprint.boot.groupId}</groupId> <artifactId>cae-live-app</artifactId> <version>${blueprint.boot.version}</version> <scope>runtime</scope> </dependency> </dependencies>
Maven
pom.xml
- build.<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-dependency-plugin</artifactId> <executions> <execution> <id>copy-boot-jar</id> <goals> <goal>copy-dependencies</goal> </goals> <phase>generate-resources</phase> <configuration> <includeArtifactIds>cae-live-app</includeArtifactIds> <stripVersion>true</stripVersion> <outputDirectory>target</outputDirectory> <excludeTransitive>true</excludeTransitive> </configuration> </execution> </executions> </plugin>
Docker
Dockerfile
.COPY --chown=coremedia:coremedia target/cae-live-app.jar /coremedia/application.jar
apps/<application name>/docker/pom.xml
This Maven module encapsulates the build process of the
dockerfile-maven-plugin
. The following list of Maven properties can be configured:docker.repository.prefix
This property defines the docker registry part of the Docker image name. By default, it is set to
coremedia
and results in an image name ofcoremedia/${project.build.finalName}
for example, for the cae-livecoremedia/cae-live
.docker.image.tag
This property defines the tag of the image. By default,
latest
is used. In a CI environment, you should set this property with a reasonable value. Good candidates are Git hashes or the incremental build number of the build job. Do not use running tags likelatest
orstable
in production.docker.java-application-base-image.repo
This property defines the image repository for the
java-application-base
image, which is the base image for all Spring-Boot application images for CoreMedia.docker.java-application-base-image.tag
The java-application-base
properties are passed as build args to the Docker build process. This is defined in the
dockerfile-maven-plugin
definition:
Maven pom.xml
- dockerfile-maven-plugin - here with shortened property names.
<plugin> <groupId>com.spotify</groupId> <artifactId>dockerfile-maven-plugin</artifactId> <configuration> <buildArgs combine.children="append"> <BASE_IMAGE_REPO>${base-image.repo}</BASE_IMAGE_REPO> <BASE_IMAGE_TAG>${base-image.tag}</BASE_IMAGE_TAG> </buildArgs> </configuration> </plugin>
And consumed in the Dockerfile
of the application:
Docker Dockerfile
- from directive.
ARG BASE_IMAGE_REPO ARG BASE_IMAGE_TAG FROM ${BASE_IMAGE_REPO}:${BASE_IMAGE_TAG}