From 045f86903218ce5d9232500e1a289c4db157a618 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=ED=99=8D=EC=A0=95=ED=98=84?= <57659252+jhhong0509@users.noreply.github.com> Date: Sun, 4 Sep 2022 20:50:17 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20spring-cloud-config=20=EC=A0=81?= =?UTF-8?q?=EC=9A=A9=20(#82)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/prod-build.yaml | 21 +------- Dockerfile | 42 ++-------------- buildSrc/src/main/kotlin/Dependencies.kt | 3 ++ user-infrastructure/build.gradle.kts | 1 + .../src/main/resources/application.yml | 48 +++---------------- 5 files changed, 17 insertions(+), 98 deletions(-) diff --git a/.github/workflows/prod-build.yaml b/.github/workflows/prod-build.yaml index 834be6e..0bd0440 100644 --- a/.github/workflows/prod-build.yaml +++ b/.github/workflows/prod-build.yaml @@ -56,25 +56,8 @@ jobs: registry: ${{ steps.ecr.outputs.registry }} tags: ${{ steps.get_version.outputs.VERSION }} buildargs: | - DBMS=${{secrets.DBMS_PROD}} - DB_HOST=${{secrets.DB_HOST_PROD}} - DB_PORT=${{secrets.DB_PORT_PROD}} - DB_NAME=${{secrets.DB_NAME_PROD}} - DB_PASSWORD=${{secrets.DB_PASSWORD_PROD}} - DB_USERNAME=${{secrets.DB_USERNAME_PROD}} - SHOW_SQL=${{secrets.SHOW_SQL_PROD}} - DDL_AUTO_MODE=${{secrets.DDL_AUTO_MODE_PROD}} - DB_POOL=${{secrets.DB_POOL_PROD}} - AUTHORITY_SERVICE_HOST=${{secrets.AUTHORITY_SERVICE_HOST}} - APPLICATION_SERVICE_HOST=${{secrets.APPLICATION_SERVICE_HOST}} - JWT_SECRET_KEY=${{secrets.JWT_SECRET_KEY_PROD}} - JWT_ACCESS_TOKEN_EXP_AS_HOUR=${{secrets.JWT_ACCESS_TOKEN_EXP_AS_HOUR_PROD}} - JWT_REFRESH_TOKEN_EXP_AS_HOUR=${{secrets.JWT_REFRESH_TOKEN_EXP_AS_HOUR_PROD}} - REDIS_HOST=${{secrets.REDIS_HOST_PROD}} - REDIS_PORT=${{secrets.REDIS_PORT_PROD}} - REDIS_PASSWORD=${{secrets.REDIS_PASSWORD_PROD}} - AUTHORITY_SERVICE_HOST=${{secrets.AUTHORITY_SERVICE_HOST}} - APPLICATION_SERVICE_HOST=${{secrets.APPLICATION_SERVICE_HOST}} + CLOUD_CONFIG_PASSWORD=${{secrets.CLOUD_CONFIG_PASSWORD}} + CLOUD_CONFIG_USERNAME=${{secrets.CLOUD_CONFIG_USERNAME}} - name: Repository Dispatch uses: peter-evans/repository-dispatch@v1 with: diff --git a/Dockerfile b/Dockerfile index 227811c..1f119c6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,44 +2,10 @@ FROM eclipse-temurin:17-jre-focal EXPOSE 8080 -ARG DBMS -ENV DBMS ${DBMS} -ARG DB_HOST -ENV DB_HOST ${DB_HOST} -ARG DB_PORT -ENV DB_PORT ${DB_PORT} -ARG DB_NAME -ENV DB_NAME ${DB_NAME} -ARG DB_PASSWORD -ENV DB_PASSWORD ${DB_PASSWORD} -ARG DB_USERNAME -ENV DB_USERNAME ${DB_USERNAME} -ARG SHOW_SQL -ENV SHOW_SQL ${SHOW_SQL} -ARG DDL_AUTO_MODE -ENV DDL_AUTO_MODE ${DDL_AUTO_MODE} -ARG DB_POOL -ENV DB_POOL ${DB_POOL} -ARG AUTHORITY_SERVICE_HOST -ENV AUTHORITY_SERVICE_HOST ${AUTHORITY_SERVICE_HOST} -ARG APPLICATION_SERVICE_HOST -ENV APPLICATION_SERVICE_HOST ${APPLICATION_SERVICE_HOST} -ARG JWT_SECRET_KEY -ENV JWT_SECRET_KEY ${JWT_SECRET_KEY} -ARG JWT_ACCESS_TOKEN_EXP_AS_HOUR -ENV JWT_ACCESS_TOKEN_EXP_AS_HOUR ${JWT_ACCESS_TOKEN_EXP_AS_HOUR} -ARG JWT_REFRESH_TOKEN_EXP_AS_HOUR -ENV JWT_REFRESH_TOKEN_EXP_AS_HOUR ${JWT_REFRESH_TOKEN_EXP_AS_HOUR} -ARG REDIS_HOST -ENV REDIS_HOST ${REDIS_HOST} -ARG REDIS_PORT -ENV REDIS_PORT ${REDIS_PORT} -ARG REDIS_PASSWORD -ENV REDIS_PASSWORD ${REDIS_PASSWORD} -ARG AUTHORITY_SERVICE_HOST -ENV AUTHORITY_SERVICE_HOST ${AUTHORITY_SERVICE_HOST} -ARG APPLICATION_SERVICE_HOST -ENV APPLICATION_SERVICE_HOST ${APPLICATION_SERVICE_HOST} +ARG CLOUD_CONFIG_USERNAME +ENV CLOUD_CONFIG_USERNAME ${CLOUD_CONFIG_USERNAME} +ARG CLOUD_CONFIG_PASSWORD +ENV CLOUD_CONFIG_PASSWORD ${CLOUD_CONFIG_PASSWORD} ADD user-infrastructure/build/libs/*.jar app.jar ENTRYPOINT ["java", "-jar", "/app.jar"] \ No newline at end of file diff --git a/buildSrc/src/main/kotlin/Dependencies.kt b/buildSrc/src/main/kotlin/Dependencies.kt index 6484027..f4267ce 100644 --- a/buildSrc/src/main/kotlin/Dependencies.kt +++ b/buildSrc/src/main/kotlin/Dependencies.kt @@ -55,4 +55,7 @@ object Dependencies { // redis const val REACTIVE_REDIS = "org.springframework.boot:spring-boot-starter-data-redis-reactive" + + // cloud config + const val CLOUD_CONFIG = "org.springframework.cloud:spring-cloud-config-client" } diff --git a/user-infrastructure/build.gradle.kts b/user-infrastructure/build.gradle.kts index d115456..70b9f5a 100644 --- a/user-infrastructure/build.gradle.kts +++ b/user-infrastructure/build.gradle.kts @@ -34,6 +34,7 @@ dependencies { kapt(Dependencies.MAPSTRUCT_APT) kapt(Dependencies.CONFIGURATION_PROCESSOR) implementation(Dependencies.REACTIVE_REDIS) + implementation(Dependencies.CLOUD_CONFIG) implementation(project(":user-domain")) } diff --git a/user-infrastructure/src/main/resources/application.yml b/user-infrastructure/src/main/resources/application.yml index b9e1351..8e98237 100644 --- a/user-infrastructure/src/main/resources/application.yml +++ b/user-infrastructure/src/main/resources/application.yml @@ -1,29 +1,18 @@ spring: - redis: - host: ${REDIS_HOST} - port: ${REDIS_PORT} - password: ${REDIS_PASSWORD} main: web-application-type: reactive - datasource: - dbms: ${DBMS} - host: ${DB_HOST} - port: ${DB_PORT} - database: ${DB_NAME} - password: ${DB_PASSWORD} - username: ${DB_USERNAME} - show-sql: ${SHOW_SQL} - format-sql: false - highlight-sql: false - ddl-auto: ${DDL_AUTO_MODE} - pool-size: ${DB_POOL} jackson: property-naming-strategy: SNAKE_CASE date-format: yyyy-MM-dd'T'HH:mm:ss time-zone: Asia/Seoul application: - name: user-service-v1 - + name: v1-user-service + config: + import: optional:configserver:https://api.xquare.app/cloud-config/ + cloud: + config: + username: ${CLOUD_CONFIG_USERNAME} + password: ${CLOUD_CONFIG_PASSWORD} server: shutdown: graceful @@ -35,26 +24,3 @@ management: endpoint: health: show-details: when_authorized - -service: - authority: - host: ${AUTHORITY_SERVICE_HOST} - application: - host: ${APPLICATION_SERVICE_HOST} - -jwt: - secret-key: ${JWT_SECRET_KEY} - refresh-token-properties: - expiration-as-hour: ${JWT_REFRESH_TOKEN_EXP_AS_HOUR} - access-token-properties: - expiration-as-hour: ${JWT_ACCESS_TOKEN_EXP_AS_HOUR} ---- - -spring: - config: - activate: - on-profile: local - datasource: - show-sql: true - format-sql: true - highlight-sql: true