diff --git a/.github/workflows/ci-cd-develop.yml b/.github/workflows/ci-cd-develop.yml index 764bd2e..cd4ae6f 100644 --- a/.github/workflows/ci-cd-develop.yml +++ b/.github/workflows/ci-cd-develop.yml @@ -1,4 +1,4 @@ -name: Auth Server develop CI/CD Pipeline +name: Backend Server develop CI/CD Pipeline on: push: diff --git a/.github/workflows/ci-cd-main.yml b/.github/workflows/ci-cd-main.yml index 38039bd..e39a130 100644 --- a/.github/workflows/ci-cd-main.yml +++ b/.github/workflows/ci-cd-main.yml @@ -1,4 +1,4 @@ -name: Auth Server main CI/CD Pipeline +name: Backend Server main CI/CD Pipeline on: push: @@ -70,4 +70,7 @@ jobs: docker stop backend-service || true docker rm backend-service || true docker pull ${{ secrets.DOCKER_USERNAME }}/cantech:${{ github.sha }} - docker run -d --name backend-service -p 8080:8080 ${{ secrets.DOCKER_USERNAME }}/cantech:${{ github.sha }} + docker run -d --name backend-service -p 8080:8080 \ + -e SPRING_PROFILES_ACTIVE=prod \ + -e CONFIG_SERVER_URL="${{ secrets.CONFIG_SERVER_URL }}" \ + ${{ secrets.DOCKER_USERNAME }}/cantech:${{ github.sha }} diff --git a/build.gradle.kts b/build.gradle.kts index 4abe311..3d9fc70 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -40,6 +40,10 @@ dependencies { // Lombok (테스트 환경) testCompileOnly("org.projectlombok:lombok") testAnnotationProcessor("org.projectlombok:lombok") + + // Spring Cloud Config + implementation("org.springframework.cloud:spring-cloud-starter-config") + testImplementation("com.h2database:h2") } dependencyManagement { diff --git a/src/main/resources/application-dev.properties b/src/main/resources/application-dev.properties index 7e717be..8af1165 100644 --- a/src/main/resources/application-dev.properties +++ b/src/main/resources/application-dev.properties @@ -1,5 +1,16 @@ +spring.config.import=optional:configserver: + +eureka.client.register-with-eureka=true +eureka.client.fetch-registry=true eureka.client.service-url.defaultZone=${EUREKA_SERVER_URL} +spring.datasource.driver-class-name=org.postgresql.Driver spring.datasource.url=${DATABASE_URL} spring.datasource.username=${DATABASE_USERNAME} -spring.datasource.password=${DATABASE_PASSWORD} \ No newline at end of file +spring.datasource.password=${DATABASE_PASSWORD} + +spring.jpa.database=postgresql +spring.jpa.hibernate.ddl-auto=none +spring.jpa.show-sql=true + +server.port=8082 \ No newline at end of file diff --git a/src/main/resources/application-prod.properties b/src/main/resources/application-prod.properties index 7e717be..e53955b 100644 --- a/src/main/resources/application-prod.properties +++ b/src/main/resources/application-prod.properties @@ -1,5 +1 @@ -eureka.client.service-url.defaultZone=${EUREKA_SERVER_URL} - -spring.datasource.url=${DATABASE_URL} -spring.datasource.username=${DATABASE_USERNAME} -spring.datasource.password=${DATABASE_PASSWORD} \ No newline at end of file +spring.config.import=optional:configserver:${CONFIG_SERVER_URL} \ No newline at end of file diff --git a/src/main/resources/application-test.properties b/src/main/resources/application-test.properties new file mode 100644 index 0000000..5ba5801 --- /dev/null +++ b/src/main/resources/application-test.properties @@ -0,0 +1,7 @@ +spring.datasource.url=${DATABASE_URL:jdbc:h2:mem:testdb} +spring.datasource.username=${DATABASE_USERNAME:sa} +spring.datasource.password=${DATABASE_PASSWORD:} +spring.jpa.database-platform=org.hibernate.dialect.H2Dialect + +spring.cloud.config.enabled=false +eureka.client.enabled=false diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 909fe06..34ff745 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -1,11 +1,3 @@ -spring.application.name=backend-service -server.port=8082 +spring.application.name=back -eureka.client.register-with-eureka=true -eureka.client.fetch-registry=true - -spring.jpa.database=postgresql -spring.jpa.hibernate.ddl-auto=none -spring.jpa.show-sql=true - -spring.datasource.driver-class-name=org.postgresql.Driver \ No newline at end of file +spring.profiles.active=${SPRING_PROFILES_ACTIVE:dev} diff --git a/src/test/java/com/cantech/backend/backend_service/BackendServiceApplicationTests.java b/src/test/java/com/cantech/backend/backend_service/BackendServiceApplicationTests.java index 589e4e1..9664dd4 100644 --- a/src/test/java/com/cantech/backend/backend_service/BackendServiceApplicationTests.java +++ b/src/test/java/com/cantech/backend/backend_service/BackendServiceApplicationTests.java @@ -2,8 +2,10 @@ import org.junit.jupiter.api.Test; import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.ActiveProfiles; @SpringBootTest +@ActiveProfiles("test") class BackendServiceApplicationTests { @Test