From 30abb98150c7f2edf0cc72e36c6d7753cba48d6e Mon Sep 17 00:00:00 2001 From: KimSongMok Date: Wed, 23 Oct 2024 20:23:15 +0900 Subject: [PATCH 01/13] feat: cd pipeline MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit cd pipeline 구축 --- .github/workflows/cd.yml | 49 +++++++++++++++ Dockerfile | 11 +++- docker-compose.yml | 78 ++++++++++++------------ src/main/resources/application-local.yml | 11 ++++ src/main/resources/application-prod.yml | 11 ++++ src/main/resources/application.yml | 31 +++------- 6 files changed, 128 insertions(+), 63 deletions(-) create mode 100644 .github/workflows/cd.yml create mode 100644 src/main/resources/application-local.yml create mode 100644 src/main/resources/application-prod.yml diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml new file mode 100644 index 00000000..b1748881 --- /dev/null +++ b/.github/workflows/cd.yml @@ -0,0 +1,49 @@ +name: CD Pipeline + +on: + push: + branches: + - develop # develop 브랜치에 merge될 때 트리거 + - 'weekly/**' + +jobs: + deploy: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Set up Java 21 + uses: actions/setup-java@v3 + with: + distribution: 'temurin' + java-version: '21' + + - name: Build with Gradle # Spring Boot를 사용하는 경우 + run: ./gradlew build + + - name: Set up Docker + uses: docker/setup-buildx-action@v2 + + - name: Log in to Docker Hub + run: echo "${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}" | docker login -u "${{ secrets.DOCKER_HUB_USERNAME }}" --password-stdin + + - name: Set Image Tag + id: image_tag + run: echo "IMAGE_TAG=$(date +'%Y%m%d%H%M%S')" >> $GITHUB_ENV + + - name: Build and Push Docker image + run: docker buildx build --push --platform linux/amd64 -t kimsongmok/splanet:${{ env.IMAGE_TAG }} . + + - name: Deploy to EC2 + uses: appleboy/ssh-action@v0.1.6 + with: + host: ${{ secrets.EC2_HOST }} + username: ubuntu + key: ${{ secrets.EC2_SSH_KEY }} + script: | + sudo docker pull kimsongmok/splanet:${{ env.IMAGE_TAG }} # 새 이미지 풀링 + sudo docker stop splanet || true # 기존 컨테이너 중지 + sudo docker rm splanet || true # 기존 컨테이너 제거 + sudo docker run -d --name splanet -p 80:8080 kimsongmok/splanet:${{ env.IMAGE_TAG }} # 새 컨테이너 실행 \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index b7fe629f..84d6f0b2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -6,10 +6,17 @@ COPY build.gradle . COPY settings.gradle . COPY src src RUN chmod +x ./gradlew -RUN ./gradlew bootJar +# Gradle 빌드에서 프로필을 지정하여 실행 +RUN ./gradlew bootJar -Dspring.profiles.active=${SPRING_PROFILES_ACTIVE} + +# 런타임 단계 FROM eclipse-temurin:21 COPY --from=builder build/libs/*.jar app.jar +# 런타임에서도 동일하게 환경 변수 사용 +ENV SPRING_PROFILES_ACTIVE=prod + + ENTRYPOINT ["java", "-jar", "/app.jar"] -VOLUME /tmp +VOLUME /tmp \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index 769880e8..c940c54b 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,50 +1,50 @@ version: '3' services: - mysql: - container_name: mysql - image: mysql:8.0 - restart: always - environment: - MYSQL_USER: ${MYSQL_USER} - MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD} - MYSQL_PASSWORD: ${MYSQL_PASSWORD} - MYSQL_DATABASE: ${MYSQL_DATABASE} - volumes: - - ./splanet-db/mysql:/var/lib/mysql - ports: - - 3306:3306 - networks: - - splanet - - redis: - container_name: redis - image: redis - ports: - - 6379:6379 - networks: - - splanet - - -# 개발할때는 주석처리하여 로컬로 개발합니다. -# springboot: -# container_name: springboot_splanet -# build: -# context: . -# dockerfile: Dockerfile +# mysql: +# container_name: mysql +# image: mysql:8.0 # restart: always -# depends_on: -# - mysql -# ports: -# - 8080:8080 # environment: -# SPRING_DATASOURCE_URL: ${SPRING_DATASOURCE_URL} -# SPRING_DATASOURCE_USERNAME: ${SPRING_DATASOURCE_USERNAME} -# SPRING_DATASOURCE_PASSWORD: ${SPRING_DATASOURCE_PASSWORD} -# SPRING_PROFILES_ACTIVE: ${SPRING_PROFILES_ACTIVE} +# MYSQL_USER: ${MYSQL_USER} +# MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD} +# MYSQL_PASSWORD: ${MYSQL_PASSWORD} +# MYSQL_DATABASE: ${MYSQL_DATABASE} +# volumes: +# - ./splanet-db/mysql:/var/lib/mysql +# ports: +# - 3306:3306 +# networks: +# - splanet +# +# redis: +# container_name: redis +# image: redis +# ports: +# - 6379:6379 # networks: # - splanet + +# 개발할때는 주석처리하여 로컬로 개발합니다. + springboot: + container_name: springboot_splanet + build: + context: . + dockerfile: Dockerfile + restart: always + depends_on: + - mysql + ports: + - 8080:8080 + environment: + SPRING_DATASOURCE_URL: ${SPRING_DATASOURCE_URL} + SPRING_DATASOURCE_USERNAME: ${SPRING_DATASOURCE_USERNAME} + SPRING_DATASOURCE_PASSWORD: ${SPRING_DATASOURCE_PASSWORD} + SPRING_PROFILES_ACTIVE: ${SPRING_PROFILES_ACTIVE} + networks: + - splanet + networks: splanet: driver: bridge diff --git a/src/main/resources/application-local.yml b/src/main/resources/application-local.yml new file mode 100644 index 00000000..44eb850a --- /dev/null +++ b/src/main/resources/application-local.yml @@ -0,0 +1,11 @@ +spring: + datasource: + url: jdbc:mysql://localhost:3306/${MYSQL_DATABASE} + username: ${MYSQL_USER} + password: ${MYSQL_PASSWORD} + driver-class-name: com.mysql.cj.jdbc.Driver + security: + oauth2: + redirect-url: http://localhost:8080/login/oauth2/code/kakao + config: + import: env.properties \ No newline at end of file diff --git a/src/main/resources/application-prod.yml b/src/main/resources/application-prod.yml new file mode 100644 index 00000000..c1faa893 --- /dev/null +++ b/src/main/resources/application-prod.yml @@ -0,0 +1,11 @@ +spring: + datasource: + url: jdbc:mysql://${MYSQL_PROD_URL}:3306 + username: ${MYSQL_PROD_USER} + password: ${MYSQL_PROD_PASSWORD} + driver-class-name: com.mysql.cj.jdbc.Driver + security: + oauth2: + redirect-url: https://splanet.co.kr/login/oauth2/code/kakao + config: + import: env.properties \ No newline at end of file diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index feb38a7c..d7af2286 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -1,9 +1,4 @@ spring: - datasource: - url: jdbc:mysql://localhost:3306/${MYSQL_DATABASE} - username: ${MYSQL_USER} - password: ${MYSQL_PASSWORD} - driver-class-name: com.mysql.cj.jdbc.Driver jpa: hibernate: ddl-auto: update @@ -14,30 +9,23 @@ spring: format_sql: true data: redis: - host: localhost # 로컬에서 실행하기 때문 + host: localhost port: 6379 - config: - import: env.properties security: oauth2: - redirect-url: ${REDIRECT_URL} client: - 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 - registration: kakao: client-id: ${CLIENT_ID} client-secret: ${CLIENT_SECRET} - redirect-uri: http://localhost:8080/login/oauth2/code/kakao - client-authentication-method: client_secret_post + scope: profile + redirect-uri: ${REDIRECT_URL} authorization-grant-type: authorization_code - scope: profile_nickname, profile_image, account_email - client-name: Kakao + 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 logging: level: @@ -45,5 +33,4 @@ logging: springdoc: swagger-ui: - path: /swagger - + path: /swagger \ No newline at end of file From c771771a6fbfa75f70d06853475588a956bbc53f Mon Sep 17 00:00:00 2001 From: KimSongMok Date: Wed, 23 Oct 2024 20:47:18 +0900 Subject: [PATCH 02/13] =?UTF-8?q?refactor:=20jwt=ED=86=A0=ED=81=B0=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 받아오는 방식 수정 --- .../splanet/core/properties/JwtProperties.java | 14 ++++++++++++++ .../com/splanet/splanet/jwt/JwtTokenProvider.java | 10 ++++++---- src/main/resources/application.yml | 2 ++ 3 files changed, 22 insertions(+), 4 deletions(-) create mode 100644 src/main/java/com/splanet/splanet/core/properties/JwtProperties.java diff --git a/src/main/java/com/splanet/splanet/core/properties/JwtProperties.java b/src/main/java/com/splanet/splanet/core/properties/JwtProperties.java new file mode 100644 index 00000000..fb540351 --- /dev/null +++ b/src/main/java/com/splanet/splanet/core/properties/JwtProperties.java @@ -0,0 +1,14 @@ +package com.splanet.splanet.core.properties; + +import lombok.Getter; +import lombok.Setter; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.context.annotation.Configuration; + +@Getter +@Setter +@Configuration +@ConfigurationProperties(prefix = "spring.security.jwt") +public class JwtProperties { + private String secret; +} diff --git a/src/main/java/com/splanet/splanet/jwt/JwtTokenProvider.java b/src/main/java/com/splanet/splanet/jwt/JwtTokenProvider.java index 22c74a87..afa88a23 100644 --- a/src/main/java/com/splanet/splanet/jwt/JwtTokenProvider.java +++ b/src/main/java/com/splanet/splanet/jwt/JwtTokenProvider.java @@ -2,6 +2,7 @@ import com.splanet.splanet.core.exception.BusinessException; import com.splanet.splanet.core.exception.ErrorCode; +import com.splanet.splanet.core.properties.JwtProperties; import io.jsonwebtoken.*; import jakarta.annotation.PostConstruct; import jakarta.servlet.http.HttpServletRequest; @@ -18,16 +19,17 @@ public class JwtTokenProvider { private Key secretKey; - @Value("${JWT_SECRET}") - private String secret; - private static final long TOKEN_VALIDITY_IN_MILLISECONDS = 3600000; // 1시간 private static final long REFRESH_TOKEN_VALIDITY_IN_MILLISECONDS = 604800000; // 7일 + private final JwtProperties jwtProperties; + public JwtTokenProvider(JwtProperties jwtProperties) { + this.jwtProperties = jwtProperties; + } @PostConstruct protected void init() { - this.secretKey = new SecretKeySpec(secret.getBytes(StandardCharsets.UTF_8), SignatureAlgorithm.HS256.getJcaName()); + this.secretKey = new SecretKeySpec(jwtProperties.getSecret().getBytes(StandardCharsets.UTF_8), SignatureAlgorithm.HS256.getJcaName()); } public String createAccessToken(Long userId) { diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index d7af2286..358e139d 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -12,6 +12,8 @@ spring: host: localhost port: 6379 security: + jwt: + secret: ${JWT_SECRET} oauth2: client: registration: From 655828b33fbb6578eee22ad92191300cbdda67e8 Mon Sep 17 00:00:00 2001 From: KimSongMok Date: Wed, 23 Oct 2024 20:56:34 +0900 Subject: [PATCH 03/13] =?UTF-8?q?refactor:=20datasource=20=EB=AC=B8?= =?UTF-8?q?=EC=A0=9C=20=ED=95=B4=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/ci.yml | 3 +++ src/main/resources/application-prod.yml | 2 +- src/test/resources/application.yml | 0 3 files changed, 4 insertions(+), 1 deletion(-) create mode 100644 src/test/resources/application.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f4dd0668..88e5c6b5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -89,10 +89,13 @@ jobs: - name: Build with Gradle run: ./gradlew build + env: + SPRING_PROFILES_ACTIVE: local - name: Run Tests run: ./gradlew test env: + SPRING_PROFILES_ACTIVE: local MYSQL_DATABASE: ${{ secrets.MYSQL_DATABASE }} MYSQL_USER: ${{ secrets.MYSQL_USER }} MYSQL_PASSWORD: ${{ secrets.MYSQL_PASSWORD }} diff --git a/src/main/resources/application-prod.yml b/src/main/resources/application-prod.yml index c1faa893..1e7f4b28 100644 --- a/src/main/resources/application-prod.yml +++ b/src/main/resources/application-prod.yml @@ -1,6 +1,6 @@ spring: datasource: - url: jdbc:mysql://${MYSQL_PROD_URL}:3306 + url: jdbc:mysql://${MYSQL_PROD_URL}:3306/${MYSQL_DATABASE} username: ${MYSQL_PROD_USER} password: ${MYSQL_PROD_PASSWORD} driver-class-name: com.mysql.cj.jdbc.Driver diff --git a/src/test/resources/application.yml b/src/test/resources/application.yml new file mode 100644 index 00000000..e69de29b From 7ef0397a81c9e8f3a3d0dad1ee5cfe8999107630 Mon Sep 17 00:00:00 2001 From: KimSongMok Date: Wed, 23 Oct 2024 21:43:26 +0900 Subject: [PATCH 04/13] =?UTF-8?q?refactor:=20test=EC=96=B4=EB=85=B8?= =?UTF-8?q?=ED=85=8C=EC=9D=B4=EC=85=98=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/ci.yml | 3 +++ src/test/java/com/splanet/splanet/SplanetApplicationTests.java | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 88e5c6b5..26d7e5be 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -91,6 +91,9 @@ jobs: run: ./gradlew build env: SPRING_PROFILES_ACTIVE: local + MYSQL_DATABASE: ${{ secrets.MYSQL_DATABASE }} + MYSQL_USER: ${{ secrets.MYSQL_USER }} + MYSQL_PASSWORD: ${{ secrets.MYSQL_PASSWORD }} - name: Run Tests run: ./gradlew test diff --git a/src/test/java/com/splanet/splanet/SplanetApplicationTests.java b/src/test/java/com/splanet/splanet/SplanetApplicationTests.java index 6b6fb866..b40e2597 100644 --- a/src/test/java/com/splanet/splanet/SplanetApplicationTests.java +++ b/src/test/java/com/splanet/splanet/SplanetApplicationTests.java @@ -3,7 +3,7 @@ import org.junit.jupiter.api.Test; import org.springframework.boot.test.context.SpringBootTest; -@SpringBootTest +// @SpringBootTest class SplanetApplicationTests { @Test From 7117e9a973af7c5633651725983333f1ebfa7ccb Mon Sep 17 00:00:00 2001 From: KimSongMok Date: Wed, 23 Oct 2024 21:51:28 +0900 Subject: [PATCH 05/13] =?UTF-8?q?refarctor:=20cd=20pipeline=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/cd.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index b1748881..0652c1d6 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -5,6 +5,10 @@ on: branches: - develop # develop 브랜치에 merge될 때 트리거 - 'weekly/**' + pull_request: + branches: + - develop + - 'weekly/**' jobs: deploy: From 4975a8305b358dd7e009eeffee52243d54dbb443 Mon Sep 17 00:00:00 2001 From: KimSongMok Date: Wed, 23 Oct 2024 22:18:31 +0900 Subject: [PATCH 06/13] =?UTF-8?q?refactor:=20prod.yml=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/resources/application-prod.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/application-prod.yml b/src/main/resources/application-prod.yml index 1e7f4b28..0f99cac2 100644 --- a/src/main/resources/application-prod.yml +++ b/src/main/resources/application-prod.yml @@ -8,4 +8,4 @@ spring: oauth2: redirect-url: https://splanet.co.kr/login/oauth2/code/kakao config: - import: env.properties \ No newline at end of file + import: optional:env.properties \ No newline at end of file From dd1753095c54206d0c239e2c6cd7b3aac993e618 Mon Sep 17 00:00:00 2001 From: KimSongMok Date: Wed, 23 Oct 2024 22:31:31 +0900 Subject: [PATCH 07/13] =?UTF-8?q?refactor:=20cd=20yml=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/cd.yml | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index 0652c1d6..37b1cdf7 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -47,7 +47,17 @@ jobs: username: ubuntu key: ${{ secrets.EC2_SSH_KEY }} script: | - sudo docker pull kimsongmok/splanet:${{ env.IMAGE_TAG }} # 새 이미지 풀링 - sudo docker stop splanet || true # 기존 컨테이너 중지 - sudo docker rm splanet || true # 기존 컨테이너 제거 - sudo docker run -d --name splanet -p 80:8080 kimsongmok/splanet:${{ env.IMAGE_TAG }} # 새 컨테이너 실행 \ No newline at end of file + sudo docker pull kimsongmok/splanet:${{ env.IMAGE_TAG }} + sudo docker stop splanet || true + sudo docker rm splanet || true + sudo docker run -d --name splanet \ + -e MYSQL_PROD_URL=${{ secrets.MYSQL_PROD_URL }} \ + -e MYSQL_PROD_USER=${{ secrets.MYSQL_PROD_USER }} \ + -e MYSQL_PROD_PASSWORD=${{ secrets.MYSQL_PROD_PASSWORD }} \ + -e MYSQL_DATABASE=${{ secrets.MYSQL_DATABASE }} \ + -e CLIENT_ID=${{ secrets.CLIENT_ID }} \ + -e CLIENT_SECRET=${{ secrets.CLIENT_SECRET }} \ + -e JWT_SECRET=${{ secrets.JWT_SECRET }} \ + -e REDIRECT_URL=${{ secrets.REDIRECT_URL }} \ + -p 80:8080 --restart unless-stopped kimsongmok/splanet:${{ env.IMAGE_TAG }}\ + -v ./src/main/resources/env.properties \ No newline at end of file From 1da042945090d84a6a1c3ecc2f03f063e301da93 Mon Sep 17 00:00:00 2001 From: KimSongMok Date: Thu, 24 Oct 2024 01:51:19 +0900 Subject: [PATCH 08/13] =?UTF-8?q?refactor:=20application.yml=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build.gradle | 1 + src/main/resources/application.yml | 11 ++++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index d9924785..505230dd 100644 --- a/build.gradle +++ b/build.gradle @@ -32,6 +32,7 @@ dependencies { implementation 'org.springframework.boot:spring-boot-starter-thymeleaf' implementation 'org.springframework.boot:spring-boot-starter-web' implementation 'javax.xml.bind:jaxb-api:2.3.1' + implementation 'org.springframework.boot:spring-boot-starter-actuator' // implementation 'org.thymeleaf.extras:thymeleaf-extras-springsecurity6' implementation 'org.springdoc:springdoc-openapi-starter-webmvc-ui:2.0.2' implementation 'io.jsonwebtoken:jjwt:0.9.1' diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 358e139d..30a73b78 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -35,4 +35,13 @@ logging: springdoc: swagger-ui: - path: /swagger \ No newline at end of file + path: /swagger +management: + endpoints: + health: + show-details: always + web: + exposure: + include: health + security: + enabled: false \ No newline at end of file From b756811ff51a7d8b2b351c57f1e19cd0a0be1297 Mon Sep 17 00:00:00 2001 From: kanguk Date: Thu, 24 Oct 2024 02:29:40 +0900 Subject: [PATCH 09/13] =?UTF-8?q?refactor:=20redis=20=EC=84=A4=EC=A0=95=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/cd.yml | 1 + src/main/resources/application-local.yml | 4 ++++ src/main/resources/application-prod.yml | 4 ++++ src/main/resources/application.yml | 5 +---- 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index 37b1cdf7..2d024340 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -51,6 +51,7 @@ jobs: sudo docker stop splanet || true sudo docker rm splanet || true sudo docker run -d --name splanet \ + --network splanet \ -e MYSQL_PROD_URL=${{ secrets.MYSQL_PROD_URL }} \ -e MYSQL_PROD_USER=${{ secrets.MYSQL_PROD_USER }} \ -e MYSQL_PROD_PASSWORD=${{ secrets.MYSQL_PROD_PASSWORD }} \ diff --git a/src/main/resources/application-local.yml b/src/main/resources/application-local.yml index 44eb850a..df8a51a6 100644 --- a/src/main/resources/application-local.yml +++ b/src/main/resources/application-local.yml @@ -1,4 +1,8 @@ spring: + data: + redis: + host: localhost + port: 6379 datasource: url: jdbc:mysql://localhost:3306/${MYSQL_DATABASE} username: ${MYSQL_USER} diff --git a/src/main/resources/application-prod.yml b/src/main/resources/application-prod.yml index 0f99cac2..2d08afe7 100644 --- a/src/main/resources/application-prod.yml +++ b/src/main/resources/application-prod.yml @@ -1,4 +1,8 @@ spring: + data: + redis: + host: redis + port: 6379 datasource: url: jdbc:mysql://${MYSQL_PROD_URL}:3306/${MYSQL_DATABASE} username: ${MYSQL_PROD_USER} diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 30a73b78..41c7757d 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -7,10 +7,7 @@ spring: hibernate: dialect: org.hibernate.dialect.MySQLDialect format_sql: true - data: - redis: - host: localhost - port: 6379 + security: jwt: secret: ${JWT_SECRET} From f79c924b35d3ac331833c898023a4e111fcc65d2 Mon Sep 17 00:00:00 2001 From: KimSongMok Date: Thu, 24 Oct 2024 02:56:51 +0900 Subject: [PATCH 10/13] =?UTF-8?q?refactor:=20application.yml=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit show details 위치 수정 --- src/main/resources/application.yml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 30a73b78..3e04690c 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -38,10 +38,9 @@ springdoc: path: /swagger management: endpoints: - health: - show-details: always web: exposure: include: health - security: - enabled: false \ No newline at end of file + endpoint: + health: + show-details: always \ No newline at end of file From fe0fa697460d293b70641ecb6fa9560c180a140a Mon Sep 17 00:00:00 2001 From: KimSongMok Date: Thu, 24 Oct 2024 21:28:46 +0900 Subject: [PATCH 11/13] =?UTF-8?q?refator:=20cd=20healthy=20check=20api=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../core/controller/StatusCheckController.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 src/main/java/com/splanet/splanet/core/controller/StatusCheckController.java diff --git a/src/main/java/com/splanet/splanet/core/controller/StatusCheckController.java b/src/main/java/com/splanet/splanet/core/controller/StatusCheckController.java new file mode 100644 index 00000000..a4f71490 --- /dev/null +++ b/src/main/java/com/splanet/splanet/core/controller/StatusCheckController.java @@ -0,0 +1,15 @@ +package com.splanet.splanet.core.controller; + +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +public class StatusCheckController { + + @GetMapping("/actuator/health-check") + public ResponseEntity checkHealthStatus() { + return new ResponseEntity<>(HttpStatus.OK); + } +} \ No newline at end of file From 1d67ef067a76569783a88cfa5b9e8fa7619e4516 Mon Sep 17 00:00:00 2001 From: KimSongMok Date: Thu, 24 Oct 2024 21:34:30 +0900 Subject: [PATCH 12/13] =?UTF-8?q?refactor:=20cd=20healthy=20check=20api=20?= =?UTF-8?q?=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../core/controller/StatusCheckController.java | 15 --------------- 1 file changed, 15 deletions(-) delete mode 100644 src/main/java/com/splanet/splanet/core/controller/StatusCheckController.java diff --git a/src/main/java/com/splanet/splanet/core/controller/StatusCheckController.java b/src/main/java/com/splanet/splanet/core/controller/StatusCheckController.java deleted file mode 100644 index a4f71490..00000000 --- a/src/main/java/com/splanet/splanet/core/controller/StatusCheckController.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.splanet.splanet.core.controller; - -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RestController; - -@RestController -public class StatusCheckController { - - @GetMapping("/actuator/health-check") - public ResponseEntity checkHealthStatus() { - return new ResponseEntity<>(HttpStatus.OK); - } -} \ No newline at end of file From 4a53e6c2126e1d15ed6ceaafed5182438c8f2198 Mon Sep 17 00:00:00 2001 From: kanguk Date: Fri, 25 Oct 2024 00:46:09 +0900 Subject: [PATCH 13/13] =?UTF-8?q?refactor:=20=ED=94=84=EB=A1=9C=ED=8C=8C?= =?UTF-8?q?=EC=9D=BC=20=EB=8D=94=20=EC=A0=95=ED=99=95=ED=95=98=EA=B2=8C=20?= =?UTF-8?q?=EB=B6=84=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 이전에 꼬여있던 부분 수정 --- .../core/properties/JwtProperties.java | 2 +- src/main/resources/application-local.yml | 16 ++++---- src/main/resources/application-prod.yml | 16 ++++---- src/main/resources/application.yml | 38 ++++++++++--------- 4 files changed, 39 insertions(+), 33 deletions(-) diff --git a/src/main/java/com/splanet/splanet/core/properties/JwtProperties.java b/src/main/java/com/splanet/splanet/core/properties/JwtProperties.java index fb540351..3c787400 100644 --- a/src/main/java/com/splanet/splanet/core/properties/JwtProperties.java +++ b/src/main/java/com/splanet/splanet/core/properties/JwtProperties.java @@ -8,7 +8,7 @@ @Getter @Setter @Configuration -@ConfigurationProperties(prefix = "spring.security.jwt") +@ConfigurationProperties(prefix = "jwt") public class JwtProperties { private String secret; } diff --git a/src/main/resources/application-local.yml b/src/main/resources/application-local.yml index df8a51a6..8eb1e6ac 100644 --- a/src/main/resources/application-local.yml +++ b/src/main/resources/application-local.yml @@ -1,15 +1,17 @@ spring: - data: - redis: - host: localhost - port: 6379 datasource: url: jdbc:mysql://localhost:3306/${MYSQL_DATABASE} username: ${MYSQL_USER} password: ${MYSQL_PASSWORD} driver-class-name: com.mysql.cj.jdbc.Driver + data: + redis: + host: localhost + port: 6379 security: oauth2: - redirect-url: http://localhost:8080/login/oauth2/code/kakao - config: - import: env.properties \ No newline at end of file + redirect-url: http://localhost:5173/oauth2/redirect + client: + registration: + kakao: + redirect-uri: http://localhost:8080/login/oauth2/code/kakao diff --git a/src/main/resources/application-prod.yml b/src/main/resources/application-prod.yml index 2d08afe7..4ff4c8ac 100644 --- a/src/main/resources/application-prod.yml +++ b/src/main/resources/application-prod.yml @@ -1,15 +1,17 @@ spring: - data: - redis: - host: redis - port: 6379 datasource: url: jdbc:mysql://${MYSQL_PROD_URL}:3306/${MYSQL_DATABASE} username: ${MYSQL_PROD_USER} password: ${MYSQL_PROD_PASSWORD} driver-class-name: com.mysql.cj.jdbc.Driver + data: + redis: + host: redis + port: 6379 security: oauth2: - redirect-url: https://splanet.co.kr/login/oauth2/code/kakao - config: - import: optional:env.properties \ No newline at end of file + redirect-url: https://splanet.co.kr/oauth2/redirect + client: + registration: + kakao: + redirect-uri: https://splanet.co.kr/login/oauth2/code/kakao diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 0796ff27..f79fd2b8 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -7,24 +7,26 @@ spring: hibernate: dialect: org.hibernate.dialect.MySQLDialect format_sql: true - + config: + import: optional:env.properties security: - jwt: - secret: ${JWT_SECRET} oauth2: client: - registration: - kakao: - client-id: ${CLIENT_ID} - client-secret: ${CLIENT_SECRET} - scope: profile - redirect-uri: ${REDIRECT_URL} - 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 + registration: + kakao: + client-id: ${CLIENT_ID} + client-secret: ${CLIENT_SECRET} + redirect-uri: http://localhost:8080/login/oauth2/code/kakao + client-authentication-method: client_secret_post + authorization-grant-type: authorization_code + scope: profile_nickname, profile_image, account_email + client-name: Kakao logging: level: @@ -33,11 +35,11 @@ logging: springdoc: swagger-ui: path: /swagger -management: - endpoints: - web: - exposure: - include: health - endpoint: - health: - show-details: always \ No newline at end of file + +jwt: + secret: ${JWT_SECRET} + +clova: + speech: + client-secret: ${CLOVA_CLIENT_SECRET} + language: ko