diff --git a/docker-compose.yml b/docker-compose.yml index ec34ee6..b92e589 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,6 +1,17 @@ version: "3.9" services: + nginx: + image: nginx:1.25.3 + restart: unless-stopped + volumes: + - ./nginx/templates:/etc/nginx/templates + - ./nginx/configuration/custom_proxy_settings.conf:/etc/nginx/conf.d/custom_proxy_settings.conf + ports: + - "80:80" + networks: + - matcha-network + keycloak: image: quay.io/keycloak/keycloak:21.0.2 command: [ 'start-dev --import-realm' ] diff --git a/nginx/configuration/custom_proxy_settings.conf b/nginx/configuration/custom_proxy_settings.conf new file mode 100644 index 0000000..87153c7 --- /dev/null +++ b/nginx/configuration/custom_proxy_settings.conf @@ -0,0 +1 @@ +client_max_body_size 30m; \ No newline at end of file diff --git a/nginx/templates/default.conf.template b/nginx/templates/default.conf.template new file mode 100644 index 0000000..f788ca4 --- /dev/null +++ b/nginx/templates/default.conf.template @@ -0,0 +1,37 @@ +server { + server_name 127.0.0.11; + + # Docker DNS + resolver 127.0.0.11; + + location /swagger-ui/ { + proxy_pass http://swagger-ui:8090; + } + location /product/ { + proxy_pass http://product; + } +} + +server { + server_name sell; + location / { + proxy_pass http://sell; + } +} + +server { + server_name identity; + large_client_header_buffers 8 32k; + location / { + proxy_pass http://identity; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-Proto $scheme; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + + # Workaround to void CORS error from Reactjs + if ($uri ~ "^(.*)/(protocol/openid-connect/auth|login/oauth2/code)(.*)") { + add_header Access-Control-Allow-Origin *; + } + } +} diff --git a/pom.xml b/pom.xml index a60516a..7c9ae54 100644 --- a/pom.xml +++ b/pom.xml @@ -56,6 +56,7 @@ 0.8.12 0.00 2023.0.3 + 4.0.0 @@ -93,6 +94,11 @@ pom import + + me.paulschwarz + spring-dotenv + ${dotenv-version} + diff --git a/product/.env.sample b/product/.env.sample new file mode 100644 index 0000000..dae11ce --- /dev/null +++ b/product/.env.sample @@ -0,0 +1,3 @@ +SPRING_DATASOURCE_URL= +SPRING_DATA_USERNAME= +SPRING_DATA_PASSWORD= \ No newline at end of file diff --git a/product/.gitignore b/product/.gitignore index 549e00a..221c5f3 100644 --- a/product/.gitignore +++ b/product/.gitignore @@ -31,3 +31,4 @@ build/ ### VS Code ### .vscode/ +.env diff --git a/product/src/main/resources/application.properties b/product/src/main/resources/application.properties deleted file mode 100644 index 81d683e..0000000 --- a/product/src/main/resources/application.properties +++ /dev/null @@ -1,14 +0,0 @@ -spring.application.name=product - -spring.datasource.url=jdbc:postgresql://localhost:5432/product -spring.datasource.username=admin -spring.datasource.password=admin -spring.datasource.driver-class-name=org.postgresql.Driver - -# JPA & Hibernate settings -spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect -spring.jpa.hibernate.ddl-auto=update - -# Optional settings -spring.jpa.show-sql=true -spring.jpa.properties.hibernate.format_sql=true diff --git a/product/src/main/resources/application.yml b/product/src/main/resources/application.yml new file mode 100644 index 0000000..08cb261 --- /dev/null +++ b/product/src/main/resources/application.yml @@ -0,0 +1,20 @@ +spring: + application: + name: product + datasource: + url: ${SPRING_DATASOURCE_URL} + username: ${SPRING_DATA_USERNAME} + password: ${SPRING_DATA_PASSWORD} + driver-class-name: org.postgresql.Driver + + jpa: + properties: + hibernate: + dialect: org.hibernate.dialect.PostgreSQLDialect + format_sql: true + hibernate: + ddl-auto: update + show-sql: true + +server: + port: 8081 diff --git a/product/src/test/resources/application.properties b/product/src/test/resources/application.properties index 5b0d418..822551a 100644 --- a/product/src/test/resources/application.properties +++ b/product/src/test/resources/application.properties @@ -3,11 +3,10 @@ server.servlet.context-path=/product spring.profiles.active=test -spring.data.mongodb.uri=jdbc:h2:mem:testdb;NON_KEYWORDS=VALUE -spring.datasource.driverClassName=org.h2.Driver +spring.datasource.url=jdbc:h2:mem:testdb;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE +spring.datasource.driver-class-name=org.h2.Driver spring.datasource.username=sa spring.datasource.password= -spring.jpa.database-platform=org.hibernate.dialect.H2Dialect +spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.H2Dialect spring.jpa.hibernate.ddl-auto=update -spring.liquibase.enabled=false \ No newline at end of file diff --git a/sell-bff/src/main/resources/application.yaml b/sell-bff/src/main/resources/application.yaml index a5b48d5..ed4d059 100644 --- a/sell-bff/src/main/resources/application.yaml +++ b/sell-bff/src/main/resources/application.yaml @@ -51,10 +51,3 @@ spring: filters: - RewritePath=/api/(?.*), /$\{segment} - TokenRelay= - - id: api - uri: http://api.matcha.local - predicates: - - Path=/api/** - filters: - - RewritePath=/api/(?.*), /$\{segment} - - TokenRelay=