-
Notifications
You must be signed in to change notification settings - Fork 179
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Updating spring boot to latest 2.3.0.M4 - Add Maven plugin that build, tag, and push image with maven verify goal. - Adding some control properties to control dockerization stages. - Some other enhancements.
- Loading branch information
1 parent
29428ca
commit 4296fb5
Showing
11 changed files
with
134 additions
and
21 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,10 +18,13 @@ RUN java -Djarmode=layertools -jar --enable-preview application.jar extract | |
# ------------------------ | ||
# Build image based on JDK 14 base image, based on latest debian buster OS | ||
FROM openjdk:14-slim-buster | ||
MAINTAINER Mohamed Taman <[email protected]> | ||
|
||
# Set image information | ||
LABEL version="0.1.beta" name="Product Service" | ||
# Set image information, but could be set to different location from command line | ||
ARG IMAGE_VERSION="0.0.1-SNAPSHOT" | ||
ARG IMAGE_NAME="Product Composite Service" | ||
ARG MAINTAINER="Mohamed Taman <[email protected]>" | ||
|
||
LABEL version=${IMAGE_VERSION} name=${IMAGE_NAME} maintainer=${MAINTAINER} | ||
|
||
# Limiting security access to not user root user | ||
RUN addgroup siriusxi && useradd -g siriusxi -ms /bin/bash taman | ||
|
@@ -41,7 +44,9 @@ COPY --from=builder temp/application/ ./ | |
# Expose current application to port 8080 | ||
EXPOSE 8080 | ||
|
||
# Run the application | ||
ARG JAVA_OPTS="" | ||
|
||
# Run the application with JVM configs if any | ||
ENTRYPOINT ["bash", "-c", \ | ||
"java -server --enable-preview -XX:+UseContainerSupport \ | ||
-XX:+AlwaysActAsServerClassMachine -XX:+UseG1GC -XX:+UseStringDeduplication ${JAVA_OPTS} \ | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ | |
FROM openjdk:14-slim-buster as builder | ||
WORKDIR temp | ||
|
||
# Could be set to different jar file location | ||
# Fatjar location, but could be set to different location from command line | ||
ARG JAR_FILE=target/*.jar | ||
|
||
# Copy fat jar file to current image builder | ||
|
@@ -20,8 +20,12 @@ RUN java -Djarmode=layertools -jar --enable-preview application.jar extract | |
FROM openjdk:14-slim-buster | ||
MAINTAINER Mohamed Taman <[email protected]> | ||
|
||
# Set image information | ||
LABEL version="0.1.beta" name="Product Service" | ||
# Set image information, but could be set to different location from command line | ||
ARG IMAGE_VERSION="0.0.1-SNAPSHOT" | ||
ARG IMAGE_NAME="Product Service" | ||
ARG MAINTAINER="Mohamed Taman <[email protected]>" | ||
|
||
LABEL version=${IMAGE_VERSION} name=${IMAGE_NAME} maintainer=${MAINTAINER} | ||
|
||
# Limiting security access to not user root user | ||
RUN addgroup siriusxi && useradd -g siriusxi -ms /bin/bash taman | ||
|
@@ -41,7 +45,9 @@ COPY --from=builder temp/application/ ./ | |
# Expose current application to port 8080 | ||
EXPOSE 8080 | ||
|
||
# Run the application | ||
ARG JAVA_OPTS="" | ||
|
||
# Run the application with JVM configs if any | ||
ENTRYPOINT ["bash", "-c", \ | ||
"java -server --enable-preview -XX:+UseContainerSupport \ | ||
-XX:+AlwaysActAsServerClassMachine -XX:+UseG1GC -XX:+UseStringDeduplication ${JAVA_OPTS} \ | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,8 +20,12 @@ RUN java -Djarmode=layertools -jar --enable-preview application.jar extract | |
FROM openjdk:14-slim-buster | ||
MAINTAINER Mohamed Taman <[email protected]> | ||
|
||
# Set image information | ||
LABEL version="0.1.beta" name="Review Service" | ||
# Set image information, but could be set to different location from command line | ||
ARG IMAGE_VERSION="0.0.1-SNAPSHOT" | ||
ARG IMAGE_NAME="Recommendation Service" | ||
ARG MAINTAINER="Mohamed Taman <[email protected]>" | ||
|
||
LABEL version=${IMAGE_VERSION} name=${IMAGE_NAME} maintainer=${MAINTAINER} | ||
|
||
# Limiting security access to not user root user | ||
RUN addgroup siriusxi && useradd -g siriusxi -ms /bin/bash taman | ||
|
@@ -41,7 +45,9 @@ COPY --from=builder temp/application/ ./ | |
# Expose current application to port 8080 | ||
EXPOSE 8080 | ||
|
||
# Run the application | ||
ARG JAVA_OPTS="" | ||
|
||
# Run the application with JVM configs if any | ||
ENTRYPOINT ["bash", "-c", \ | ||
"java -server --enable-preview -XX:+UseContainerSupport \ | ||
-XX:+AlwaysActAsServerClassMachine -XX:+UseG1GC -XX:+UseStringDeduplication ${JAVA_OPTS} \ | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,8 +20,12 @@ RUN java -Djarmode=layertools -jar --enable-preview application.jar extract | |
FROM openjdk:14-slim-buster | ||
MAINTAINER Mohamed Taman <[email protected]> | ||
|
||
# Set image information | ||
LABEL version="0.1.beta" name="Review Service" | ||
# Set image information, but could be set to different location from command line | ||
ARG IMAGE_VERSION="0.0.1-SNAPSHOT" | ||
ARG IMAGE_NAME="Review Service" | ||
ARG MAINTAINER="Mohamed Taman <[email protected]>" | ||
|
||
LABEL version=${IMAGE_VERSION} name=${IMAGE_NAME} maintainer=${MAINTAINER} | ||
|
||
# Limiting security access to not user root user | ||
RUN addgroup siriusxi && useradd -g siriusxi -ms /bin/bash taman | ||
|
@@ -41,7 +45,9 @@ COPY --from=builder temp/application/ ./ | |
# Expose current application to port 8080 | ||
EXPOSE 8080 | ||
|
||
# Run the application | ||
ARG JAVA_OPTS="" | ||
|
||
# Run the application with JVM configs if any | ||
ENTRYPOINT ["bash", "-c", \ | ||
"java -server --enable-preview -XX:+UseContainerSupport \ | ||
-XX:+AlwaysActAsServerClassMachine -XX:+UseG1GC -XX:+UseStringDeduplication ${JAVA_OPTS} \ | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,12 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<parent> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-parent</artifactId> | ||
<!-- FIXME change this version to 2.3.0.M4 that fixes ASM8_EXPERIMENTAL when using JDK 14 | ||
record feature --> | ||
<version>2.3.0.M2</version> | ||
<version>2.3.0.M4</version> | ||
<relativePath/> <!-- lookup parent from repository --> | ||
</parent> | ||
|
||
|
@@ -31,6 +30,19 @@ | |
<java.version>14</java.version> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> | ||
|
||
<!-- Dependencies versions properties --> | ||
<dockerfile-maven-version>1.4.13</dockerfile-maven-version> | ||
|
||
<!-- Custom properties --> | ||
<maintainer.name>Mohamed Taman</maintainer.name> | ||
<maintainer.email>[email protected]</maintainer.email> | ||
<docker.repo.image.prefix>siriusxi</docker.repo.image.prefix> | ||
<docker.image.default.tag>latest</docker.image.default.tag> | ||
<skip.dockerization>true</skip.dockerization> | ||
<skip.image.build>true</skip.image.build> | ||
<skip.image.tag>true</skip.image.tag> | ||
<skip.image.push>true</skip.image.push> | ||
</properties> | ||
|
||
<dependencies> | ||
|
@@ -101,7 +113,9 @@ | |
<artifactId>spring-boot-maven-plugin</artifactId> | ||
<configuration> | ||
<!-- Make final jar, a layered jar --> | ||
<layout>LAYERED_JAR</layout> | ||
<layers> | ||
<enabled>true</enabled> | ||
</layers> | ||
</configuration> | ||
</plugin> | ||
|
||
|
@@ -127,6 +141,62 @@ | |
</configuration> | ||
</plugin> | ||
|
||
<!-- Start docker image build plugin --> | ||
<plugin> | ||
<groupId>com.spotify</groupId> | ||
<artifactId>dockerfile-maven-plugin</artifactId> | ||
<version>${dockerfile-maven-version}</version> | ||
<executions> | ||
<execution> | ||
<id>build-image</id> | ||
<phase>package</phase> | ||
<goals> | ||
<goal>build</goal> | ||
</goals> | ||
<configuration> | ||
<skipBuild>${skip.image.build}</skipBuild> | ||
<repository>${docker.repo.image.prefix}/${project.artifactId}</repository> | ||
<tag>${docker.image.default.tag}</tag> | ||
</configuration> | ||
</execution> | ||
<execution> | ||
<id>tag-image</id> | ||
<phase>package</phase> | ||
<goals> | ||
<goal>tag</goal> | ||
</goals> | ||
<configuration> | ||
<skipTag>${skip.image.tag}</skipTag> | ||
<tag>${project.version}</tag> | ||
</configuration> | ||
</execution> | ||
<execution> | ||
<id>push-image</id> | ||
<phase>verify</phase> | ||
<goals> | ||
<goal>push</goal> | ||
</goals> | ||
<configuration> | ||
<skipPush>${skip.image.push}</skipPush> | ||
<tag>${project.version}</tag> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
<configuration> | ||
<skip>${skip.dockerization}</skip> | ||
<dockerfile>Dockerfile</dockerfile> | ||
<repository>${docker.repo.image.prefix}/${project.artifactId}</repository> | ||
<useMavenSettingsForAuth>true</useMavenSettingsForAuth> | ||
<buildArgs> | ||
<JAR_FILE>target/${project.build.finalName}.jar</JAR_FILE> | ||
<IMAGE_VERSION>${project.version}</IMAGE_VERSION> | ||
<IMAGE_NAME>${project.name}</IMAGE_NAME> | ||
<MAINTAINER>"${maintainer.name} (${maintainer.email})"</MAINTAINER> | ||
</buildArgs> | ||
</configuration> | ||
</plugin> | ||
<!-- End docker image build plugin --> | ||
|
||
</plugins> | ||
</build> | ||
|
||
|
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