Skip to content

Commit

Permalink
feat: spring-cloud-config 적용 (#82)
Browse files Browse the repository at this point in the history
  • Loading branch information
jhhong0509 authored Sep 4, 2022
1 parent 156fed0 commit 045f869
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 98 deletions.
21 changes: 2 additions & 19 deletions .github/workflows/prod-build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
42 changes: 4 additions & 38 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
3 changes: 3 additions & 0 deletions buildSrc/src/main/kotlin/Dependencies.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
1 change: 1 addition & 0 deletions user-infrastructure/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
}
Expand Down
48 changes: 7 additions & 41 deletions user-infrastructure/src/main/resources/application.yml
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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

0 comments on commit 045f869

Please sign in to comment.