From 45efcc517b45d758e3c41588ce1e54d5c9cf2407 Mon Sep 17 00:00:00 2001 From: Mohamed Taman Date: Sat, 4 Apr 2020 01:43:52 +0200 Subject: [PATCH 1/8] Dockerize product microservice - Create a specific docker file, that also separates the libs from the main Jar for docker layer caching and reusability. - Image is based on Java jdk openjdk:14-slim-buster. - Use a multi-stage docker file to unzip the files for better image layering and faster startup --- product-service/Dockerfile | 46 +++++++++++++++++++ .../src/main/resources/application.yaml | 11 ++++- store-chassis/pom.xml | 8 +++- 3 files changed, 62 insertions(+), 3 deletions(-) create mode 100644 product-service/Dockerfile diff --git a/product-service/Dockerfile b/product-service/Dockerfile new file mode 100644 index 00000000..4d961c0b --- /dev/null +++ b/product-service/Dockerfile @@ -0,0 +1,46 @@ +#### Start of builder image +# ------------------------ +# Builder stage to prepare application for final image +FROM openjdk:14-slim-buster as builder +WORKDIR temp + +# Could be set to different jar file location +ARG JAR_FILE=target/*.jar + +# Copy fat jar file to current image builder +COPY ${JAR_FILE} application.jar + +# Extract the jar file layers +RUN java -Djarmode=layertools -jar --enable-preview application.jar extract +#### End of builder stage + +#### Start of actual image +# ------------------------ +# Build image based on JDK 14 base image, based on latest debian buster OS +FROM openjdk:14-slim-buster +MAINTAINER Mohamed Taman + +# Set image information +LABEL version="0.1.beta" name="Product Service" + +# Limiting security access to not user root user +RUN addgroup siriusxi && useradd -g siriusxi -ms /bin/bash taman + +# Setting user to current created user +USER taman + +# Set working directory to application folder +WORKDIR /home/taman/application + +# Copy all layers from builder stage to current image +COPY --from=builder temp/dependencies/ ./ +COPY --from=builder temp/snapshot-dependencies/ ./ +COPY --from=builder temp/resources/ ./ +COPY --from=builder temp/application/ ./ + +# Expose current application to port 8080 +EXPOSE 8080 + +# Run the application +ENTRYPOINT ["bash", "-c", \ +"java --enable-preview ${JAVA_OPTS} org.springframework.boot.loader.JarLauncher ${0} ${@}"] \ No newline at end of file diff --git a/product-service/src/main/resources/application.yaml b/product-service/src/main/resources/application.yaml index 2e84cb35..ec025ef8 100644 --- a/product-service/src/main/resources/application.yaml +++ b/product-service/src/main/resources/application.yaml @@ -18,4 +18,13 @@ management: include: "*" endpoint: shutdown: - enabled: true \ No newline at end of file + enabled: true + +# This is a docker specific profile properties +# Also profiles could be separated in its owen file +# with file name format of "application-docker.yaml" +--- +spring: + profiles: docker +server: + port: 8080 \ No newline at end of file diff --git a/store-chassis/pom.xml b/store-chassis/pom.xml index ad2e14a3..d5497379 100644 --- a/store-chassis/pom.xml +++ b/store-chassis/pom.xml @@ -16,7 +16,7 @@ 0.0.1-SNAPSHOT pom Springy Store Chassis - Parent pom project for Spring Boot μServices + Parent pom project for Springy μServices ../product-composite-service @@ -80,7 +80,7 @@ reactor-test test - + com.siriusxi.ms.store store-api @@ -99,6 +99,10 @@ org.springframework.boot spring-boot-maven-plugin + + + LAYERED_JAR + From 35df49a851315aa0b63dab3ff886062b03b16d6d Mon Sep 17 00:00:00 2001 From: Mohamed Taman Date: Sat, 4 Apr 2020 11:15:48 +0200 Subject: [PATCH 2/8] Review service dockerization - Create a multi-stage docker file docker file. Resolves #8 --- .../src/main/resources/application.yaml | 1 + review-service/Dockerfile | 46 +++++++++++++++++++ .../src/main/resources/application.yaml | 12 ++++- 3 files changed, 58 insertions(+), 1 deletion(-) create mode 100644 review-service/Dockerfile diff --git a/product-service/src/main/resources/application.yaml b/product-service/src/main/resources/application.yaml index ec025ef8..b0f13e4e 100644 --- a/product-service/src/main/resources/application.yaml +++ b/product-service/src/main/resources/application.yaml @@ -26,5 +26,6 @@ management: --- spring: profiles: docker + server: port: 8080 \ No newline at end of file diff --git a/review-service/Dockerfile b/review-service/Dockerfile new file mode 100644 index 00000000..094caa66 --- /dev/null +++ b/review-service/Dockerfile @@ -0,0 +1,46 @@ +#### Start of builder image +# ------------------------ +# Builder stage to prepare application for final image +FROM openjdk:14-slim-buster as builder +WORKDIR temp + +# Could be set to different jar file location +ARG JAR_FILE=target/*.jar + +# Copy fat jar file to current image builder +COPY ${JAR_FILE} application.jar + +# Extract the jar file layers +RUN java -Djarmode=layertools -jar --enable-preview application.jar extract +#### End of builder stage + +#### Start of actual image +# ------------------------ +# Build image based on JDK 14 base image, based on latest debian buster OS +FROM openjdk:14-slim-buster +MAINTAINER Mohamed Taman + +# Set image information +LABEL version="0.1.beta" name="Review Service" + +# Limiting security access to not user root user +RUN addgroup siriusxi && useradd -g siriusxi -ms /bin/bash taman + +# Setting user to current created user +USER taman + +# Set working directory to application folder +WORKDIR /home/taman/application + +# Copy all layers from builder stage to current image +COPY --from=builder temp/dependencies/ ./ +COPY --from=builder temp/snapshot-dependencies/ ./ +COPY --from=builder temp/resources/ ./ +COPY --from=builder temp/application/ ./ + +# Expose current application to port 8080 +EXPOSE 8080 + +# Run the application +ENTRYPOINT ["bash", "-c", \ +"java --enable-preview ${JAVA_OPTS} org.springframework.boot.loader.JarLauncher ${0} ${@}"] \ No newline at end of file diff --git a/review-service/src/main/resources/application.yaml b/review-service/src/main/resources/application.yaml index e00c7614..b8c4baaa 100644 --- a/review-service/src/main/resources/application.yaml +++ b/review-service/src/main/resources/application.yaml @@ -18,4 +18,14 @@ management: include: "*" endpoint: shutdown: - enabled: true \ No newline at end of file + enabled: true + +# This is a docker specific profile properties +# Also profiles could be separated in its owen file +# with file name format of "application-docker.yaml" +--- +spring: + profiles: docker + +server: + port: 8080 \ No newline at end of file From a26cc24826e5d03312fe6d8c039f53f2abecd5ff Mon Sep 17 00:00:00 2001 From: Mohamed Taman Date: Sat, 4 Apr 2020 12:00:36 +0200 Subject: [PATCH 3/8] Recommendation service dockerization - Create a multi-stage docker file docker file. - Add docker profile to application.yaml --- recommendation-service/Dockerfile | 46 +++++++++++++++++++ .../src/main/resources/application.yaml | 10 ++++ 2 files changed, 56 insertions(+) create mode 100644 recommendation-service/Dockerfile diff --git a/recommendation-service/Dockerfile b/recommendation-service/Dockerfile new file mode 100644 index 00000000..094caa66 --- /dev/null +++ b/recommendation-service/Dockerfile @@ -0,0 +1,46 @@ +#### Start of builder image +# ------------------------ +# Builder stage to prepare application for final image +FROM openjdk:14-slim-buster as builder +WORKDIR temp + +# Could be set to different jar file location +ARG JAR_FILE=target/*.jar + +# Copy fat jar file to current image builder +COPY ${JAR_FILE} application.jar + +# Extract the jar file layers +RUN java -Djarmode=layertools -jar --enable-preview application.jar extract +#### End of builder stage + +#### Start of actual image +# ------------------------ +# Build image based on JDK 14 base image, based on latest debian buster OS +FROM openjdk:14-slim-buster +MAINTAINER Mohamed Taman + +# Set image information +LABEL version="0.1.beta" name="Review Service" + +# Limiting security access to not user root user +RUN addgroup siriusxi && useradd -g siriusxi -ms /bin/bash taman + +# Setting user to current created user +USER taman + +# Set working directory to application folder +WORKDIR /home/taman/application + +# Copy all layers from builder stage to current image +COPY --from=builder temp/dependencies/ ./ +COPY --from=builder temp/snapshot-dependencies/ ./ +COPY --from=builder temp/resources/ ./ +COPY --from=builder temp/application/ ./ + +# Expose current application to port 8080 +EXPOSE 8080 + +# Run the application +ENTRYPOINT ["bash", "-c", \ +"java --enable-preview ${JAVA_OPTS} org.springframework.boot.loader.JarLauncher ${0} ${@}"] \ No newline at end of file diff --git a/recommendation-service/src/main/resources/application.yaml b/recommendation-service/src/main/resources/application.yaml index fe117b8f..22775918 100644 --- a/recommendation-service/src/main/resources/application.yaml +++ b/recommendation-service/src/main/resources/application.yaml @@ -19,3 +19,13 @@ management: endpoint: shutdown: enabled: true + +# This is a docker specific profile properties +# Also profiles could be separated in its owen file +# with file name format of "application-docker.yaml" +--- +spring: + profiles: docker + +server: + port: 8080 From 18a63f1585c8bd466a2363b0d10667297ff111bb Mon Sep 17 00:00:00 2001 From: Mohamed Taman Date: Sat, 4 Apr 2020 17:07:10 +0200 Subject: [PATCH 4/8] Product composite service containerization - Add product-composite-service docker file. - Add microservices landscape docker-compose.yml. - Edit test-em-all.sh file to work with docker compose. --- docker-compose.yml | 28 +++++++++ product-composite-service/Dockerfile | 46 +++++++++++++++ ...itional-spring-configuration-metadata.json | 33 +++++++++++ .../src/main/resources/application.yaml | 23 +++++++- test-em-all.sh | 59 ++++++++++++++++++- 5 files changed, 185 insertions(+), 4 deletions(-) create mode 100644 docker-compose.yml create mode 100644 product-composite-service/Dockerfile create mode 100644 product-composite-service/src/main/resources/META-INF/additional-spring-configuration-metadata.json diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 00000000..9e3972c9 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,28 @@ +version: '2.1' + +services: + product: + build: product-service + mem_limit: 350m + environment: + - SPRING_PROFILES_ACTIVE=docker + + recommendation: + build: recommendation-service + mem_limit: 350m + environment: + - SPRING_PROFILES_ACTIVE=docker + + review: + build: review-service + mem_limit: 350m + environment: + - SPRING_PROFILES_ACTIVE=docker + + product-composite: + build: product-composite-service + mem_limit: 350m + ports: + - "8080:8080" + environment: + - SPRING_PROFILES_ACTIVE=docker diff --git a/product-composite-service/Dockerfile b/product-composite-service/Dockerfile new file mode 100644 index 00000000..4d961c0b --- /dev/null +++ b/product-composite-service/Dockerfile @@ -0,0 +1,46 @@ +#### Start of builder image +# ------------------------ +# Builder stage to prepare application for final image +FROM openjdk:14-slim-buster as builder +WORKDIR temp + +# Could be set to different jar file location +ARG JAR_FILE=target/*.jar + +# Copy fat jar file to current image builder +COPY ${JAR_FILE} application.jar + +# Extract the jar file layers +RUN java -Djarmode=layertools -jar --enable-preview application.jar extract +#### End of builder stage + +#### Start of actual image +# ------------------------ +# Build image based on JDK 14 base image, based on latest debian buster OS +FROM openjdk:14-slim-buster +MAINTAINER Mohamed Taman + +# Set image information +LABEL version="0.1.beta" name="Product Service" + +# Limiting security access to not user root user +RUN addgroup siriusxi && useradd -g siriusxi -ms /bin/bash taman + +# Setting user to current created user +USER taman + +# Set working directory to application folder +WORKDIR /home/taman/application + +# Copy all layers from builder stage to current image +COPY --from=builder temp/dependencies/ ./ +COPY --from=builder temp/snapshot-dependencies/ ./ +COPY --from=builder temp/resources/ ./ +COPY --from=builder temp/application/ ./ + +# Expose current application to port 8080 +EXPOSE 8080 + +# Run the application +ENTRYPOINT ["bash", "-c", \ +"java --enable-preview ${JAVA_OPTS} org.springframework.boot.loader.JarLauncher ${0} ${@}"] \ No newline at end of file diff --git a/product-composite-service/src/main/resources/META-INF/additional-spring-configuration-metadata.json b/product-composite-service/src/main/resources/META-INF/additional-spring-configuration-metadata.json new file mode 100644 index 00000000..5468421c --- /dev/null +++ b/product-composite-service/src/main/resources/META-INF/additional-spring-configuration-metadata.json @@ -0,0 +1,33 @@ +{ + "properties": [ + { + "name": "app.product-service.host", + "type": "java.lang.String", + "description": "Description for app.product-service.host." + }, + { + "name": "app.product-service.port", + "type": "java.lang.Integer", + "description": "Description for app.product-service.port." + }, + { + "name": "app.recommendation-service.host", + "type": "java.lang.String", + "description": "Description for app.recommendation-service.host." + }, + { + "name": "app.recommendation-service.port", + "type": "java.lang.Integer", + "description": "Description for app.recommendation-service.port." + }, + { + "name": "app.review-service.host", + "type": "java.lang.String", + "description": "Description for app.review-service.host." + }, + { + "name": "app.review-service.port", + "type": "java.lang.String", + "description": "Description for app.review-service.port." + } + ] } \ No newline at end of file diff --git a/product-composite-service/src/main/resources/application.yaml b/product-composite-service/src/main/resources/application.yaml index 3c8fe449..b2bd0bed 100644 --- a/product-composite-service/src/main/resources/application.yaml +++ b/product-composite-service/src/main/resources/application.yaml @@ -30,4 +30,25 @@ app: port: 9082 review-service: host: localhost - port: 9083 \ No newline at end of file + port: 9083 + +# This is a docker specific profile properties +# Also profiles could be separated in its owen file +# with file name format of "application-docker.yaml" +--- +spring: + profiles: docker + +server: + port: 8080 + +app: + product-service: + host: product + port: 8080 + recommendation-service: + host: recommendation + port: 8080 + review-service: + host: review + port: 8080 \ No newline at end of file diff --git a/test-em-all.sh b/test-em-all.sh index fd047b53..04bb85e2 100644 --- a/test-em-all.sh +++ b/test-em-all.sh @@ -2,13 +2,15 @@ ## Author: Mohamed Taman ## version: v1.0 ### Sample usage: -# -# HOST=localhost PORT=9080 ./test-em-all.bash +# for local run +# HOST=localhost PORT=9080 ./test-em-all.bash +# with docker compose +# HOST=localhost PORT=8080 ./test-em-all.bash start stop # echo -e "Starting [Springy Store] full functionality testing....\n" : ${HOST=localhost} -: ${PORT=9080} +: ${PORT=8080} function assertCurl() { @@ -48,11 +50,54 @@ function assertEqual() { fi } +function testUrl() { + url=$@ + if curl ${url} -ks -f -o /dev/null + then + echo "Ok" + return 0 + else + echo -n "not yet" + return 1 + fi; +} + +function waitForService() { + url=$@ + echo -n "Wait for: $url... " + n=0 + until testUrl ${url} + do + n=$((n + 1)) + if [[ ${n} == 100 ]] + then + echo " Give up" + exit 1 + else + sleep 6 + echo -n ", retry #$n " + fi + done +} + set -e +echo "Start:" `date` + echo "HOST=${HOST}" echo "PORT=${PORT}" +if [[ $@ == *"start"* ]] +then + echo "Restarting the test environment..." + echo "$ docker-compose down" + docker-compose down + echo "$ docker-compose up -d" + docker-compose up -d +fi + +waitForService http://${HOST}:${PORT}/product-composite/1 + # Verify that a normal request works, expect three recommendations and three reviews assertCurl 200 "curl http://$HOST:$PORT/product-composite/1 -s" assertEqual 1 $(echo ${RESPONSE} | jq .productId) @@ -82,3 +127,11 @@ assertEqual "\"Invalid productId: -1\"" "$(echo ${RESPONSE} | jq .message)" assertCurl 400 "curl http://$HOST:$PORT/product-composite/invalidProductId -s" assertEqual "\"Type mismatch.\"" "$(echo ${RESPONSE} | jq .message)" +if [[ $@ == *"stop"* ]] +then + echo "We are done, stopping the test environment..." + echo "$ docker-compose down" + docker-compose down +fi + +echo "End:" `date` \ No newline at end of file From a2b369f0c2cec282a0c29c2275272a4aef46517d Mon Sep 17 00:00:00 2001 From: Mohamed Taman Date: Sat, 4 Apr 2020 17:34:04 +0200 Subject: [PATCH 5/8] validate some properties --- .../META-INF/additional-spring-configuration-metadata.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/product-composite-service/src/main/resources/META-INF/additional-spring-configuration-metadata.json b/product-composite-service/src/main/resources/META-INF/additional-spring-configuration-metadata.json index 5468421c..c8fce465 100644 --- a/product-composite-service/src/main/resources/META-INF/additional-spring-configuration-metadata.json +++ b/product-composite-service/src/main/resources/META-INF/additional-spring-configuration-metadata.json @@ -27,7 +27,7 @@ }, { "name": "app.review-service.port", - "type": "java.lang.String", + "type": "java.lang.Integer", "description": "Description for app.review-service.port." } ] } \ No newline at end of file From 8c8ad808e64a5317e9ccba683477980b89bdc710 Mon Sep 17 00:00:00 2001 From: Mohamed Taman Date: Sat, 4 Apr 2020 23:38:39 +0200 Subject: [PATCH 6/8] Passing project name to docker-compose Just a way to get rid from prefixing services with folder name. --- test-em-all.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test-em-all.sh b/test-em-all.sh index 04bb85e2..0bfa7cae 100644 --- a/test-em-all.sh +++ b/test-em-all.sh @@ -92,7 +92,7 @@ then echo "Restarting the test environment..." echo "$ docker-compose down" docker-compose down - echo "$ docker-compose up -d" + echo "$ docker-compose -p ssm up -d" docker-compose up -d fi From 29428ca04359a4677602a51e2a0c5f083ced7179 Mon Sep 17 00:00:00 2001 From: Mohamed Taman Date: Sun, 5 Apr 2020 02:21:12 +0200 Subject: [PATCH 7/8] General enhancements and performance tweaking. --- product-composite-service/Dockerfile | 4 +++- product-composite-service/src/main/resources/application.yaml | 2 ++ product-service/Dockerfile | 4 +++- product-service/src/main/resources/application.yaml | 2 ++ recommendation-service/Dockerfile | 4 +++- recommendation-service/src/main/resources/application.yaml | 2 ++ review-service/Dockerfile | 4 +++- review-service/src/main/resources/application.yaml | 2 ++ test-em-all.sh | 2 +- 9 files changed, 21 insertions(+), 5 deletions(-) diff --git a/product-composite-service/Dockerfile b/product-composite-service/Dockerfile index 4d961c0b..30212339 100644 --- a/product-composite-service/Dockerfile +++ b/product-composite-service/Dockerfile @@ -43,4 +43,6 @@ EXPOSE 8080 # Run the application ENTRYPOINT ["bash", "-c", \ -"java --enable-preview ${JAVA_OPTS} org.springframework.boot.loader.JarLauncher ${0} ${@}"] \ No newline at end of file +"java -server --enable-preview -XX:+UseContainerSupport \ +-XX:+AlwaysActAsServerClassMachine -XX:+UseG1GC -XX:+UseStringDeduplication ${JAVA_OPTS} \ +org.springframework.boot.loader.JarLauncher ${0} ${@}"] \ No newline at end of file diff --git a/product-composite-service/src/main/resources/application.yaml b/product-composite-service/src/main/resources/application.yaml index b2bd0bed..9017d16e 100644 --- a/product-composite-service/src/main/resources/application.yaml +++ b/product-composite-service/src/main/resources/application.yaml @@ -38,6 +38,8 @@ app: --- spring: profiles: docker + jmx: + enabled: false server: port: 8080 diff --git a/product-service/Dockerfile b/product-service/Dockerfile index 4d961c0b..30212339 100644 --- a/product-service/Dockerfile +++ b/product-service/Dockerfile @@ -43,4 +43,6 @@ EXPOSE 8080 # Run the application ENTRYPOINT ["bash", "-c", \ -"java --enable-preview ${JAVA_OPTS} org.springframework.boot.loader.JarLauncher ${0} ${@}"] \ No newline at end of file +"java -server --enable-preview -XX:+UseContainerSupport \ +-XX:+AlwaysActAsServerClassMachine -XX:+UseG1GC -XX:+UseStringDeduplication ${JAVA_OPTS} \ +org.springframework.boot.loader.JarLauncher ${0} ${@}"] \ No newline at end of file diff --git a/product-service/src/main/resources/application.yaml b/product-service/src/main/resources/application.yaml index b0f13e4e..e14a686a 100644 --- a/product-service/src/main/resources/application.yaml +++ b/product-service/src/main/resources/application.yaml @@ -26,6 +26,8 @@ management: --- spring: profiles: docker + jmx: + enabled: false server: port: 8080 \ No newline at end of file diff --git a/recommendation-service/Dockerfile b/recommendation-service/Dockerfile index 094caa66..96dd37dc 100644 --- a/recommendation-service/Dockerfile +++ b/recommendation-service/Dockerfile @@ -43,4 +43,6 @@ EXPOSE 8080 # Run the application ENTRYPOINT ["bash", "-c", \ -"java --enable-preview ${JAVA_OPTS} org.springframework.boot.loader.JarLauncher ${0} ${@}"] \ No newline at end of file +"java -server --enable-preview -XX:+UseContainerSupport \ +-XX:+AlwaysActAsServerClassMachine -XX:+UseG1GC -XX:+UseStringDeduplication ${JAVA_OPTS} \ +org.springframework.boot.loader.JarLauncher ${0} ${@}"] \ No newline at end of file diff --git a/recommendation-service/src/main/resources/application.yaml b/recommendation-service/src/main/resources/application.yaml index 22775918..d0af2644 100644 --- a/recommendation-service/src/main/resources/application.yaml +++ b/recommendation-service/src/main/resources/application.yaml @@ -26,6 +26,8 @@ management: --- spring: profiles: docker + jmx: + enabled: false server: port: 8080 diff --git a/review-service/Dockerfile b/review-service/Dockerfile index 094caa66..96dd37dc 100644 --- a/review-service/Dockerfile +++ b/review-service/Dockerfile @@ -43,4 +43,6 @@ EXPOSE 8080 # Run the application ENTRYPOINT ["bash", "-c", \ -"java --enable-preview ${JAVA_OPTS} org.springframework.boot.loader.JarLauncher ${0} ${@}"] \ No newline at end of file +"java -server --enable-preview -XX:+UseContainerSupport \ +-XX:+AlwaysActAsServerClassMachine -XX:+UseG1GC -XX:+UseStringDeduplication ${JAVA_OPTS} \ +org.springframework.boot.loader.JarLauncher ${0} ${@}"] \ No newline at end of file diff --git a/review-service/src/main/resources/application.yaml b/review-service/src/main/resources/application.yaml index b8c4baaa..21f2c40b 100644 --- a/review-service/src/main/resources/application.yaml +++ b/review-service/src/main/resources/application.yaml @@ -26,6 +26,8 @@ management: --- spring: profiles: docker + jmx: + enabled: false server: port: 8080 \ No newline at end of file diff --git a/test-em-all.sh b/test-em-all.sh index 0bfa7cae..9413eb9f 100644 --- a/test-em-all.sh +++ b/test-em-all.sh @@ -5,7 +5,7 @@ # for local run # HOST=localhost PORT=9080 ./test-em-all.bash # with docker compose -# HOST=localhost PORT=8080 ./test-em-all.bash start stop +# HOST=localhost PORT=8080 ./test-em-all.bash start stop # echo -e "Starting [Springy Store] full functionality testing....\n" From 4296fb5528ee27edf79135db9ff97a60919c024a Mon Sep 17 00:00:00 2001 From: Mohamed Taman Date: Sun, 5 Apr 2020 16:42:03 +0200 Subject: [PATCH 8/8] Adding maven docker plugin - 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. --- product-composite-service/Dockerfile | 13 +++-- product-composite-service/pom.xml | 5 ++ product-service/Dockerfile | 14 +++-- product-service/pom.xml | 5 ++ recommendation-service/Dockerfile | 12 +++-- recommendation-service/pom.xml | 5 ++ review-service/Dockerfile | 12 +++-- review-service/pom.xml | 5 ++ store-api/pom.xml | 2 +- store-chassis/pom.xml | 80 ++++++++++++++++++++++++++-- store-utils/pom.xml | 2 +- 11 files changed, 134 insertions(+), 21 deletions(-) diff --git a/product-composite-service/Dockerfile b/product-composite-service/Dockerfile index 30212339..eb7ba1d7 100644 --- a/product-composite-service/Dockerfile +++ b/product-composite-service/Dockerfile @@ -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 -# 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 " + +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} \ diff --git a/product-composite-service/pom.xml b/product-composite-service/pom.xml index 658dd259..adc103f4 100644 --- a/product-composite-service/pom.xml +++ b/product-composite-service/pom.xml @@ -14,4 +14,9 @@ Product Composite Service Product Composite Service Spring Boot based project + + false + false + + diff --git a/product-service/Dockerfile b/product-service/Dockerfile index 30212339..492c8e38 100644 --- a/product-service/Dockerfile +++ b/product-service/Dockerfile @@ -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 -# 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 " + +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} \ diff --git a/product-service/pom.xml b/product-service/pom.xml index cbedb927..654737e2 100644 --- a/product-service/pom.xml +++ b/product-service/pom.xml @@ -14,4 +14,9 @@ Product Service Product Service Spring Boot based project + + false + false + + diff --git a/recommendation-service/Dockerfile b/recommendation-service/Dockerfile index 96dd37dc..75ab08b9 100644 --- a/recommendation-service/Dockerfile +++ b/recommendation-service/Dockerfile @@ -20,8 +20,12 @@ RUN java -Djarmode=layertools -jar --enable-preview application.jar extract FROM openjdk:14-slim-buster MAINTAINER Mohamed Taman -# 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 " + +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} \ diff --git a/recommendation-service/pom.xml b/recommendation-service/pom.xml index dbded8af..c9106565 100644 --- a/recommendation-service/pom.xml +++ b/recommendation-service/pom.xml @@ -14,4 +14,9 @@ Recommendation Service Recommendation Service Spring Boot based project + + false + false + + diff --git a/review-service/Dockerfile b/review-service/Dockerfile index 96dd37dc..37564580 100644 --- a/review-service/Dockerfile +++ b/review-service/Dockerfile @@ -20,8 +20,12 @@ RUN java -Djarmode=layertools -jar --enable-preview application.jar extract FROM openjdk:14-slim-buster MAINTAINER Mohamed Taman -# 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 " + +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} \ diff --git a/review-service/pom.xml b/review-service/pom.xml index ab68e6bb..653471f6 100644 --- a/review-service/pom.xml +++ b/review-service/pom.xml @@ -14,4 +14,9 @@ Review Service Review Service Spring Boot based project + + false + false + + diff --git a/store-api/pom.xml b/store-api/pom.xml index 40e06f27..43c417bb 100644 --- a/store-api/pom.xml +++ b/store-api/pom.xml @@ -17,7 +17,7 @@ UTF-8 UTF-8 - 2.2.3.BUILD-SNAPSHOT + 2.3.0.M3 3.8.1 3.0.0-M4 3.0.0-M4 diff --git a/store-chassis/pom.xml b/store-chassis/pom.xml index d5497379..e181abfc 100644 --- a/store-chassis/pom.xml +++ b/store-chassis/pom.xml @@ -1,13 +1,12 @@ - 4.0.0 org.springframework.boot spring-boot-starter-parent - - 2.3.0.M2 + 2.3.0.M4 @@ -31,6 +30,19 @@ 14 UTF-8 UTF-8 + + + 1.4.13 + + + Mohamed Taman + mohamed.taman@gmail.com + siriusxi + latest + true + true + true + true @@ -101,7 +113,9 @@ spring-boot-maven-plugin - LAYERED_JAR + + true + @@ -127,6 +141,62 @@ + + + com.spotify + dockerfile-maven-plugin + ${dockerfile-maven-version} + + + build-image + package + + build + + + ${skip.image.build} + ${docker.repo.image.prefix}/${project.artifactId} + ${docker.image.default.tag} + + + + tag-image + package + + tag + + + ${skip.image.tag} + ${project.version} + + + + push-image + verify + + push + + + ${skip.image.push} + ${project.version} + + + + + ${skip.dockerization} + Dockerfile + ${docker.repo.image.prefix}/${project.artifactId} + true + + target/${project.build.finalName}.jar + ${project.version} + ${project.name} + "${maintainer.name} (${maintainer.email})" + + + + + diff --git a/store-utils/pom.xml b/store-utils/pom.xml index aacd0357..d0ce4fa9 100644 --- a/store-utils/pom.xml +++ b/store-utils/pom.xml @@ -17,7 +17,7 @@ UTF-8 UTF-8 - 2.2.3.BUILD-SNAPSHOT + 2.3.0.M3 3.8.1 3.0.0-M4 3.0.0-M4