Skip to content

Commit

Permalink
Merge branch 'release/0.0.2' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
johnnymillergh committed Jul 16, 2021
2 parents d76d3e5 + 50b4e74 commit 922297f
Show file tree
Hide file tree
Showing 609 changed files with 17,077 additions and 18,213 deletions.
13 changes: 13 additions & 0 deletions .drone.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
kind: pipeline
type: exec
name: default

platform:
os: linux
arch: amd64

steps:
- name: greeting
commands:
- echo HELLO WORLD! Drone on Docker
496 changes: 496 additions & 0 deletions .editorconfig

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion .travis/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ command "ls"

printInfo "[INSTALL] Start to run Maven clean, install…"
# Run the Maven clean install
./mvnw clean install --batch-mode --show-version -DskipTests=true -Dmaven.javadoc.skip=true -Djib.to.auth.username=$DOCKER_HUB_USERNAME -Djib.to.auth.password=$DOCKER_HUB_PASSWORD
./mvnw clean install --batch-mode --show-version --quiet -DskipTests=true -Dmaven.javadoc.skip=true -Djib.to.auth.username=$DOCKER_HUB_USERNAME -Djib.to.auth.password=$DOCKER_HUB_PASSWORD
INSTALL_COMMAND_RESULT=$?
if [ "$INSTALL_COMMAND_RESULT" -eq 0 ]; then
printInfo "[INSTALL] Installation succeed. INSTALL_COMMAND_RESULT: $INSTALL_COMMAND_RESULT"
Expand Down
482 changes: 471 additions & 11 deletions CHANGELOG.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@
same "printed page" as the copyright notice for easier
identification within third-party archives.

Copyright 2020 Johnny Miller (鍾俊)
Copyright 2020 Johnny Miller (锺俊)

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
92 changes: 76 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,35 +26,43 @@ Here is the highlights of **Muscle and Fitness Server**:

