Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
MIAGE_GLOP_Banzai_USER_MANAGEMENT
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Package registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Contributor analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Madeline Carpentier
MIAGE_GLOP_Banzai_USER_MANAGEMENT
Commits
d091fc9c
Commit
d091fc9c
authored
3 months ago
by
Abdellatif Kebraoui
Browse files
Options
Downloads
Patches
Plain Diff
[FEAT] implement conditional Eureka client activation based on profiles for cloud deployment
parent
ecc3261e
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
pom.xml
+32
-1
32 additions, 1 deletion
pom.xml
src/main/java/com/miage/glop/config/EurekaConfig.java
+16
-0
16 additions, 0 deletions
src/main/java/com/miage/glop/config/EurekaConfig.java
src/main/resources/application-cloud.yml
+32
-39
32 additions, 39 deletions
src/main/resources/application-cloud.yml
with
80 additions
and
40 deletions
pom.xml
+
32
−
1
View file @
d091fc9c
...
@@ -56,9 +56,17 @@
...
@@ -56,9 +56,17 @@
<artifactId>
spring-boot-starter-data-jpa
</artifactId>
<artifactId>
spring-boot-starter-data-jpa
</artifactId>
</dependency>
</dependency>
<!-- Eureka client - Now conditionally activated based on profile -->
<dependency>
<dependency>
<groupId>
org.springframework.cloud
</groupId>
<groupId>
org.springframework.cloud
</groupId>
<artifactId>
spring-cloud-starter-netflix-eureka-client
</artifactId>
<artifactId>
spring-cloud-starter-netflix-eureka-client
</artifactId>
<!-- Only active in non-cloud profiles -->
<exclusions>
<exclusion>
<groupId>
org.springframework.cloud
</groupId>
<artifactId>
spring-cloud-starter-loadbalancer
</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependency>
<!-- Database drivers -->
<!-- Database drivers -->
...
@@ -67,7 +75,6 @@
...
@@ -67,7 +75,6 @@
<artifactId>
postgresql
</artifactId>
<artifactId>
postgresql
</artifactId>
<version>
42.7.2
</version>
<version>
42.7.2
</version>
</dependency>
</dependency>
<!-- Removing MySQL dependency as PostgreSQL is the preferred DB for cloud deployment -->
<!-- H2 Database for testing -->
<!-- H2 Database for testing -->
<dependency>
<dependency>
...
@@ -155,4 +162,28 @@
...
@@ -155,4 +162,28 @@
</plugin>
</plugin>
</plugins>
</plugins>
</build>
</build>
<!-- Add profiles section to control dependency behavior -->
<profiles>
<profile>
<id>
cloud
</id>
<dependencies>
<!-- In cloud profile, we exclude Eureka client -->
<dependency>
<groupId>
org.springframework.cloud
</groupId>
<artifactId>
spring-cloud-starter-netflix-eureka-client
</artifactId>
<scope>
provided
</scope>
<optional>
true
</optional>
</dependency>
</dependencies>
</profile>
<profile>
<id>
local
</id>
<activation>
<activeByDefault>
true
</activeByDefault>
</activation>
<!-- Local profile uses default dependencies with Eureka enabled -->
</profile>
</profiles>
</project>
</project>
This diff is collapsed.
Click to expand it.
src/main/java/com/miage/glop/config/EurekaConfig.java
0 → 100644
+
16
−
0
View file @
d091fc9c
package
com.miage.glop.config
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.context.annotation.Profile
;
import
org.springframework.cloud.client.discovery.EnableDiscoveryClient
;
/**
* Eureka configuration that's only activated for non-cloud profiles.
* This ensures Eureka client is only used in local development.
*/
@Configuration
@EnableDiscoveryClient
@Profile
(
"!cloud"
)
// Only active when NOT in cloud profile
public
class
EurekaConfig
{
// Configuration is handled through properties files
}
This diff is collapsed.
Click to expand it.
src/main/resources/application-cloud.yml
+
32
−
39
View file @
d091fc9c
server
:
address
:
0.0.0.0
port
:
${PORT:80}
error
:
include-message
:
always
spring
:
spring
:
applicatio
n
:
mai
n
:
name
:
user-management-service
banner-mode
:
OFF
datasource
:
datasource
:
url
:
${SPRING_DATASOURCE_URL:jdbc:postgresql://localhost:5432/userdb}
url
:
jdbc:postgresql://172.29.32.3:5432/bdd_assure
username
:
${SPRING_DATASOURCE_USERNAME:postgres}
username
:
dbuser
password
:
${SPRING_DATASOURCE_PASSWORD:postgres}
password
:
ComplexPassword123!
driver-class-name
:
org.postgresql.Driver
driver-class-name
:
org.postgresql.Driver
jpa
:
jpa
:
hibernate
:
hibernate
:
ddl-auto
:
update
ddl-auto
:
update
show-sql
:
true
properties
:
properties
:
hibernate
:
hibernate
:
dialect
:
org.hibernate.dialect.PostgreSQLDialect
dialect
:
org.hibernate.dialect.PostgreSQLDialect
format_sql
:
true
javax
:
persistence
:
validation
:
mode
:
auto
application
:
name
:
user-management-service
server
:
address
:
0.0.0.0
port
:
${PORT:8080}
# Disable Eureka client for cloud deployment
eureka
:
eureka
:
client
:
client
:
serviceUrl
:
enabled
:
false
defaultZone
:
https://eureka-service-682610574114.europe-west1.run.app/eureka/
register-with-eureka
:
false
registryFetchIntervalSeconds
:
30
fetch-registry
:
false
healthcheck
:
enabled
:
true
# Direct service URLs for Cloud Run
register-with-eureka
:
true
insurance-service
:
fetch-registry
:
true
url
:
https://insurance-service-682610574114.europe-west1.run.app
instance
:
prefer-ip-address
:
true
incident-service
:
hostname
:
${K_SERVICE:user-management-service}.${K_REVISION:default}.${K_CONFIGURATION:default}.run.app
url
:
https://incident-service-682610574114.europe-west1.run.app
secure-port
:
${PORT:80}
secure-port-enabled
:
true
invoice-service
:
non-secure-port-enabled
:
false
url
:
https://invoice-service-682610574114.europe-west1.run.app
instance-id
:
${spring.application.name}:${random.uuid}
ip-address
:
${K_REVISION:localhost}
leaseRenewalIntervalInSeconds
:
30
leaseExpirationDurationInSeconds
:
90
metadataMap
:
instanceId
:
${spring.application.name}:${random.uuid}
management
:
notification-service
:
endpoints
:
url
:
https://notification-service-682610574114.europe-west1.run.app
web
:
exposure
:
include
:
health,info
endpoint
:
health
:
show-details
:
always
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment