Skip to content

Commit

Permalink
Merge branch 'release/0.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
mohamed-taman committed Apr 5, 2020
2 parents 5cb24ec + a1ed7e6 commit b05ef3b
Show file tree
Hide file tree
Showing 18 changed files with 496 additions and 14 deletions.
28 changes: 28 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -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
53 changes: 53 additions & 0 deletions product-composite-service/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#### 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

# 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

# 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

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} \
org.springframework.boot.loader.JarLauncher ${0} ${@}"]
5 changes: 5 additions & 0 deletions product-composite-service/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,9 @@
<name>Product Composite Service</name>
<description>Product Composite Service Spring Boot based project</description>

<properties>
<skip.dockerization>false</skip.dockerization>
<skip.image.build>false</skip.image.build>
</properties>

</project>
Original file line number Diff line number Diff line change
@@ -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.Integer",
"description": "Description for app.review-service.port."
}
] }
25 changes: 24 additions & 1 deletion product-composite-service/src/main/resources/application.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,27 @@ app:
port: 9082
review-service:
host: localhost
port: 9083
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
jmx:
enabled: false

server:
port: 8080

app:
product-service:
host: product
port: 8080
recommendation-service:
host: recommendation
port: 8080
review-service:
host: review
port: 8080
54 changes: 54 additions & 0 deletions product-service/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#### Start of builder image
# ------------------------
# Builder stage to prepare application for final image
FROM openjdk:14-slim-buster as builder
WORKDIR temp

# 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
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 <[email protected]>

# 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

# 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

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} \
org.springframework.boot.loader.JarLauncher ${0} ${@}"]
5 changes: 5 additions & 0 deletions product-service/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,9 @@
<name>Product Service</name>
<description>Product Service Spring Boot based project</description>

<properties>
<skip.dockerization>false</skip.dockerization>
<skip.image.build>false</skip.image.build>
</properties>

</project>
14 changes: 13 additions & 1 deletion product-service/src/main/resources/application.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,16 @@ management:
include: "*"
endpoint:
shutdown:
enabled: true
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
jmx:
enabled: false

server:
port: 8080
54 changes: 54 additions & 0 deletions recommendation-service/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#### 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 <[email protected]>

# 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

# 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

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} \
org.springframework.boot.loader.JarLauncher ${0} ${@}"]
5 changes: 5 additions & 0 deletions recommendation-service/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,9 @@
<name>Recommendation Service</name>
<description>Recommendation Service Spring Boot based project</description>

<properties>
<skip.dockerization>false</skip.dockerization>
<skip.image.build>false</skip.image.build>
</properties>

</project>
12 changes: 12 additions & 0 deletions recommendation-service/src/main/resources/application.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,15 @@ 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
jmx:
enabled: false

server:
port: 8080
54 changes: 54 additions & 0 deletions review-service/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#### 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 <[email protected]>

# 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

# 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

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} \
org.springframework.boot.loader.JarLauncher ${0} ${@}"]
5 changes: 5 additions & 0 deletions review-service/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,9 @@
<name>Review Service</name>
<description>Review Service Spring Boot based project</description>

<properties>
<skip.dockerization>false</skip.dockerization>
<skip.image.build>false</skip.image.build>
</properties>

</project>
Loading

0 comments on commit b05ef3b

Please sign in to comment.