Skip to content

Commit

Permalink
Merge pull request #40 from MichiBaum/develop
Browse files Browse the repository at this point in the history
Update from Develop
  • Loading branch information
MichiBaum authored Oct 25, 2024
2 parents e616edb + 3a72dc2 commit d833e44
Show file tree
Hide file tree
Showing 290 changed files with 176,506 additions and 3,113 deletions.
14 changes: 14 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -1,7 +1,21 @@
SPRING_ACTIVE_PROFILES=prod

DISCORD_BOT_TOKEN=PleaseChangeMe
DISCORD_GUILD_ID=PleaseChangeMe
DISCORD_REGISTRY_SERVICE_LOG_CHANNEL=PleaseChangeMe
DISCORD_USERMANAGEMENT_SERVICE_LOG_CHANNEL=PleaseChangeMe
DISCORD_WEBSITE_SERVICE_LOG_CHANNEL=PleaseChangeMe
DISCORD_JAVADOC_SERVICE_LOG_CHANNEL=PleaseChangeMe
DISCORD_CHESS_SERVICE_LOG_CHANNEL=PleaseChangeMe
DISCORD_GATEWAY_SERVICE_LOG_CHANNEL=PleaseChangeMe
DISCORD_AUTHENTICATION_SERVICE_LOG_CHANNEL=PleaseChangeMe
DISCORD_ADMIN_SERVICE_LOG_CHANNEL=PleaseChangeMe

USERMANAGEMENT_DB_PASSWORD=PleaseChangeMe
USERMANAGEMENT_DB=usermanagement

AUTHENTICATION_DB_PASSWORD=PleaseChangeMe
AUTHENTICATION_DB=authentication

CHESS_DB_PASSWORD=PleaseChangeMe
CHESS_DB=chess
2 changes: 2 additions & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
buy_me_a_coffee: michibaum
github: MichiBaum
8 changes: 1 addition & 7 deletions .github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ on:
push:
branches:
- master
- develop

jobs:
build:
Expand All @@ -31,9 +30,4 @@ jobs:
run: npm run --prefix website build-production

- name: Maven package
run: |
if [[ "${{github.ref}}" == "refs/heads/develop" ]]; then
mvn test
else
mvn package -DdockerHub.username=${{secrets.DOCKER_USERNAME}} -DdockerHub.password=${{secrets.DOCKER_PASSWORD}}
fi
run: mvn package -Ppublish-image -DdockerHub.username=${{secrets.DOCKER_USERNAME}} -DdockerHub.password=${{secrets.DOCKER_PASSWORD}}
4 changes: 2 additions & 2 deletions .github/workflows/sonarqube.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: |
mvn clean compile -DdockerHub.username=${{secrets.DOCKERHUB_USERNAME}} -DdockerHub.password=${{secrets.DOCKERHUB_PASSWORD}} -DdockerHub.publish=false
mvn sonar:sonar -Dsonar.projectKey=MichiBaum_Microservices
mvn clean verify -fn -Psonar-report
mvn sonar:sonar -Psonar-report -Dsonar.projectKey=MichiBaum_Microservices
16 changes: 16 additions & 0 deletions .run/All Project Tests.run.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="All Project Tests" type="JUnit" factoryName="JUnit">
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="true" />
<option name="ALTERNATIVE_JRE_PATH" value="openjdk-21" />
<option name="PACKAGE_NAME" value="com.michibaum" />
<option name="MAIN_CLASS_NAME" value="" />
<option name="METHOD_NAME" value="" />
<option name="TEST_OBJECT" value="package" />
<option name="TEST_SEARCH_SCOPE">
<value defaultName="wholeProject" />
</option>
<method v="2">
<option name="Make" enabled="true" />
</method>
</configuration>
</component>
19 changes: 19 additions & 0 deletions .run/All UT.run.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="All UT" type="JUnit" factoryName="JUnit">
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="true" />
<option name="ALTERNATIVE_JRE_PATH" value="openjdk-21" />
<option name="PACKAGE_NAME" value="com.michibaum" />
<option name="MAIN_CLASS_NAME" value="" />
<option name="METHOD_NAME" value="" />
<option name="TEST_OBJECT" value="pattern" />
<option name="TEST_SEARCH_SCOPE">
<value defaultName="wholeProject" />
</option>
<patterns>
<pattern testClass="^(.*UT$).*$" />
</patterns>
<method v="2">
<option name="Make" enabled="true" />
</method>
</configuration>
</component>
31 changes: 23 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@



This project is all about microservices and microfrontends.
This project is all about microservices. Frontend is currently build with Angular.
There are microservices build with spring, spring cloud and so forth.

## Available Microservices
## Modules
There are these microservices:
- [Admin Service](./admin-service/README.md)
- [Authentication Service](./authentication-service/README.md)
Expand All @@ -25,6 +25,13 @@ There are these microservices:
- [Registry Service](./registry-service/README.md)
- [Usermanagement Service](./usermanagement-service/README.md)
- [Website Service](./website-service/README.md)
- [Chess Service](./chess-service/README.md)

And these libraries
- [Authentication Library](./authentication-library/README.md)
- [Permission Library](./permission-library/README.md)
- [Usermanagement Library](./usermanagement-library/README.md)
- [Spring Boot Starter Discord](./spring-boot-starter-discord/README.md)

## Release

Expand All @@ -38,11 +45,6 @@ There are these microservices:

mvnw javadoc:aggregate

### Build & Push docker images
Build docker images:

mvnw spring-boot:build-image --projects ./admin-service,./javadoc-service,./registry-service -DdockerHub.username=YourDockerHubUsername -DdockerHub.password=YourDockerHubPassword

### Container

#### Up
Expand All @@ -61,7 +63,7 @@ Build docker images:
# Single container
docker compose logs ´name´

### Change HOSTS file
### Change HOSTS file (for dev on local machine)
*Remember to take Backup before editing your `hosts` file, mistakes there can block your internet access or cause other network-related issues.*


Expand All @@ -70,6 +72,7 @@ Build docker images:
In *C:\Windows\System32\drivers\etc* find file *hosts* and add those lines:

# Microservices
127.0.0.1 chess.michibaum.ch
127.0.0.1 gateway.michibaum.ch
127.0.0.1 registry.michibaum.ch
127.0.0.1 admin.michibaum.ch
Expand All @@ -87,6 +90,18 @@ File: */etc/hosts*

docker scan YourDockerHubUsername/DockerHubRepository:TagName --dependency-tree

## Local DB

docker run --name microservices -e MYSQL_ROOT_PASSWORD=someRootPass -p 3306:3306 -d mysql:9.0.1

After that create the databases in the container.
The tables are created trough

spring
jpa:
hibernate:
ddl-auto: update

## License