2. [Spring Cloud](https://spring.io/projects/spring-cloud) Feature:

- Eureka - Service registration and discovery.

- Consul - Service registration and discovery.
- Spring Cloud Gateway - API Gateway on top of Spring WebFlux. Provide a simple, yet effective way to route to APIs and provide cross cutting concerns to them such as: security, monitoring/metrics, and resiliency.
- Spring Cloud OpenFeign - Declarative REST Client: Feign creates a dynamic implementation of an interface decorated with JAX-RS or Spring MVC annotations. Enhanced connection by Okhttp 3.
- Spring Boot Admin - Admin UI for administration of spring boot applications.
- Zipkin - a distributed tracing system. It helps gather timing data needed to troubleshoot latency problems in service architectures.

- Spring Cloud OpenFeign - Declarative REST Client: Feign creates a dynamic implementation of an interface decorated with JAX-RS or Spring MVC annotations.
3. Secured API. RBAC control by API gateway and Auth Center. JWT authentication, and RBAC authorization.

- Spring Cloud Gateway - provide a simple, yet effective way to route to APIs and provide cross cutting concerns to them such as: security, monitoring/metrics, and resiliency.
4. Higher-level packaging other libraries: `Spring Cloud Starter`, auto configuration for Spring Cloud services.

- Zipkin - a distributed tracing system. It helps gather timing data needed to troubleshoot latency problems in service architectures.
5. MySQL cluster support. Multi data source. Dynamic SQL read-write isolation. MyBatis-Plus is the integrated ORM library.

6. Redis 6.x support.

7. Docker, Rancher Kubernetes support. Google JIB for building Docker container images.

3. Docker support.
8. OSS service, based on Minio and SFTP integration.

4. Multi-environment support.
9. STOMP over WebSocket (SockJS), real time messaging, based on RabbitMQ STOMP message broker.

5. SFTP integration.
10. Quartz support. Distributed job scheduling, based on JDBC.

6. API visualization. Enhanced Swagger API documentation.
11. Multi-environment support.

7. Log compression.
12. API visualization. Enhanced Swagger API documentation.

8. Request log.
13. Log compression. ELK log aggregation.

9. Method Argument Validation Aspect.
14. Request log.

10. Docker container log persistence.
15. Method Argument Validation Aspect.

11. Startup statistics.
16. Docker container log persistence.

12. Customized startup banner.
17. Startup statistics.

18. Customized startup banner.

## Usage

Expand All @@ -68,6 +76,59 @@ Here is the highlights of **Muscle and Fitness Server**:

3. Click the green triangle to Run.

## Useful Commands

### Maven

1. Compile:

```shell
$ mvn clean validate compile --batch-mode --show-version --quiet -f pom.xml
```

2. Package:

```shell
$ mvn clean package --batch-mode --show-version --quiet -f pom.xml
```

3. Set Version:

```sh
$ mvn versions:set -DgenerateBackupPoms=false -f pom.xml
```

4. Build Docker Images:

```shell
$ mvn clean verify --batch-mode --show-version --quiet -f pom.xml
```

### Conventional Changelog CLI

1. Install global dependencies (optional if installed):

```
npm install -g conventional-changelog-cli
```

2. This will *not* overwrite any previous changelogs. The above generates a changelog based on commits since the last semver tag that matches the pattern of "Feature", "Fix", "Performance Improvement" or "Breaking Changes".

```
conventional-changelog -p angular -i CHANGELOG.md -s
```

3. If this is your first time using this tool and you want to generate all previous changelogs, you could do:

```
conventional-changelog -p angular -i CHANGELOG.md -s -r 0
```

## CI (Continuous Integration)

- [Travis CI](https://travis-ci.com/github/johnnymillergh/media-streaming) is for publishing Docker Hub images of SNAPSHOT and RELEASE.
- [GitHub Actions](https://github.com/johnnymillergh/media-streaming/actions) is for checking dependency updates and tests.

## Maintainers

[@johnnymillergh](https://github.com/johnnymillergh).
Expand All @@ -94,4 +155,3 @@ Support this project by becoming a sponsor. Your logo will show up here with a l

2020 - Present


File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@ chcp 65001
@REM #################### Configurable Environment Variables ###################
SET skipGitPull=true
SET skipMavenBuild=true
SET minimalJavaMajorVersion=11
SET javaExe=C:\Users\Johnny\.sdkman\candidates\java\11.0.10.hs-adpt\bin\java.exe
SET mavenActiveProfile="development-local"
SET javaParameter=-Dfile.encoding=UTF-8 -Xms256m -Xmx256m
SET javaParameter=-Xms256m -Xmx256m -Dfile.encoding=UTF-8 -Dspring.cloud.consul.host=localhost

GOTO:MAIN

Expand Down Expand Up @@ -55,6 +57,22 @@ EXIT /B 0

@REM ############################ Custom Functions #############################

@REM Check Java major version
:checkJavaMajorVersion
CALL :logWarn "Start to Check Java major version…"
%javaExe% -version 1>nul 2>nul || (
CALL :logError "Java is not installed!"
EXIT /B 2
)
for /f tokens^=2-6^ delims^=.-_+^" %%j in ('%javaExe% -fullversion 2^>^&1') do set "currentJavaMajorVersion=%%j"
CALL :logWarn "Got current Java major version number: %currentJavaMajorVersion%"
if %currentJavaMajorVersion% LSS %minimalJavaMajorVersion% (
CALL :logError "Current Java version is too low, at least OpenJDK %minimalJavaMajorVersion% is needed"
EXIT /B 1
)
CALL :logInfo "Passed Java major version cheking"
EXIT /B 0

@REM Pull the latest code of current branch from Git.
:gitPull
git pull
Expand All @@ -76,7 +94,7 @@ EXIT /B 0
CALL :gitPull
)
CALL :logInfo "[PRE-BUILD] Java Version Information"
CALL java -version
CALL %javaExe% -version
CALL :logInfo "[PRE-BUILD] Maven Version Information"
CALL mvn -v
CALL :logInfo "[PRE-BUILD] Current directory:"
Expand Down Expand Up @@ -113,14 +131,22 @@ EXIT /B 0
)
CALL :logWarn "[RUN] Found JAR: %jarFileName%"
CALL :setTerminalTitle %jarFileName%
SET runJarCommand=java %javaParameter% -Dspring.profiles.active=%mavenActiveProfile% -jar target\%jarFileName%
SET runJarCommand=%javaExe% %javaParameter% -Dspring.profiles.active=%mavenActiveProfile% -jar target\%jarFileName%
CALL :logWarn "[RUN] Execute command: %runJarCommand%"
CALL %runJarCommand%
EXIT /B 0

@REM ############################# MAIN Procedures #############################
:MAIN
cls

@REM Check Java major version
CALL :checkJavaMajorVersion
if %ERRORLEVEL% NEQ 0 (
CALL :logError "Failed to check Java major version!"
EXIT /B %ERRORLEVEL%
)

@REM Pre-build phrase (Display version, Git pull)
CALL :executePreBuildPhase
if %ERRORLEVEL% NEQ 0 (
Expand Down
72 changes: 37 additions & 35 deletions gateway/pom.xml → api-gateway/pom.xml
Original file line number Diff line number Diff line change
@@ -1,20 +1,16 @@
<?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:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
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>

<!-- Sub-module Basics -->
<artifactId>gateway</artifactId>
<name>Muscle and Fitness Server :: Gateway</name>
<description>Gateway for Muscle and Fitness microservices.</description>
<properties>
<java.version>11</java.version>
<port>8080</port>
</properties>
<artifactId>api-gateway</artifactId>
<name>Muscle and Fitness Server :: API Gateway</name>
<description>API Gateway for Muscle and Fitness microservices.</description>
<parent>
<groupId>com.jmsoftware.maf</groupId>
<artifactId>muscle-and-fitness-server</artifactId>
<version>0.0.1</version>
<version>0.0.2</version>
</parent>

<!-- Build Settings -->
Expand All @@ -23,22 +19,31 @@
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<id>build-info</id>
<phase>compile</phase>
<goals>
<goal>build-info</goal>
</goals>
</execution>
</executions>
</plugin>

<!-- https://github.com/GoogleContainerTools/jib/blob/master/jib-maven-plugin/README.md -->
<plugin>
<groupId>com.google.cloud.tools</groupId>
<artifactId>jib-maven-plugin</artifactId>
<version>2.2.0</version>
<version>${jib-maven-plugin.version}</version>
<executions>
<!-- Bind `jib:dockerBuild` to a Maven lifecycle `verify`. Jib will build your image directly to a Docker daemon. -->
<!-- Bind `jib:dockerBuild` to a Maven lifecycle `verify`. Jib will build your image directly to a Docker daemon.
<execution>
<id>buildDockerImagePhase</id>
<phase>verify</phase>
<goals>
<goal>dockerBuild</goal>
</goals>
</execution>
</execution> -->
<!-- Bind `jib:build` to a Maven lifecycle `install`. Jib will build and push image to image registry. -->
<execution>
<id>buildAndPushDockerImagePhase</id>
Expand All @@ -50,8 +55,8 @@
</executions>
<configuration>
<from>
<!-- https://hub.docker.com/_/openjdk?tab=tags&page=1&ordering=last_updated&name=11.0.9.1-jre-slim -->
<image>openjdk:11.0.9.1-jre-slim</image>
<!-- https://hub.docker.com/r/adoptopenjdk/openjdk11/tags?page=1&ordering=last_updated&name=alpine-jre-11 -->
<image>adoptopenjdk/openjdk11:${adoptopenjdk11.tag}</image>
</from>
<to>
<image>docker.io/ijohnnymiller/${project.parent.artifactId}.${project.artifactId}</image>
Expand All @@ -66,7 +71,7 @@
<jvmFlag>-Dfile.encoding=${project.build.sourceEncoding}</jvmFlag>
</jvmFlags>
<ports>
<port>${gateway.port}</port>
<port>${api-gateway.port}</port>
</ports>
<creationTime>USE_CURRENT_TIMESTAMP</creationTime>
</container>
Expand All @@ -78,40 +83,37 @@
<!-- Scoped Dependencies Management -->
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-gateway</artifactId>
<groupId>com.jmsoftware.maf</groupId>
<artifactId>reactive-spring-cloud-starter</artifactId>
</dependency>

<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
<artifactId>spring-cloud-starter-gateway</artifactId>
</dependency>

<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-zipkin</artifactId>
<groupId>com.github.xiaoymin</groupId>
<artifactId>knife4j-spring-boot-starter</artifactId>
<version>${knife4j.version}</version>
</dependency>

<!-- Test -->
<dependency>
<groupId>com.jmsoftware.maf</groupId>
<artifactId>common</artifactId>
<version>0.0.1</version>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
</exclusion>
</exclusions>
</dependency>

<dependency>
<groupId>de.codecentric</groupId>
<artifactId>spring-boot-admin-starter-client</artifactId>
<version>${spring-boot-admin.version}</version>
</dependency>

<dependency>
<groupId>com.github.xiaoymin</groupId>
<artifactId>knife4j-spring-boot-starter</artifactId>
<version>${knife4j.version}</version>
<groupId>io.projectreactor</groupId>
<artifactId>reactor-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package com.jmsoftware.maf.apigateway;

import com.jmsoftware.maf.reactivespringcloudstarter.helper.SpringBootStartupHelper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.util.StopWatch;

/**
* <h1>ApiGatewayApplication</h1>
* <p>
* Change description here.
*
* @author Johnny Miller (锺俊), email: johnnysviva@outlook.com, date: 12/22/2020 3:39 PM
**/
@Slf4j
@EnableDiscoveryClient
@SpringBootApplication
public class ApiGatewayApplication {
private static final StopWatch STOP_WATCH = new StopWatch();
private static SpringBootStartupHelper springBootStartupHelper;

public ApiGatewayApplication(SpringBootStartupHelper springBootStartupHelper) {
ApiGatewayApplication.springBootStartupHelper = springBootStartupHelper;
}

public static void main(String[] args) {
STOP_WATCH.start();
SpringApplication.run(ApiGatewayApplication.class, args);
springBootStartupHelper.stop(STOP_WATCH);
}
}
Loading

0 comments on commit 922297f

Please sign in to comment.