diff --git a/.github/workflows/prod-server.yml b/.github/workflows/prod-server.yml index d4062802..4a06c1cc 100644 --- a/.github/workflows/prod-server.yml +++ b/.github/workflows/prod-server.yml @@ -82,6 +82,7 @@ jobs: -p $NEW_PORT:8080 \ --name $NEW_CONTAINER \ --network common \ + -e SPRING_PROFILES_ACTIVE=prod \ -e SPRING_DATASOURCE_URL="${{secrets.PROD_DB_URL}}" \ -e SPRING_DATASOURCE_USERNAME="${{secrets.PROD_DB_USERNAME}}" \ -e SPRING_DATASOURCE_PASSWORD="${{secrets.PROD_DB_PASSWORD}}" \ diff --git a/.github/workflows/test-server-cd.yml b/.github/workflows/test-server-cd.yml index 4162dd05..5908734f 100644 --- a/.github/workflows/test-server-cd.yml +++ b/.github/workflows/test-server-cd.yml @@ -59,6 +59,7 @@ jobs: -p $NEW_PORT:8080 \ --name $NEW_CONTAINER \ --network common \ + -e SPRING_PROFILES_ACTIVE=server \ -e SPRING_DATASOURCE_URL="${{secrets.TEST_DB_URL}}" \ -e SPRING_DATASOURCE_USERNAME="${{secrets.TEST_DB_USERNAME}}" \ -e SPRING_DATASOURCE_PASSWORD="${{secrets.TEST_DB_PASSWORD}}" \ diff --git a/.github/workflows/test-server-ci.yml b/.github/workflows/test-server-ci.yml index 14655ca7..28fcd620 100644 --- a/.github/workflows/test-server-ci.yml +++ b/.github/workflows/test-server-ci.yml @@ -68,7 +68,7 @@ jobs: - name: Generate application-secrets.yml run: | mkdir -p src/main/resources - echo "${{ secrets.APPLICATION_SECRET_YML }}" > src/main/resources/application-secrets.yml + echo "${{ secrets.APPLICATION_SECRET_YML_V2 }}" > src/main/resources/application-secrets.yml echo "OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}" >> src/main/resources/application-secrets.yml echo "spring.cloud.aws.region.static: ${{ secrets.AWS_REGION }}" >> src/main/resources/application-secrets.yml diff --git a/src/main/java/org/tuna/zoopzoop/backend/domain/auth/handler/OAuth2SuccessHandler.java b/src/main/java/org/tuna/zoopzoop/backend/domain/auth/handler/OAuth2SuccessHandler.java index 2e076056..2c926f0b 100644 --- a/src/main/java/org/tuna/zoopzoop/backend/domain/auth/handler/OAuth2SuccessHandler.java +++ b/src/main/java/org/tuna/zoopzoop/backend/domain/auth/handler/OAuth2SuccessHandler.java @@ -41,8 +41,7 @@ public class OAuth2SuccessHandler extends SimpleUrlAuthenticationSuccessHandler @Value("${front.redirect_domain}") private String redirect_domain; - @Value("${spring.profiles.active:dev}") - private String activeProfile; + private final String SITE_DOMAIN = "zoopzoop.kro.kr"; @Override public void onAuthenticationSuccess(HttpServletRequest request, HttpServletResponse response, @@ -112,7 +111,7 @@ public void onAuthenticationSuccess(HttpServletRequest request, HttpServletRespo .maxAge(jwtProperties.getAccessTokenValidity() / 1000) // .domain() // 프론트엔드 & 백엔드 상위 도메인 // .secure(true) // https 필수 설정. - .domain(redirect_domain) + .domain(SITE_DOMAIN) .secure(true) .sameSite("None") .build(); @@ -121,7 +120,7 @@ public void onAuthenticationSuccess(HttpServletRequest request, HttpServletRespo .httpOnly(true) .path("/") .maxAge(jwtProperties.getRefreshTokenValidity() / 1000) // RefreshToken 유효기간과 동일하게 - .domain(redirect_domain) + .domain(SITE_DOMAIN) .secure(true) .sameSite("None") .build(); diff --git a/src/main/resources/application-dev.yml b/src/main/resources/application-dev.yml index 28f49010..c100f54a 100644 --- a/src/main/resources/application-dev.yml +++ b/src/main/resources/application-dev.yml @@ -15,20 +15,27 @@ spring: host: localhost port: 6379 timeout: 6000 - cache: #Spring Cache를 사용하기 위한 Redis - type: redis - redis: - time-to-live: 300000 - cache-null-values: false + + security: + oauth2: + client: + registration: + kakao: + redirect-uri: http://localhost:8080/login/oauth2/code/kakao + google: + redirect-uri: http://localhost:8080/login/oauth2/code/google app: seed: enabled: true +front: + redirect_domain: http://localhost:3000 + sentry: - dsn: https://60f1acad189d2994353d59b7895076ee@o4510100579155968.ingest.us.sentry.io/4510100584923136 - # Add data like request headers and IP for users, - # see https://docs.sentry.io/platforms/java/guides/spring-boot/data-management/data-collected/ for more info send-default-pii: true environment: local - traces-sample-rate: 0.0 \ No newline at end of file + traces-sample-rate: 0.0 + +liveblocks: + secret-key: test_dummy_liveblocks_secret_key diff --git a/src/main/resources/application-prod.yml b/src/main/resources/application-prod.yml new file mode 100644 index 00000000..ae4eb008 --- /dev/null +++ b/src/main/resources/application-prod.yml @@ -0,0 +1,32 @@ +spring: + datasource: + url: ${SPRING_DATASOURCE_URL} + username: ${SPRING_DATASOURCE_USERNAME} + password: ${SPRING_DATASOURCE_PASSWORD} + + data: #RedisTemplate 등을 사용하기 위한 직접 연결용 + redis: + host: 10.0.1.153 + port: 6379 + timeout: 6000 + password: ${redis-password-prod} + + security: + oauth2: + client: + registration: + kakao: + redirect-uri: https://api.prod.zoopzoop.kro.kr/login/oauth2/code/kakao + google: + redirect-uri: https://api.prod.zoopzoop.kro.kr/login/oauth2/code/google + +front: + redirect_domain: https://www.zoopzoop.kro.kr/ + +sentry: + send-default-pii: true + environment: prod-server + traces-sample-rate: 0.2 + +liveblocks: + secret-key: ${liveblocks-secret-key} \ No newline at end of file diff --git a/src/main/resources/application-secrets.yml.template b/src/main/resources/application-secrets.yml.template index 8f7e5116..8959e412 100644 --- a/src/main/resources/application-secrets.yml.template +++ b/src/main/resources/application-secrets.yml.template @@ -52,4 +52,5 @@ jwt: OPENAI_API_KEY: {OPENAI_API_KEY} liveblocks: - secret-key: {LIVEBLOCKS_SECRET_KEY} \ No newline at end of file + secret-key: {LIVEBLOCKS_SECRET_KEY} + diff --git a/src/main/resources/application-server.yml b/src/main/resources/application-server.yml index 30b1df91..42468e71 100644 --- a/src/main/resources/application-server.yml +++ b/src/main/resources/application-server.yml @@ -4,35 +4,31 @@ spring: username: ${SPRING_DATASOURCE_USERNAME} password: ${SPRING_DATASOURCE_PASSWORD} - jpa: - hibernate: - ddl-auto: update - data: #RedisTemplate 등을 사용하기 위한 직접 연결용 redis: host: 10.0.1.246 port: 6379 timeout: 6000 - password: zoopzoopRedisTest! - cache: #Spring Cache를 사용하기 위한 Redis - type: redis - redis: - time-to-live: 300000 - cache-null-values: false + password: ${redis-password-test} + + security: + oauth2: + client: + registration: + kakao: + redirect-uri: https://api.test.zoopzoop.kro.kr/login/oauth2/code/kakao + google: + redirect-uri: https://api.test.zoopzoop.kro.kr/login/oauth2/code/google -management: - endpoints: - web: - exposure: - include: health,info - endpoint: - health: - show-details: always +front: + redirect_domain: http://localhost:3000 sentry: - dsn: https://60f1acad189d2994353d59b7895076ee@o4510100579155968.ingest.us.sentry.io/4510100584923136 - # Add data like request headers and IP for users, - # see https://docs.sentry.io/platforms/java/guides/spring-boot/data-management/data-collected/ for more info send-default-pii: true - environment: prod + environment: prod-server traces-sample-rate: 0.2 + +liveblocks: + secret-key: ${liveblocks-secret-key} + + diff --git a/src/main/resources/application-test.yml b/src/main/resources/application-test.yml index c43018a5..0549b6ef 100644 --- a/src/main/resources/application-test.yml +++ b/src/main/resources/application-test.yml @@ -17,9 +17,32 @@ spring: init: mode: never + data: #RedisTemplate 등을 사용하기 위한 직접 연결용 + redis: + host: localhost + port: 6379 + timeout: 6000 + + security: + oauth2: + client: + registration: + kakao: + redirect-uri: http://localhost:8080/login/oauth2/code/kakao + google: + redirect-uri: http://localhost:8080/login/oauth2/code/google + +front: + redirect_domain: http://localhost:3000 + app: seed: enabled: false +sentry: + send-default-pii: true + environment: local + traces-sample-rate: 0.0 + liveblocks: - secret-key: test_dummy_liveblocks_secret_key \ No newline at end of file + secret-key: test_dummy_liveblocks_secret_key diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index b730aec3..51d6ea3b 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -1,33 +1,41 @@ spring: application: name: back + profiles: active: dev + output: ansi: enabled: always + datasource: hikari: auto-commit: false - jackson: + + jackson: #Jackson 설정 serialization: fail-on-empty-beans: false - jpa: + + jpa: #Hibernate JPA 설정. show-sql: true hibernate: - ddl-auto: create-drop + ddl-auto: update properties: hibernate: format_sql: true highlight_sql: true use_sql_comments: true - config: + + config: #application-secrets의 값을 바로 받아올 수 있게. import: optional:classpath:application-secrets.yml - servlet: + + servlet: # multipart: max-file-size: 10MB max-request-size: 10MB - ai: + + ai: #Spring AI 설정 openai: base-url: https://api.groq.com/openai # 내부 서버를 groq으로 api-key: ${OPENAI_API_KEY} @@ -35,7 +43,8 @@ spring: options: model: meta-llama/llama-4-scout-17b-16e-instruct temperature: 0 - rabbitmq: + + rabbitmq: #RabbitMQ 설정 host: ${SPRING_RABBITMQ_HOST:localhost} port: 5672 username: ${SPRING_RABBITMQ_USERNAME:guest} @@ -46,19 +55,54 @@ spring: enabled: true initial-interval: 2000 max-attempts: 3 - data: #RedisTemplate 등을 사용하기 위한 직접 연결용 - redis: - host: localhost - port: 6379 - timeout: 6000 + cache: #Spring Cache를 사용하기 위한 Redis type: redis redis: time-to-live: 300000 cache-null-values: false - key-prefix: -springdoc: + security: #OAuth2 범용 설정 + oauth2: + client: + registration: + kakao: + client-id: ${kakao.client-id} + scope: + - profile_nickname + - profile_image + authorization-grant-type: authorization_code + google: + client-id: ${google.client-id} + client-secret: ${google.client-secret} + scope: + - profile + authorization-grant-type: authorization_code + provider: + kakao: + authorization-uri: https://kauth.kakao.com/oauth/authorize + token-uri: https://kauth.kakao.com/oauth/token + user-info-uri: https://kapi.kakao.com/v2/user/me + user-name-attribute: id + google: + authorization-uri: https://accounts.google.com/o/oauth2/v2/auth + token-uri: https://oauth2.googleapis.com/token + user-info-uri: https://www.googleapis.com/oauth2/v3/userinfo + user-name-attribute: sub + + cloud: #S3 설정 + aws: + credentials: + access-key: ${aws.access-key} + secret-key: ${aws.secret-key} + region: + static: ap-northeast-2 + s3: + bucket: ${aws.bucket} + stack: + auto: false + +springdoc: #Spring doc 설정. default-produces-media-type: application/json;charset=UTF-8 logging: level: @@ -68,9 +112,18 @@ logging: com.back: DEBUG org.springframework.retry: DEBUG -server: - port: 8080 - app: seed: - enabled: true \ No newline at end of file + enabled: true + +management: + endpoints: + web: + exposure: + include: health,info + endpoint: + health: + show-details: always + +sentry: #Sentry 모니터렁 기본 설정. + dsn: ${sentry-dsn} \ No newline at end of file