feat: cicd pipeline

This commit is contained in:
2025-11-12 23:02:47 +09:00
parent 1fb168850b
commit f1cd9b7fdb
11 changed files with 821 additions and 99 deletions

View File

@@ -0,0 +1,99 @@
package com.kamco.cd.kamcoback.config;
import com.zaxxer.hikari.HikariDataSource;
import javax.sql.DataSource;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.context.event.ApplicationReadyEvent;
import org.springframework.context.event.EventListener;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Component;
@Slf4j
@Component
@RequiredArgsConstructor
public class StartupLogger {
private final Environment environment;
private final DataSource dataSource;
@EventListener(ApplicationReadyEvent.class)
public void logStartupInfo() {
String[] activeProfiles = environment.getActiveProfiles();
String profileInfo =
activeProfiles.length > 0 ? String.join(", ", activeProfiles) : "default";
// Database connection information
String dbUrl = environment.getProperty("spring.datasource.url");
String dbUsername = environment.getProperty("spring.datasource.username");
String dbDriver = environment.getProperty("spring.datasource.driver-class-name");
// HikariCP pool settings
String poolInfo = "";
if (dataSource instanceof HikariDataSource hikariDs) {
poolInfo =
String.format(
"""
│ Pool Size : min=%d, max=%d
│ Connection Timeout: %dms
│ Idle Timeout : %dms
│ Max Lifetime : %dms""",
hikariDs.getMinimumIdle(),
hikariDs.getMaximumPoolSize(),
hikariDs.getConnectionTimeout(),
hikariDs.getIdleTimeout(),
hikariDs.getMaxLifetime());
}
// JPA/Hibernate settings
String showSql = environment.getProperty("spring.jpa.show-sql", "false");
String ddlAuto = environment.getProperty("spring.jpa.hibernate.ddl-auto", "none");
String batchSize =
environment.getProperty("spring.jpa.properties.hibernate.jdbc.batch_size", "N/A");
String batchFetchSize =
environment.getProperty(
"spring.jpa.properties.hibernate.default_batch_fetch_size", "N/A");
String startupMessage =
String.format(
"""
╔════════════════════════════════════════════════════════════════════════════════╗
║ 🚀 APPLICATION STARTUP INFORMATION ║
╠════════════════════════════════════════════════════════════════════════════════╣
║ PROFILE CONFIGURATION ║
╠────────────────────────────────────────────────────────────────────────────────╣
│ Active Profile(s): %s
╠════════════════════════════════════════════════════════════════════════════════╣
║ DATABASE CONFIGURATION ║
╠────────────────────────────────────────────────────────────────────────────────╣
│ Database URL : %s
│ Username : %s
│ Driver : %s
╠════════════════════════════════════════════════════════════════════════════════╣
║ HIKARICP CONNECTION POOL ║
╠────────────────────────────────────────────────────────────────────────────────╣
%s
╠════════════════════════════════════════════════════════════════════════════════╣
║ JPA/HIBERNATE CONFIGURATION ║
╠────────────────────────────────────────────────────────────────────────────────╣
│ Show SQL : %s
│ DDL Auto : %s
│ JDBC Batch Size : %s
│ Fetch Batch Size : %s
╚════════════════════════════════════════════════════════════════════════════════╝
""",
profileInfo,
dbUrl != null ? dbUrl : "N/A",
dbUsername != null ? dbUsername : "N/A",
dbDriver != null ? dbDriver : "PostgreSQL JDBC Driver (auto-detected)",
poolInfo,
showSql,
ddlAuto,
batchSize,
batchFetchSize);
log.info(startupMessage);
}
}

View File

@@ -0,0 +1,25 @@
spring:
config:
activate:
on-profile: dev
jpa:
show-sql: true
hibernate:
ddl-auto: validate
properties:
hibernate:
default_batch_fetch_size: 100 # ✅ 성능 - N+1 쿼리 방지
order_updates: true # ✅ 성능 - 업데이트 순서 정렬로 데드락 방지
use_sql_comments: true # ⚠️ 선택 - SQL에 주석 추가 (디버깅용)
format_sql: true # ⚠️ 선택 - SQL 포맷팅 (가독성)
datasource:
url: jdbc:postgresql://10.100.0.10:25432/temp
username: temp
password: temp123!
hikari:
minimum-idle: 10
maximum-pool-size: 20

