From 43adb6d31f95f5062822cc232ef2edb9e2394587 Mon Sep 17 00:00:00 2001 From: Anthony Debucquoy Date: Tue, 27 Feb 2024 16:55:16 +0100 Subject: [PATCH] database on deploy --- backend/compose.yaml | 1 + .../main/java/ovh/herisson/Clyde/JdbcConfig.java | 13 +++++++++++++ 2 files changed, 14 insertions(+) diff --git a/backend/compose.yaml b/backend/compose.yaml index 5257bdf..654ebad 100644 --- a/backend/compose.yaml +++ b/backend/compose.yaml @@ -5,5 +5,6 @@ services: - 'POSTGRES_DB=clyde' - 'POSTGRES_USER=devel' - 'POSTGRES_PASSWORD=devel' + - 'SPRING_PROFILES_ACTIVE=prod' ports: - '5432:5432' diff --git a/backend/src/main/java/ovh/herisson/Clyde/JdbcConfig.java b/backend/src/main/java/ovh/herisson/Clyde/JdbcConfig.java index 56074f0..84c808f 100644 --- a/backend/src/main/java/ovh/herisson/Clyde/JdbcConfig.java +++ b/backend/src/main/java/ovh/herisson/Clyde/JdbcConfig.java @@ -4,6 +4,7 @@ import javax.sql.DataSource; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Profile; import org.springframework.jdbc.datasource.DriverManagerDataSource; import org.springframework.web.servlet.config.annotation.CorsRegistry; import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; @@ -12,6 +13,7 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; public class JdbcConfig { @Bean + @Profile("!prod") public DataSource psqlSource(){ DriverManagerDataSource source = new DriverManagerDataSource(); source.setDriverClassName("org.postgresql.Driver"); @@ -22,6 +24,17 @@ public class JdbcConfig { return source; } + @Bean + @Profile("prod") + public DataSource psqlSourceProd(){ + DriverManagerDataSource source = new DriverManagerDataSource(); + source.setDriverClassName("org.postgresql.Driver"); + source.setUrl("jdbc:postgresql://localhost:5432/clyde"); + source.setUsername("clyde"); + + return source; + } + @Bean public WebMvcConfigurer corsConfigurer() {