[![GitHub license](https://badgen.net/github/license/MichiBaum/Microservices)](https://github.com/MichiBaum/Microservices/blob/master/LICENSE)
Expand Down
93 changes: 57 additions & 36 deletions admin-service/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
</dependency>
<dependency>
<groupId>com.github.ben-manes.caffeine</groupId>
<artifactId>caffeine</artifactId>
</dependency>

<!-- Cluster replication -->
<dependency>
Expand All @@ -55,6 +59,12 @@
<optional>true</optional>
</dependency>

<dependency>
<groupId>com.michibaum</groupId>
<artifactId>spring-boot-starter-discord</artifactId>
<version>1.0.0-TEST-9</version>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
Expand All @@ -68,49 +78,60 @@
</dependency>
</dependencies>

<profiles>
<profile>
<id>publish-image</id>
<build>
<plugins>
<plugin>
<groupId>com.google.cloud.tools</groupId>
<artifactId>jib-maven-plugin</artifactId>
<version>3.4.3</version>
<configuration>
<from>
<image>eclipse-temurin:21-jre</image>
<auth>
<!--suppress UnresolvedMavenProperty -->
<username>${dockerHub.username}</username>
<!--suppress UnresolvedMavenProperty -->
<password>${dockerHub.password}</password>
</auth>
</from>
<to>
<!--suppress UnresolvedMavenProperty -->
<image>docker.io/${dockerHub.username}/${project.artifactId}</image>
<auth>
<!--suppress UnresolvedMavenProperty -->
<username>${dockerHub.username}</username>
<!--suppress UnresolvedMavenProperty -->
<password>${dockerHub.password}</password>
</auth>
</to>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>build</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>

<build>
<sourceDirectory>src/main/kotlin</sourceDirectory>
<sourceDirectory>${project.basedir}/src/main/kotlin</sourceDirectory>
<testSourceDirectory>${project.basedir}/src/test/kotlin</testSourceDirectory>
<resources>
<resource>
<directory>src/main/resources</directory>
<directory>${project.basedir}/src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
<plugins>
<plugin>
<groupId>com.google.cloud.tools</groupId>
<artifactId>jib-maven-plugin</artifactId>
<version>3.4.3</version>
<configuration>
<from>
<image>eclipse-temurin:21-jre</image>
<auth>
<!--suppress UnresolvedMavenProperty -->
<username>${dockerHub.username}</username>
<!--suppress UnresolvedMavenProperty -->
<password>${dockerHub.password}</password>
</auth>
</from>
<to>
<!--suppress UnresolvedMavenProperty -->
<image>docker.io/${dockerHub.username}/${project.artifactId}</image>
<auth>
<!--suppress UnresolvedMavenProperty -->
<username>${dockerHub.username}</username>
<!--suppress UnresolvedMavenProperty -->
<password>${dockerHub.password}</password>
</auth>
</to>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>build</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>io.github.git-commit-id</groupId>
<artifactId>git-commit-id-maven-plugin</artifactId>
Expand Down
8 changes: 8 additions & 0 deletions admin-service/src/main/resources/application-prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@ server:
port: 80

spring:
microservices:
discord:
enabled: true
bot-token: ${DISCORD_BOT_TOKEN}
guild-id: ${DISCORD_GUILD_ID}
logging:
enabled: true
channel-id: ${DISCORD_ADMIN_SERVICE_LOG_CHANNEL}
boot:
admin:
ui:
Expand Down
2 changes: 2 additions & 0 deletions admin-service/src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ spring:
client:
health-indicator:
include-description: true
openfeign:
lazy-attributes-resolution: true
main:
allow-bean-definition-overriding: true

Expand Down
12 changes: 12 additions & 0 deletions admin-service/src/main/resources/logback-spring.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,21 @@
</encoder>
</appender>

<appender name="Discord" class="com.michibaum.discord.logging.DiscordAppenderDelegator"/>

<!-- LOG everything at INFO level -->
<root level="info">
<appender-ref ref="Console" />
</root>

<logger name="com.michibaum" level="WARN">
<appender-ref ref="Console" />
<appender-ref ref="Discord" />
</logger>

<logger name="org.springframework" level="ERROR">
<appender-ref ref="Console" />
<appender-ref ref="Discord" />
</logger>

</configuration>
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.michibaum.admin_service

import org.junit.jupiter.api.Assertions.*
import org.junit.jupiter.api.Test
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.boot.test.context.SpringBootTest
import org.springframework.context.ApplicationContext


@SpringBootTest
class AdminServiceApplicationIT {

@Autowired
lateinit var applicationContext: ApplicationContext

@Test
fun contextLoads() {
assertNotNull(applicationContext)
}
}
1 change: 1 addition & 0 deletions authentication-library/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Authentication library
5 changes: 5 additions & 0 deletions authentication-library/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,9 @@

</dependencies>

<build>
<sourceDirectory>${project.basedir}/src/main/kotlin</sourceDirectory>
<testSourceDirectory>${project.basedir}/src/test/kotlin</testSourceDirectory>
</build>

</project>
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.michibaum.authentication_library

import org.springframework.web.bind.annotation.PostMapping
import org.springframework.web.bind.annotation.GetMapping

interface AuthenticationEndpoints {
@get:PostMapping(value = ["/checkPasword"])
val publicKey: PublicKeyDto?
@GetMapping(value = ["/getAuthDetails"])
fun publicKey(): PublicKeyDto
}
Loading

0 comments on commit d833e44

Please sign in to comment.