Deployment Manual / Version 2107
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
Dockerfiledefines 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 theDockerfileresides, can be copied or added to the Docker image.The contents of the
src/dockerfolder will be copied as-is into the/coremediawithin the image. This copying is done by the Dockerfile directive:COPY --chown=coremedia:coremedia src/docker /coremedia
apps/<application name>/docker/<application naem>/pom.xmlThis 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.xmlThis Maven module encapsulates the build process of the
fabric8-maven-plugin. The following list of Maven properties can be configured:docker.repository.prefixThis property defines the docker registry part of the Docker image name. By default, it is set to
coremediaand results in an image name ofcoremedia/${project.build.finalName}for example, for the cae-livecoremedia/cae-live.docker.image.tagThis property defines the tag of the image. By default,
latestis 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 likelatestorstablein production.docker.java-application-base-image.repoThis property defines the image repository for the
java-application-baseimage, 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
fabric8-maven-plugin definition:
Maven pom.xml - fabric8-maven-plugin - here with shortened property names.
<plugin>
<groupId>io.fabric8</groupId>
<artifactId>docker-maven-plugin</artifactId>
<configuration>
<images>
<image>
<name>${docker.repository.prefix}/${docker.repository.suffix}</name>
<build>
<dockerFileDir>${project.basedir}</dockerFileDir>
<args>
<JAVA_APPLICATION_BASE_IMAGE_REPO>${docker.java-application-base-image.repo}</JAVA_APPLICATION_BASE_IMAGE_REPO>
<JAVA_APPLICATION_BASE_IMAGE_TAG>${docker.java-application-base-image.tag}</JAVA_APPLICATION_BASE_IMAGE_TAG>
</args>
<tags>
<tag>${docker.image.tag}</tag>
</tags>
</build>
</image>
</images>
</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}