View File

@@ -0,0 +1,25 @@
spring:
config:
activate:
on-profile: local
jpa:
show-sql: true
hibernate:
ddl-auto: validate
properties:
hibernate:
default_batch_fetch_size: 100 # ✅ 성능 - N+1 쿼리 방지
order_updates: true # ✅ 성능 - 업데이트 순서 정렬로 데드락 방지
use_sql_comments: true # ⚠️ 선택 - SQL에 주석 추가 (디버깅용)
format_sql: true # ⚠️ 선택 - SQL 포맷팅 (가독성)
datasource:
url: jdbc:postgresql://10.100.0.10:25432/temp
username: temp
password: temp123!
hikari:
minimum-idle: 1
maximum-pool-size: 5

View File

@@ -0,0 +1,24 @@
spring:
config:
activate:
on-profile: dev
jpa:
show-sql: false
hibernate:
ddl-auto: validate
properties:
hibernate:
default_batch_fetch_size: 100 # ✅ 성능 - N+1 쿼리 방지
order_updates: true # ✅ 성능 - 업데이트 순서 정렬로 데드락 방지
use_sql_comments: true # ⚠️ 선택 - SQL에 주석 추가 (디버깅용)
datasource:
url: jdbc:postgresql://10.100.0.10:25432/temp
username: temp
password: temp123!
hikari:
minimum-idle: 10
maximum-pool-size: 20

View File

@@ -1,83 +1,59 @@
server:
port: 8080
spring:
application:
name: kamco-back
name: kamco-change-detection-api
profiles:
default: local
active: local # 사용할 프로파일 지정 (ex. dev, prod, test)
server:
port: 8080
# -----------------------
# local
# -----------------------
---
server:
port: 8080
spring:
config:
activate:
on-profile: local
datasource:
driver-class-name: org.postgresql.Driver
url: jdbc:postgresql://10.100.0.10:25432/temp
username: temp
password: temp123!
hikari:
minimum-idle: 10
maximum-pool-size: 50
jdbc:
time_zone: UTC
batch_size: 50
# 권장 설정
minimum-idle: 2
maximum-pool-size: 2
connection-timeout: 20000
idle-timeout: 300000
max-lifetime: 1800000
leak-detection-threshold: 60000
jpa:
hibernate:
ddl-auto: none # 또는 update/create
show-sql: true
ddl-auto: validate
properties:
hibernate:
format_sql: true
jdbc:
batch_size: 50
default_batch_fetch_size: 100
logging:
level:
org:
springframework:
web: DEBUG
security: DEBUG
root: INFO
# actuator
management:
health:
readinessstate:
enabled: true
livenessstate:
enabled: true
endpoint:
health:
probes:
enabled: true
show-details: always
endpoints:
jmx:
exposure:
exclude: "*"
web:
base-path: /monitor
exposure:
include:
- "health"
# -----------------------
# dev
# -----------------------
---
server:
port: 3333
spring:
config:
activate:
on-profile: dev
datasource:
driver-class-name: org.postgresql.Driver
url: jdbc:postgresql://10.100.0.10:25432/temp
username: temp
password: temp123!
jpa:
hibernate:
ddl-auto: none # 또는 update/create
show-sql: true
properties:
hibernate:
format_sql: true
# -----------------------
# prod
# -----------------------
---
server:
port: 8080
spring:
config:
activate:
on-profile: prod
datasource:
driver-class-name: org.postgresql.Driver
url: jdbc:postgresql://10.100.0.10:25432/temp
username: temp
password: temp123!
jpa:
hibernate:
ddl-auto: validate # 또는 update/create
show-sql: true
properties:
hibernate:
format_sql: true