Skip to content

Commit

Permalink
Merge branch 'release/4.8'
Browse files Browse the repository at this point in the history
  • Loading branch information
mohamed-taman committed Apr 30, 2020
2 parents 3dc5e0a + 1ae5da4 commit 72f442b
Show file tree
Hide file tree
Showing 33 changed files with 712 additions and 461 deletions.
24 changes: 14 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ Springy Store μService --> Parent folder.
|- store-cloud-chassis --> Cloud services Parent POM, inherit from build contains all cloud libraries
|- store-service-chassis --> Parent POM, inherits from cloud contains all microservices common libraries
|-store-cloud-infra
|- eureka-server --> Service discovery server
|- eureka-server --> Service discovery server
|- edge-server --> API Gateway server
|-store-common
|- store-api --> API Endpoint and services definitions for all microservices
|- store-utils --> Common utilities shared between all components
Expand Down Expand Up @@ -66,7 +67,7 @@ The following topics are going to be covered in this 1st stage (other stages top
- Adding automated tests of microservices in isolation.
- Adding semi-automated tests to a microservice landscape.

### System Boundary - μServices Landscape (Release 4.5-Latest)
### System Boundary - μServices Landscape (Release 4.8-Latest)

![System Boundary](docs/stage1/app_ms_landscape.png)

Expand Down Expand Up @@ -158,7 +159,7 @@ All build commands and test suite for each microservice should run successfully,

```bash
---------------< com.siriusxi.ms.store:store-aggregator >---------------
[INFO] Building Springy Store Aggregator 1.0-SNAPSHOT [11/11]
[INFO] Building Springy Store Aggregator 1.0-SNAPSHOT [12/12]
[INFO] --------------------------------[ pom ]---------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ store-aggregator ---
Expand All @@ -175,6 +176,7 @@ All build commands and test suite for each microservice should run successfully,
[INFO] Recommendation Service ............................. SUCCESS [ 8.463 s]
[INFO] Store Service ...................................... SUCCESS [ 8.927 s]
[INFO] Eureka Discovery Server ............................ SUCCESS [ 6.536 s]
[INFO] Edge Server ........................................ SUCCESS [ 32.108 s]
[INFO] Springy Store Aggregator ........................... SUCCESS [ 0.100 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
Expand All @@ -198,6 +200,7 @@ All the **services**, **databases**, and **messaging service** will run in paral
```bash
Creating network "ssm_default" with the default driver
Creating ssm_eureka_1 ... done
Creating ssm_gateway_1 ... done
Creating ssm_mysql_1 ... done
Creating ssm_mongodb_1 ... done
Creating ssm_rabbitmq_1 ... done
Expand Down Expand Up @@ -235,7 +238,7 @@ This will result in the following response:
{
"status":"UP",
"components":{
"Core System Microservices":{
"System Microservices":{
"status":"UP",
"components":{
"Product Service":{
Expand Down Expand Up @@ -278,7 +281,7 @@ The result will look like this:
```bash
Starting [Springy Store] full functionality testing....
Start: Sun, Apr 12, 2020 2:34:19 PM
Start: Sun, Apr 30, 2020 2:34:19 PM
HOST=localhost
PORT=8080
Wait for: curl http://localhost:8080/actuator/health ... Ok
Expand All @@ -302,13 +305,13 @@ Test OK (HTTP Code: 422, {"httpStatus":"UNPROCESSABLE_ENTITY","message":"Invalid
Test OK (actual value: "Invalid productId: -1")
Test OK (HTTP Code: 400, {"timestamp":"2020-04-12T12:34:26.471+00:00","path":"/store/api/v1/products/invalidProductId","status":400,"error":"Bad Request","message":"Type mismatch.","requestId":"044dcdf2-13"})
Test OK (actual value: "Type mismatch.")
End: Sun, Apr 12, 2020 2:34:26 PM
End: Sun, Apr 30, 2020 2:34:26 PM
```
### Closing The Story
Finally, to close the story, we will need to shut down Microservices manually service by service
, hahaha just kidding, run the following script to shut down them all:
Finally, to close the story, we need to shut down Microservices manually service by service
, hahaha just kidding, run the following command to shut them all:
```bash
mohamed.taman@DTLNV8 ~/springy-store-microservices
Expand All @@ -326,6 +329,7 @@ Stopping ssm_store_1 ... done
Stopping ssm_mysql_1 ... done
Stopping ssm_rabbitmq_1 ... done
Stopping ssm_eureka_1 ... done
Stopping ssm_gateway_1 ... done
Removing ssm_recommendation_1 ... done
Removing ssm_product_1 ... done
Removing ssm_review_1 ... done
Expand All @@ -334,11 +338,11 @@ Removing ssm_store_1 ... done
Removing ssm_mysql_1 ... done
Removing ssm_rabbitmq_1 ... done
Removing ssm_eureka_1 ... done
Removing ssm_gateway_1 ... done
Removing network ssm_default
```
### The End
Happy coding :)
# License
Copyright (C) 2017-2020 Mohamed Taman
Licensed under the MIT License.
Copyright (C) 2017-2020 Mohamed Taman, Licensed under the MIT License.
18 changes: 13 additions & 5 deletions docker-compose-kafka.yml
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,6 @@ services:
## Start - Store service definition
store:
build: store-services/store-service
ports:
- "8080:8080"
environment:
- SPRING_PROFILES_ACTIVE=docker
- MANAGEMENT_HEALTH_RABBIT_ENABLED=false
Expand All @@ -115,10 +113,20 @@ services:
## Start - Eureka Service Discovery definition
eureka:
build: store-cloud-infra/eureka-server
ports:
- "8761:8761"
restart: always
restart: on-failure
## End - Eureka Service Discovery definition

## Start - Edge Server definition
gateway:
build: store-cloud-infra/edge-server
ports:
- "8080:8080"
environment:
- SPRING_PROFILES_ACTIVE=docker
depends_on:
- eureka
restart: on-failure
## End - Edge Server definition
# End - Cloud Infrastructure

# Start - Data and transport Infrastructure
Expand Down
16 changes: 12 additions & 4 deletions docker-compose-partitions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,6 @@ services:
## Start - Store service definition
store:
build: store-services/store-service
ports:
- "8080:8080"
environment:
- SPRING_PROFILES_ACTIVE=docker
- SPRING_CLOUD_STREAM_BINDINGS_OUTPUT-PRODUCTS_PRODUCER_PARTITION-KEY-EXPRESSION=payload.key
Expand All @@ -101,10 +99,20 @@ services:
## Start - Eureka Service Discovery definition
eureka:
build: store-cloud-infra/eureka-server
ports:
- "8761:8761"
restart: always
## End - Eureka Service Discovery definition

## Start - Edge Server definition
gateway:
build: store-cloud-infra/edge-server
ports:
- "8080:8080"
environment:
- SPRING_PROFILES_ACTIVE=docker
depends_on:
- eureka
restart: on-failure
## End - Edge Server definition
# End - Cloud Infrastructure

# Start - Data and transport Infrastructure
Expand Down
16 changes: 12 additions & 4 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@ services:
## Start - Store service definition
store:
build: store-services/store-service
ports:
- "8080:8080"
environment:
- SPRING_PROFILES_ACTIVE=docker
depends_on:
Expand All @@ -49,10 +47,20 @@ services:
## Start - Eureka Service Discovery definition
eureka:
build: store-cloud-infra/eureka-server
ports:
- "8761:8761"
restart: on-failure
## End - Eureka Service Discovery definition

## Start - Edge Server definition
gateway:
build: store-cloud-infra/edge-server
ports:
- "8080:8080"
environment:
- SPRING_PROFILES_ACTIVE=docker
depends_on:
- eureka
restart: on-failure
## End - Edge Server definition
# End - Cloud Infrastructure

# Start - Data and transport Infrastructure
Expand Down
Binary file modified docs/stage1/app_ms_landscape.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed docs/stage1/springy_store_project_structure.png
Binary file not shown.
1 change: 1 addition & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
<module>store-services/recommendation-service</module>
<module>store-services/store-service</module>
<module>store-cloud-infra/eureka-server</module>
<module>store-cloud-infra/edge-server</module>


</modules>
Expand Down
8 changes: 8 additions & 0 deletions store-base/store-cloud-chassis/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,14 @@
<packaging>pom</packaging>

<dependencies>
<!-- Start - Core spring dependencies -->
<!-- Start - Providing some useful infos about the service through REST API -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<!-- End - Providing some useful infos about the service through REST API -->
<!-- Start - Cloud dependencies -->
<!-- Start - Testing dependencies -->
<dependency>
<groupId>org.springframework.boot</groupId>
Expand Down
8 changes: 0 additions & 8 deletions store-base/store-service-chassis/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,6 @@
<packaging>pom</packaging>

<dependencies>
<!-- Start - Core spring dependencies -->
<!-- Start - Providing some useful infos about the service through REST API -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<!-- End - Providing some useful infos about the service through REST API -->
<!-- Start - Cloud dependencies -->
<!-- Start - Spring Stream processing using "RabbitMQ massaging" -->
<dependency>
<groupId>org.springframework.cloud</groupId>
Expand Down
60 changes: 60 additions & 0 deletions store-cloud-infra/edge-server/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#### 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

# Workaround to avoid Copy command failure when directory is not exists.
RUN test ! -d ./snapshot-dependencies \
&& mkdir snapshot-dependencies \
&& echo "Directory [snapshot-dependencies] created."

#### 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
VOLUME /tmp

# Set image information, but could be set to different location from command line
ARG IMAGE_VERSION="1.0-SNAPSHOT"
ARG IMAGE_NAME="Edge Server"
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/spring-boot-loader/ ./
COPY --from=builder temp/application/ ./

# Expose current server to port 8080
EXPOSE 8761

ARG JAVA_OPTS=""

# Run the application with JVM configs if any
ENTRYPOINT ["bash", "-c", \
"java -server --enable-preview -XX:+UseContainerSupport -XX:+ShowCodeDetailsInExceptionMessages \
-XX:+AlwaysActAsServerClassMachine -XX:+UseG1GC -XX:+UseStringDeduplication ${JAVA_OPTS} \
org.springframework.boot.loader.JarLauncher ${0} ${@}"]
41 changes: 41 additions & 0 deletions store-cloud-infra/edge-server/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?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"
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>com.siriusxi.ms.store</groupId>
<artifactId>store-cloud-chassis</artifactId>
<version>1.0-SNAPSHOT</version>
<relativePath>../store-base/store-cloud-chassis</relativePath>
</parent>

<groupId>com.siriusxi.cloud.infra</groupId>
<artifactId>gateway</artifactId>
<version>1.0-SNAPSHOT</version>
<name>Edge Server</name>
<description>Spring Cloud API Gateway Server, based on Spring boot.</description>
<packaging>jar</packaging>

<dependencies>
<!-- Start - Spring cloud API Gateway server -->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-gateway</artifactId>
</dependency>
<!-- End - Spring cloud API Gateway server -->
<!-- Start - To register API Gateway server with Eureka Discovery Server -->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
</dependency>
<!-- End - To register API Gateway server with Eureka Discovery Server -->
<!-- Start - Javax.validation is required to in order to test to work -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
<scope>runtime</scope>
</dependency>
<!-- End - Javax.validation is required to in order to test to work -->
</dependencies>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.siriusxi.cloud.infra.gateway;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.context.annotation.Bean;
import org.springframework.web.reactive.function.client.WebClient;

@SpringBootApplication
public class EdgeServerApplication {

@Bean
@LoadBalanced
public WebClient.Builder loadBalancedWebClientBuilder() {
return WebClient.builder();
}

public static void main(String[] args) {
SpringApplication.run(EdgeServerApplication.class, args);
}

}
Loading

0 comments on commit 72f442b

Please sign in to comment.