Skip to content

Commit

Permalink
Merge pull request #394 from opexdev/otc
Browse files Browse the repository at this point in the history
Prepare a new environment for the OTC market based on Opex features
  • Loading branch information
fatemeh-i authored Nov 19, 2023
2 parents 547620c + 6851d69 commit dd16c14
Show file tree
Hide file tree
Showing 21 changed files with 315 additions and 27 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
java-version: ${{ matrix.java }}
# cache: maven
- name: Build
run: mvn -B -T 1C clean install
run: mvn -B -T 1C clean install -Potc
- name: Run Tests
run: mvn -B -T 1C -Dskip.unit.tests=false surefire:test
- name: Build Docker images
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ target/
### Other files ###
.env
docker-compose.local.yml
docker-compose-otc.local.yml

docker-compose.legacy.yml
application-local.yml
mvnw
Expand Down
13 changes: 13 additions & 0 deletions docker-compose-otc.build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
version: '3.8'
services:

postgres-opex:
image: ghcr.io/opexdev/postgres-opex:$TAG
build: docker-images/postgres

wallet:
image: ghcr.io/opexdev/wallet:$TAG
build: wallet/wallet-app
vault:
image: ghcr.io/opexdev/vault-opex:$TAG
build: docker-images/vault
15 changes: 15 additions & 0 deletions docker-compose-otc.local.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
version: '3.8'
services:

postgres-wallet:
ports:
- "5435:5432"

wallet:
ports:
- "127.0.0.1:8091:8080"
- "127.0.0.1:1049:5005"
vault:
ports:
- "8200:8200"

14 changes: 14 additions & 0 deletions docker-compose-otc.override.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
version: '3.8'
services:

postgres-opex:
image: ghcr.io/opexdev/postgres-opex
build: docker-images/postgres

wallet:
build: wallet/wallet-app
volumes:
- "./preferences-dev.yml:/preferences.yml"
- "./drive-key.json:/drive-key.json"
vault:
build: docker-images/vault
86 changes: 86 additions & 0 deletions docker-compose-otc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
x-postgres-db: &postgres-db
image: ghcr.io/opexdev/postgres-opex
environment:
- POSTGRES_USER=${DB_USER:-opex}
- POSTGRES_PASSWORD=${DB_PASS:-hiopex}
- POSTGRES_DB=${DB_USER:-opex}
- POSTGRES_READ_ONLY_USER=${DB_READ_ONLY_USER:-opex_reader}
- POSTGRES_READ_ONLY_PASSWORD=${DB_READ_ONLY_PASS:-hiopex}
networks:
- default
deploy:
restart_policy:
condition: on-failure

version: '3.8'
services:
postgres-wallet:
<<: *postgres-db
volumes:
- wallet-data:/var/lib/postgresql/data/

wallet:
image: ghcr.io/opexdev/wallet
environment:
- JAVA_OPTS=-Xmx256m -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:5005
- KAFKA_IP_PORT=kafka-1:29092,kafka-2:29092,kafka-3:29092
- CONSUL_HOST=consul
- DB_IP_PORT=postgres-wallet
- BACKEND_USER=${BACKEND_USER}
- VAULT_HOST=vault
- SWAGGER_AUTH_URL=$KEYCLOAK_FRONTEND_URL
- PREFERENCES=$PREFERENCES
- DRIVE_FOLDER_ID=$DRIVE_FOLDER_ID
- BACKUP_ENABLED=$WALLET_BACKUP_ENABLED
- SPRING_PROFILES_ACTIVE=otc
configs:
- preferences.yml
depends_on:
- postgres-wallet
- vault
networks:
- default
labels:
collect_logs: "true"
deploy:
restart_policy:
condition: on-failure
vault:
image: ghcr.io/opexdev/vault-opex
volumes:
- vault-data:/vault/file
environment:
- VAULT_ADDR=http://0.0.0.0:8200
- PANEL_PASS=${PANEL_PASS}
- BACKEND_USER=${BACKEND_USER}
- SMTP_PASS=${SMTP_PASS}
- DB_USER=${DB_USER:-opex}
- DB_PASS=${DB_PASS:-hiopex}
- DB_READ_ONLY_USER=${DB_READ_ONLY_USER:-opex_reader}
- DB_READ_ONLY_PASS=${DB_READ_ONLY_PASS:-hiopex}
- KEYCLOAK_ADMIN_USERNAME=${KEYCLOAK_ADMIN_USERNAME:-opex-admin}
- KEYCLOAK_ADMIN_PASSWORD=${KEYCLOAK_ADMIN_PASSWORD:-hiopex}
- OPEX_ADMIN_KEYCLOAK_CLIENT_SECRET=${OPEX_ADMIN_KEYCLOAK_CLIENT_SECRET}
- VANDAR_API_KEY=$VANDAR_API_KEY
cap_add:
- IPC_LOCK
deploy:
restart_policy:
condition: on-failure

volumes:

wallet-data:
vault-data:

networks:
default:
driver: bridge
secrets:
opex_dev_crt:
file: opex.dev.crt
private_pem:
file: private.pem
configs:
preferences.yml:
file: preferences.yml
45 changes: 39 additions & 6 deletions wallet/wallet-app/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,42 @@
<name>wallet-app</name>
<description>Wallet management app of Opex</description>

