Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions api-gateway/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
FROM eclipse-temurin:21-jdk-alpine
LABEL authors="iakovlysenko"
VOLUME /tmp
ARG JAR_FILE=target/api-gateway-1.0-SNAPSHOT.jar
COPY ${JAR_FILE} app.jar
ENTRYPOINT ["java","-jar","/app.jar"]
79 changes: 79 additions & 0 deletions api-gateway/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
<?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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>ru.project.iakov</groupId>
<artifactId>api-gateway</artifactId>
<version>1.0-SNAPSHOT</version>

<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.2.5</version>
<relativePath/>
</parent>

<properties>
<java.version>21</java.version>
<spring-cloud.version>2023.0.1</spring-cloud.version>
</properties>

<build>
<plugins>
<!-- Maven Plugin -->
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>3.2.5</version>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>

<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.11.0</version>
<configuration>
<source>21</source>
<target>21</target>
<annotationProcessorPaths>
<path>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.38</version>
</path>
</annotationProcessorPaths>
</configuration>
</plugin>
</plugins>
</build>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>${spring-cloud.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>

<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-gateway</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package ru.project.iakov.apigateway;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class ApiGatewayApplication {
public static void main(String[] args) {
SpringApplication.run(ApiGatewayApplication.class, args);
}
}
23 changes: 23 additions & 0 deletions api-gateway/src/main/resources/application-docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
server:
port: 8080

spring:
application:
name: api-gateway
cloud:
gateway:
routes:
- id: user-service
uri: lb://user-service
predicates:
- Path=/users/**
- id: notification-service
uri: lb://notification-service
predicates:
- Path=/api/v1/email/**
config:
import: optional:configserver:http://config-server:8888
eureka:
client:
service-url:
defaultZone: http://discovery-server:8761/eureka
23 changes: 23 additions & 0 deletions api-gateway/src/main/resources/application.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
server:
port: 8082
spring:
application:
name: api-gateway
cloud:
gateway:
routes:
- id: user-service
uri: lb://user-service
predicates:
- Path=/users/**
- id: notification-service
uri: lb://notification-service
predicates:
- Path=/api/v1/email/**
config:
import: optional:configserver:http://localhost:8888

eureka:
client:
service-url:
defaultZone: http://localhost:8761/eureka
23 changes: 23 additions & 0 deletions api-gateway/target/classes/application.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
server:
port: 8082
spring:
application:
name: api-gateway
cloud:
gateway:
routes:
- id: user-service
uri: lb://user-service
predicates:
- Path=/users/**
- id: notification-service
uri: lb://notification-service
predicates:
- Path=/api/v1/email/**
config:
import: optional:configserver:http://localhost:8888

eureka:
client:
service-url:
defaultZone: http://localhost:8761/eureka
Binary file not shown.
10 changes: 10 additions & 0 deletions config-repo/application.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
eureka:
client:
register-with-eureka: true
fetch-registry: true
service-url:
defaultZone: http://discovery-server:8761/eureka/

spring:
application:
name: default
6 changes: 6 additions & 0 deletions config-repo/config-server.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
server:
port: 8888

spring:
application:
name: config-server
20 changes: 20 additions & 0 deletions config-repo/notification-service.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
server:
port: 8082

spring:
application:
name: notification-service
mail:
host: smtp.mail.ru
port: 465
username: ${EMAIL_USERNAME}
password: ${EMAIL_PASSWORD}
properties:
mail:
smtp:
auth: true
starttls:
enable: true

kafka:
topic: user-events
17 changes: 17 additions & 0 deletions config-repo/user-service.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
server:
port: 8081

spring:
application:
name: user-service
datasource:
url: jdbc:postgresql://postgres:5432/postgres
username: postgres
password: postgres
jpa:
hibernate:
ddl-auto: update
show-sql: true
properties:
hibernate:
format_sql: true
6 changes: 6 additions & 0 deletions config-server/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
FROM eclipse-temurin:21-jdk-alpine
LABEL authors="iakovlysenko"
VOLUME /tmp
ARG JAR_FILE=target/config-server-1.0-SNAPSHOT.jar
COPY ${JAR_FILE} app.jar
ENTRYPOINT ["java","-jar","/app.jar"]
79 changes: 79 additions & 0 deletions config-server/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
<?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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>ru.project.iakov</groupId>
<artifactId>config-server</artifactId>
<version>1.0-SNAPSHOT</version>

<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.2.5</version>
<relativePath/>
</parent>

<properties>
<java.version>21</java.version>
<spring-cloud.version>2023.0.1</spring-cloud.version>
</properties>

<build>
<plugins>
<!-- Maven Plugin -->
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>3.2.5</version>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>

<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.11.0</version>
<configuration>
<source>21</source>
<target>21</target>
<annotationProcessorPaths>
<path>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.38</version>
</path>
</annotationProcessorPaths>
</configuration>
</plugin>
</plugins>
</build>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>${spring-cloud.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>

<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-config-server</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package ru.project.iakov.configserver;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.config.server.EnableConfigServer;

@SpringBootApplication
@EnableConfigServer
public class ConfigServerApplication {
public static void main(String[] args) {
SpringApplication.run(ConfigServerApplication.class, args);
}
}
15 changes: 15 additions & 0 deletions config-server/src/main/resources/application-docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
server:
port: 8888

spring:
cloud:
config:
server:
native:
search-locations: file:/config


eureka:
client:
service-url:
defaultZone: http://discovery-server:8761/eureka/
14 changes: 14 additions & 0 deletions config-server/src/main/resources/application.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
server:
port: 8888
spring:
application:
name: config-server
cloud:
config:
server:
git:
uri: file:/config
eureka:
client:
service-url:
defaultZone: http://localhost:8761/eureka
14 changes: 14 additions & 0 deletions config-server/target/classes/application.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
server:
port: 8888
spring:
application:
name: config-server
cloud:
config:
server:
git:
uri: file:/config
eureka:
client:
service-url:
defaultZone: http://localhost:8761/eureka
Binary file not shown.
6 changes: 6 additions & 0 deletions discovery-server/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
FROM eclipse-temurin:21-jdk-alpine
LABEL authors="iakovlysenko"
VOLUME /tmp
ARG JAR_FILE=target/discovery-server-1.0-SNAPSHOT.jar
COPY ${JAR_FILE} app.jar
ENTRYPOINT ["java","-jar","/app.jar"]
Loading