refactor: Jenkinsfile & env

This commit is contained in:
OhSeongRak 2025-06-18 10:11:20 +09:00
parent d7d13d2dba
commit 2da126a95a
2 changed files with 104 additions and 13 deletions

View File

@ -121,6 +121,21 @@ podTemplate(
export resources_limits_cpu=${props.resources_limits_cpu} export resources_limits_cpu=${props.resources_limits_cpu}
export resources_limits_memory=${props.resources_limits_memory} export resources_limits_memory=${props.resources_limits_memory}
# API URLs도 export (혹시 사용할 수도 있으니)
export auth_url=${props.auth_url}
export member_url=${props.member_url}
export store_url=${props.store_url}
export menu_url=${props.menu_url}
export sales_url=${props.sales_url}
export content_url=${props.content_url}
export recommend_url=${props.recommend_url}
echo "=== 환경변수 확인 ==="
echo "namespace: \$namespace"
echo "ingress_host: \$ingress_host"
echo "export_port: \$export_port"
echo "========================="
envsubst < deployment/${manifest}.template > deployment/${manifest} envsubst < deployment/${manifest}.template > deployment/${manifest}
echo "Generated manifest file:" echo "Generated manifest file:"
cat deployment/${manifest} cat deployment/${manifest}

View File

@ -1,4 +1,3 @@
# ConfigMap
apiVersion: v1 apiVersion: v1
kind: ConfigMap kind: ConfigMap
metadata: metadata:
@ -6,18 +5,75 @@ metadata:
namespace: ${namespace} namespace: ${namespace}
data: data:
runtime-env.js: | runtime-env.js: |
console.log('=== RUNTIME-ENV.JS 로드됨 (배포 환경) ===');
window.__runtime_config__ = { window.__runtime_config__ = {
AUTH_URL: '${auth_url}', // 백엔드 API 구조에 맞게 URL 설정
MEMBER_URL: '${member_url}', AUTH_URL: '${auth_url}',
STORE_URL: '${store_url}', MEMBER_URL: '${member_url}',
MENU_URL: '${menu_url}', STORE_URL: '${store_url}',
SALES_URL: '${sales_url}', MENU_URL: '${menu_url}',
CONTENT_URL: '${content_url}', SALES_URL: '${sales_url}',
RECOMMEND_URL: '${recommend_url}' CONTENT_URL: '${content_url}',
RECOMMEND_URL: '${recommend_url}',
// Gateway URL (운영 환경)
GATEWAY_URL: 'http://${ingress_host}',
// 기능 플래그
FEATURES: {
ANALYTICS: true,
PUSH_NOTIFICATIONS: true,
SOCIAL_LOGIN: false,
MULTI_LANGUAGE: false,
API_HEALTH_CHECK: true,
},
// 환경 설정 (배포 환경)
ENV: 'production',
DEBUG: false,
// API 타임아웃 설정
API_TIMEOUT: 30000,
// 재시도 설정
RETRY_ATTEMPTS: 3,
RETRY_DELAY: 1000,
// 버전 정보
VERSION: '1.0.0',
BUILD_DATE: new Date().toISOString()
}; };
// 설정 검증 함수
const validateConfig = () => {
const config = window.__runtime_config__;
const requiredUrls = ['AUTH_URL', 'STORE_URL', 'SALES_URL', 'RECOMMEND_URL'];
for (const url of requiredUrls) {
if (!config[url]) {
console.error(`❌ [CONFIG] 필수 URL 누락: ${url}`);
return false;
}
}
console.log('✅ [CONFIG] 설정 검증 완료');
return true;
};
// 전역 설정 접근 함수
window.getApiConfig = () => window.__runtime_config__;
window.getApiUrl = (serviceName) => {
const config = window.__runtime_config__;
const urlKey = `${serviceName.toUpperCase()}_URL`;
return config[urlKey] || null;
};
// 설정 검증 실행
validateConfig();
console.log('✅ [RUNTIME] 런타임 설정 로드 완료 (배포 환경)');
--- ---
# Deployment
apiVersion: apps/v1 apiVersion: apps/v1
kind: Deployment kind: Deployment
metadata: metadata:
@ -56,7 +112,7 @@ spec:
subPath: runtime-env.js subPath: runtime-env.js
livenessProbe: livenessProbe:
httpGet: httpGet:
path: / path: /health
port: ${export_port} port: ${export_port}
initialDelaySeconds: 30 initialDelaySeconds: 30
periodSeconds: 10 periodSeconds: 10
@ -64,7 +120,7 @@ spec:
failureThreshold: 3 failureThreshold: 3
readinessProbe: readinessProbe:
httpGet: httpGet:
path: / path: /health
port: ${export_port} port: ${export_port}
initialDelaySeconds: 5 initialDelaySeconds: 5
periodSeconds: 5 periodSeconds: 5
@ -76,7 +132,6 @@ spec:
name: smarketing-frontend-config name: smarketing-frontend-config
--- ---
# Service
apiVersion: v1 apiVersion: v1
kind: Service kind: Service
metadata: metadata:
@ -93,3 +148,24 @@ spec:
name: http name: http
selector: selector:
app: smarketing-frontend app: smarketing-frontend
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: smarketing-frontend-ingress
namespace: ${namespace}
annotations:
nginx.ingress.kubernetes.io/rewrite-target: /
spec:
rules:
- host: ${ingress_host}
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: smarketing-frontend-service
port:
number: 80