<profiles>
<profile>
<id>otc</id>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-consul-all</artifactId>
<version>3.1.2</version>
<exclusions>
<exclusion>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-consul-binder</artifactId>
</exclusion>
<exclusion>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-bus</artifactId>
</exclusion>
<exclusion>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-consul-config</artifactId>
</exclusion>
<exclusion>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-consul-bus</artifactId>
</exclusion>
</exclusions>
<scope>provided</scope>
</dependency>
</dependencies>
</profile>
</profiles>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-consul-all</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-webflux</artifactId>
Expand Down Expand Up @@ -68,10 +103,7 @@
<groupId>co.nilin.opex.utility.log</groupId>
<artifactId>logging-handler</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-consul-all</artifactId>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
Expand Down Expand Up @@ -154,11 +186,10 @@
<version>1.18.0</version>
<scope>test</scope>
</dependency>


<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-stream</artifactId>
<version>3.2.6</version>
<type>test-jar</type>
<scope>test</scope>
<classifier>test-binder</classifier>
Expand Down Expand Up @@ -192,7 +223,9 @@
<version>5.4.0</version>
<scope>test</scope>
</dependency>

</dependencies>

<dependencyManagement>
<dependencies>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@ import org.springframework.beans.factory.annotation.Autowired
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration
import org.springframework.context.annotation.Primary
import org.springframework.context.annotation.Profile
import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder

@Configuration
@Profile("!otc")
class AppConfig {

@Autowired
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,7 @@ class SecurityConfig(private val webClient: WebClient) {
.webClient(webClient)
.build()
}



}
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@ import org.springframework.cloud.client.loadbalancer.reactive.ReactiveLoadBalanc
import org.springframework.cloud.client.loadbalancer.reactive.ReactorLoadBalancerExchangeFilterFunction
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration
import org.springframework.context.annotation.Profile
import org.springframework.web.reactive.function.client.WebClient

@Configuration
class WebClientConfig {

@Bean
fun webClient(loadBalancerFactory: ReactiveLoadBalancer.Factory<ServiceInstance>): WebClient {
@Profile("!otc")
fun loadBalancedWebClient(loadBalancerFactory: ReactiveLoadBalancer.Factory<ServiceInstance>): WebClient {
return WebClient.builder()
.filter(
ReactorLoadBalancerExchangeFilterFunction(
Expand All @@ -22,4 +24,11 @@ class WebClientConfig {
.build()
}

@Bean
@Profile("otc")
fun webClient(): WebClient {
return WebClient.builder()
.build()
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import org.springframework.scheduling.annotation.Scheduled
import org.springframework.stereotype.Component

@Component
@Profile("!test")
@Profile("!test & !otc")
class PrometheusHealthExtension(
private val registry: MeterRegistry,
private val endpoint: HealthEndpoint
Expand Down
87 changes: 87 additions & 0 deletions wallet/wallet-app/src/main/resources/application-otc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
server.port: 8080
management:
endpoints:
web:
base-path: /actuator
exposure:
include: [ "health", "prometheus", "metrics" ]
endpoint:
health:
show-details: when_authorized
metrics:
enabled: true
prometheus:
enabled: true
spring:
jackson:
serialization:
write-dates-as-timestamps: false
application:
name: opex-wallet
main:
allow-bean-definition-overriding: false
allow-circular-references: true
# kafka:
# bootstrap-servers: ${KAFKA_IP_PORT:localhost:9092}
# consumer:
# group-id: wallet
# r2dbc:
# url: r2dbc:postgresql://${DB_IP_PORT:localhost}/opex
# username: ${dbusername:opex}
# password: ${dbpassword:hiopex}
# initialization-mode: always
cloud:
bootstrap:
enabled: true
vault:
host: ${VAULT_HOST}
port: 8200
scheme: http
authentication: APPID
app-id:
user-id: co.nilin.opex.wallet.app.utils.VaultUserIdMechanism
fail-fast: true
kv:
enabled: true
backend: secret
profile-separator: '/'
application-name: ${spring.application.name}
bus:
enabled: false
consul:
enabled: false

# config:
# enabled: false

# config:
# enabled: false
# consul:


# host: ${CONSUL_HOST:localhost}
# port: 8500
# discovery:
# #healthCheckPath: ${management.context-path}/health
# instance-id: ${spring.application.name}:${server.port}
# healthCheckInterval: 20s
# prefer-ip-address: true

config:
import: vault://secret/${spring.application.name}
app:
auth:
cert-url: lb://opex-auth/auth/realms/opex/protocol/openid-connect/certs
system:
uuid: 1
backup:
enabled: ${BACKUP_ENABLED:false}
drive:
folder: ${DRIVE_FOLDER_ID:-}
logging:
level:
root: INFO
org.apache.kafka: ERROR
co.nilin: INFO
reactor.netty.http.client: INFO
swagger.authUrl: ${SWAGGER_AUTH_URL:https://api.opex.dev/auth}/realms/opex/protocol/openid-connect/token
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import org.springframework.security.web.server.SecurityWebFilterChain
import org.springframework.web.reactive.function.client.WebClient

@EnableWebFluxSecurity
@Profile("test")
class TestProfileSecurityConfig(private val webClient: WebClient) {
@Bean
fun springSecurityFilterChain(http: ServerHttpSecurity): SecurityWebFilterChain? {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import org.junit.jupiter.api.Test
import org.springframework.boot.test.context.SpringBootTest
import org.springframework.cloud.stream.binder.test.TestChannelBinderConfiguration
import org.springframework.context.annotation.Import
import org.springframework.context.annotation.Profile
import org.springframework.kafka.test.context.EmbeddedKafka
import org.springframework.test.annotation.DirtiesContext
import org.springframework.test.context.ActiveProfiles
Expand All @@ -17,6 +18,5 @@ class WalletAppTest {

@Test
fun contextLoad() {

}
}
Loading

0 comments on commit dd16c14

Please sign in to comment.