From 77878e8fb6697c51f212b03def5f338026a68505 Mon Sep 17 00:00:00 2001 From: jiseon Date: Sun, 17 Nov 2024 23:17:11 +0900 Subject: [PATCH 1/5] =?UTF-8?q?ITDS-63=20feat:=20=EA=B0=9C=EB=B0=9C=20?= =?UTF-8?q?=ED=99=98=EA=B2=BD=EC=97=90=EC=84=9C=EB=A7=8C=20=EC=97=90?= =?UTF-8?q?=EB=9F=AC=20=EC=95=8C=EB=A6=BC=EC=9D=84=20=EB=B3=B4=EB=82=B4?= =?UTF-8?q?=EA=B8=B0=20=EC=9C=84=ED=95=B4=20=ED=94=84=EB=A1=9C=ED=95=84=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 --- src/main/resources/application-dev.yml | 52 ++++++++++++++++++++++++ src/main/resources/application-local.yml | 52 ++++++++++++++++++++++++ src/main/resources/application.yml | 50 +---------------------- 3 files changed, 105 insertions(+), 49 deletions(-) create mode 100644 src/main/resources/application-dev.yml create mode 100644 src/main/resources/application-local.yml diff --git a/src/main/resources/application-dev.yml b/src/main/resources/application-dev.yml new file mode 100644 index 0000000..5af8e2e --- /dev/null +++ b/src/main/resources/application-dev.yml @@ -0,0 +1,52 @@ +spring: + datasource: + url: ${DB_URL} + username: ${DB_USER} + password: ${DB_PASSWORD} + hikari: + connection-timeout: 2000 + maximum-pool-size: 10 + driver-class-name: org.mariadb.jdbc.Driver + jpa: + hibernate: + ddl-auto: validate + show-sql: true + properties: + hibernate: + format_sql: true + dialect: com.dissonance.itit.config.MariaDBFullTextDialect + defer-datasource-initialization: false + servlet: + multipart: + max-request-size: 10MB + max-file-size: 10MB + data: + redis: + port: ${REDIS_PORT} + host: ${REDIS_HOST} + +jwt: + token: + secret-key: ${JWT_SECRET} + +logging: + level: + org: + hibernate: + type: debug + stat: debug + discord: + webhook-url: ${DISCORD_WEBHOOK_URL} + config: classpath:logback.xml + +cloud: + aws: + s3: + bucket: itit-bucket + region: + static: ap-northeast-2 + stack: + auto: false + credentials: + access-key: ${AWS_ACCESS_KEY} + secret-key: ${AWS_SECRET_KEY} \ No newline at end of file diff --git a/src/main/resources/application-local.yml b/src/main/resources/application-local.yml new file mode 100644 index 0000000..97aabc9 --- /dev/null +++ b/src/main/resources/application-local.yml @@ -0,0 +1,52 @@ +spring: + datasource: + url: ${DB_URL} + username: ${DB_USER} + password: ${DB_PASSWORD} + hikari: + connection-timeout: 2000 + maximum-pool-size: 5 + driver-class-name: org.mariadb.jdbc.Driver + jpa: + hibernate: + ddl-auto: update + show-sql: true + properties: + hibernate: + format_sql: true + dialect: com.dissonance.itit.config.MariaDBFullTextDialect + defer-datasource-initialization: true + servlet: + multipart: + max-request-size: 10MB + max-file-size: 10MB + data: + redis: + port: ${REDIS_PORT} + host: ${REDIS_HOST} + +jwt: + token: + secret-key: ${JWT_SECRET} + +logging: + level: + org: + hibernate: + type: trace + stat: debug + discord: + webhook-url: ${DISCORD_WEBHOOK_URL} + config: classpath:logback.xml + +cloud: + aws: + s3: + bucket: itit-bucket + region: + static: ap-northeast-2 + stack: + auto: false + credentials: + access-key: ${AWS_ACCESS_KEY} + secret-key: ${AWS_SECRET_KEY} \ No newline at end of file diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 1c03b94..11fff70 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -6,53 +6,5 @@ server: context-path: /api/v1 spring: - datasource: - url: ${DB_URL} - username: ${DB_USER} - password: ${DB_PASSWORD} - hikari: - connection-timeout: 2000 - maximum-pool-size: ${POOL_SIZE:5} - driver-class-name: org.mariadb.jdbc.Driver - jpa: - hibernate: - ddl-auto: ${DDL_AUTO:update} - show-sql: true - properties: - hibernate: - format_sql: true - dialect: com.dissonance.itit.config.MariaDBFullTextDialect - defer-datasource-initialization: ${DEFER_INIT:true} profiles: - include: oauth - servlet: - multipart: - max-request-size: 10MB - max-file-size: 10MB - data: - redis: - port: ${REDIS_PORT} - host: ${REDIS_HOST} - -jwt: - token: - secret-key: ${JWT_SECRET} - -logging: - level: - org: - hibernate: - type: ${LOG_LEVEL:trace} - stat: debug - -cloud: - aws: - s3: - bucket: itit-bucket - region: - static: ap-northeast-2 - stack: - auto: false - credentials: - access-key: ${AWS_ACCESS_KEY} - secret-key: ${AWS_SECRET_KEY} \ No newline at end of file + include: oauth \ No newline at end of file From 162478ce8b38cbed90f50bb1f3f943c78870510f Mon Sep 17 00:00:00 2001 From: jiseon Date: Sun, 17 Nov 2024 23:17:57 +0900 Subject: [PATCH 2/5] =?UTF-8?q?ITDS-63=20feat:=20logback=EC=9D=84=20?= =?UTF-8?q?=EC=82=AC=EC=9A=A9=ED=95=9C=20discord=20=EC=95=8C=EB=A6=BC=20?= =?UTF-8?q?=EC=97=B0=EB=8F=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build.gradle | 2 + .../exception/GlobalExceptionHandler.java | 6 +-- src/main/resources/Logback.xml | 45 +++++++++++++++++++ 3 files changed, 50 insertions(+), 3 deletions(-) create mode 100644 src/main/resources/Logback.xml diff --git a/build.gradle b/build.gradle index 11ccf5e..418e6e2 100644 --- a/build.gradle +++ b/build.gradle @@ -37,6 +37,7 @@ configurations { repositories { mavenCentral() + maven { url 'https://jitpack.io' } } dependencies { @@ -64,6 +65,7 @@ dependencies { implementation 'org.springframework.cloud:spring-cloud-starter-aws:2.2.6.RELEASE' implementation 'org.springframework.boot:spring-boot-starter-data-redis' + implementation('com.github.napstr:logback-discord-appender:1.0.0') } def QDomains = [] diff --git a/src/main/java/com/dissonance/itit/common/exception/GlobalExceptionHandler.java b/src/main/java/com/dissonance/itit/common/exception/GlobalExceptionHandler.java index 8ec0d84..a08eabf 100644 --- a/src/main/java/com/dissonance/itit/common/exception/GlobalExceptionHandler.java +++ b/src/main/java/com/dissonance/itit/common/exception/GlobalExceptionHandler.java @@ -16,7 +16,7 @@ public class GlobalExceptionHandler { @ExceptionHandler(CustomException.class) protected ResponseEntity> handleCustomException(CustomException e) { int statusCode = e.getErrorCode().getHttpStatus().value(); - log.error("CustomException : {}", e.getMessage()); + log.error("CustomException: ", e); return new ResponseEntity<>(ApiResponse.error(statusCode, e.getMessage()), e.getErrorCode().getHttpStatus()); } @@ -24,7 +24,7 @@ protected ResponseEntity> handleCustomException(CustomException e @ExceptionHandler(Exception.class) public ResponseEntity> handleAllException(final Exception e) { int statusCode = HttpStatus.INTERNAL_SERVER_ERROR.value(); - log.error("handleAllException {}", e.getMessage()); + log.error("handleAllException: ", e); return new ResponseEntity<>(ApiResponse.error(statusCode, e.getMessage()), HttpStatus.INTERNAL_SERVER_ERROR); } @@ -32,7 +32,7 @@ public ResponseEntity> handleAllException(final Exception e) { @ExceptionHandler(MaxUploadSizeExceededException.class) public ResponseEntity> handleMaxSizeException(MaxUploadSizeExceededException e) { int statusCode = e.getStatusCode().value(); - log.error("MaxUploadSizeExceededException {}", e.getMessage()); + log.error("MaxUploadSizeExceededException: ", e); return new ResponseEntity<>(ApiResponse.error(statusCode, e.getMessage()), HttpStatus.PAYLOAD_TOO_LARGE); } diff --git a/src/main/resources/Logback.xml b/src/main/resources/Logback.xml new file mode 100644 index 0000000..1ff0373 --- /dev/null +++ b/src/main/resources/Logback.xml @@ -0,0 +1,45 @@ + + + + + + + + + + + + + + + ${DISCORD_WEBHOOK_URL} + + %d{HH:mm:ss} [%thread] [%-5level] %logger{36} - %msg%n```%ex{full}``` + + ๐Ÿšจ์—๋Ÿฌ ์•Œ๋ฆผ๐Ÿšจ + + https://img1.daumcdn.net/thumb/R1280x0.fjpg/?fname=http://t1.daumcdn.net/brunch/service/user/cnoC/image/vuyIRQbt6-tQGfW80jNaVS5zjTw + + false + + + + + ${CONSOLE_LOG_PATTERN} + utf8 + + + + + + + ERROR + + + + + + + + + \ No newline at end of file From fcf109c03bd3d22512e07c7a26931ba4d09a22d5 Mon Sep 17 00:00:00 2001 From: jiseon Date: Tue, 19 Nov 2024 15:49:04 +0900 Subject: [PATCH 3/5] =?UTF-8?q?ITDS-63=20refactor:=20exception=20=EC=9D=91?= =?UTF-8?q?=EB=8B=B5=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../exception/GlobalExceptionHandler.java | 21 +++++++++++-------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/dissonance/itit/common/exception/GlobalExceptionHandler.java b/src/main/java/com/dissonance/itit/common/exception/GlobalExceptionHandler.java index a08eabf..a2c29c3 100644 --- a/src/main/java/com/dissonance/itit/common/exception/GlobalExceptionHandler.java +++ b/src/main/java/com/dissonance/itit/common/exception/GlobalExceptionHandler.java @@ -16,24 +16,27 @@ public class GlobalExceptionHandler { @ExceptionHandler(CustomException.class) protected ResponseEntity> handleCustomException(CustomException e) { int statusCode = e.getErrorCode().getHttpStatus().value(); - log.error("CustomException: ", e); - return new ResponseEntity<>(ApiResponse.error(statusCode, e.getMessage()), - e.getErrorCode().getHttpStatus()); + log.error("CustomException: {}", e.getMessage(), e); + return ResponseEntity + .status(e.getErrorCode().getHttpStatus()) + .body(ApiResponse.error(statusCode, e.getMessage())); } @ExceptionHandler(Exception.class) public ResponseEntity> handleAllException(final Exception e) { int statusCode = HttpStatus.INTERNAL_SERVER_ERROR.value(); - log.error("handleAllException: ", e); - return new ResponseEntity<>(ApiResponse.error(statusCode, e.getMessage()), - HttpStatus.INTERNAL_SERVER_ERROR); + log.error("handleAllException: {}", e.getMessage(), e); + return ResponseEntity + .status(HttpStatus.INTERNAL_SERVER_ERROR) + .body(ApiResponse.error(statusCode, e.getMessage())); } @ExceptionHandler(MaxUploadSizeExceededException.class) public ResponseEntity> handleMaxSizeException(MaxUploadSizeExceededException e) { int statusCode = e.getStatusCode().value(); - log.error("MaxUploadSizeExceededException: ", e); - return new ResponseEntity<>(ApiResponse.error(statusCode, e.getMessage()), - HttpStatus.PAYLOAD_TOO_LARGE); + log.error("MaxUploadSizeExceededException: {}", e.getMessage(), e); + return ResponseEntity + .status(HttpStatus.PAYLOAD_TOO_LARGE) + .body(ApiResponse.error(statusCode, e.getMessage())); } } From 9b58fc4bdd4659b754d3412a4690d5d0a4d19b92 Mon Sep 17 00:00:00 2001 From: jiseon Date: Tue, 19 Nov 2024 15:49:48 +0900 Subject: [PATCH 4/5] =?UTF-8?q?ITDS-63=20feat:=20CI/CD=20workflow=20?= =?UTF-8?q?=EB=B0=B0=ED=8F=AC=20=EC=8B=9C=EC=9E=91=20=EC=A0=84=ED=9B=84=20?= =?UTF-8?q?discord=20=EC=95=8C=EB=A6=BC=20=EC=A0=84=EC=86=A1=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/cicd.yml | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/.github/workflows/cicd.yml b/.github/workflows/cicd.yml index 930a2e0..5629902 100644 --- a/.github/workflows/cicd.yml +++ b/.github/workflows/cicd.yml @@ -66,6 +66,12 @@ jobs: run: | aws ec2 authorize-security-group-ingress --group-id ${{ secrets.AWS_SG_ID }} --protocol tcp --port 22 --cidr ${{ steps.ip.outputs.ipv4 }}/32 + # ๋ฐฐํฌ ์‹œ์ž‘ ์•Œ๋ฆผ ์ „์†ก + - name: Start Deployment + continue-on-error: true + run: | + curl -X POST -H "Content-Type: application/json" --data '{"content":"Deployment started!"}' ${{ secrets.DISCORD_WEBHOOK }} + # ssh๋กœ ์ ‘์†ํ•ด ์žฌ๋ฐฐํฌ - name: Deploy uses: appleboy/ssh-action@master @@ -79,7 +85,18 @@ jobs: docker-compose pull docker-compose up -d + # ๋ฐฐํฌ ์™„๋ฃŒ ์•Œ๋ฆผ ์ „์†ก + - name: Notify Deployment Completed + if: success() + run: | + curl -X POST -H "Content-Type: application/json" --data '{"content":"Deployment completed successfully!"}' ${{ secrets.DISCORD_WEBHOOK }} + - name: Notify Deployment Failed + if: failure() + run: | + curl -X POST -H "Content-Type: application/json" --data '{"content":"Deployment failed!"}' ${{ secrets.DISCORD_WEBHOOK }} + # ๋ฐฐํฌ ํ›„ ๋ณด์•ˆ ๊ทธ๋ฃน์—์„œ github ip ์‚ญ์ œ - name: Remove Github Actions IP From Security Group + if: always() run: | aws ec2 revoke-security-group-ingress --group-id ${{ secrets.AWS_SG_ID }} --protocol tcp --port 22 --cidr ${{ steps.ip.outputs.ipv4 }}/32 \ No newline at end of file From 4c4afd2f56a1640614c161ee15ba6a65fb5b209b Mon Sep 17 00:00:00 2001 From: jiseon Date: Tue, 19 Nov 2024 15:52:09 +0900 Subject: [PATCH 5/5] =?UTF-8?q?ITDS-63=20fix:=20=EB=AA=A8=EC=A7=91=20?= =?UTF-8?q?=EB=A7=88=EA=B0=90=EC=9D=BC=20not=20null=20=EC=84=A4=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/dissonance/itit/domain/entity/InfoPost.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/com/dissonance/itit/domain/entity/InfoPost.java b/src/main/java/com/dissonance/itit/domain/entity/InfoPost.java index 5533bc1..b3809c1 100644 --- a/src/main/java/com/dissonance/itit/domain/entity/InfoPost.java +++ b/src/main/java/com/dissonance/itit/domain/entity/InfoPost.java @@ -52,6 +52,7 @@ public class InfoPost extends BaseTime { @Column(name = "recruitment_start_date") private LocalDate recruitmentStartDate; + @NotNull @Column(name = "recruitment_end_date") private LocalDate recruitmentEndDate;