Add CI/CD
This commit is contained in:
parent
b60030173b
commit
f3a6d06577
19
deployment/Jenkinsfile
vendored
19
deployment/Jenkinsfile
vendored
@ -37,14 +37,14 @@ podTemplate(
|
||||
stage('Code Analysis & Quality Gate') {
|
||||
container('node') {
|
||||
sh "npm install"
|
||||
sh "npm test -- --coverage --passWithNoTests" //test code 없어도 통과되게 함
|
||||
sh "npm test -- --coverage --passWithNoTests"
|
||||
}
|
||||
|
||||
container('sonar-scanner') {
|
||||
withSonarQubeEnv('SonarQube') {
|
||||
sh """
|
||||
${sonarScannerHome}/bin/sonar-scanner \
|
||||
-Dsonar.projectKey=lifesub-web \
|
||||
-Dsonar.projectKey=lifesub-web-lifesub-web-dg0400 \
|
||||
-Dsonar.sources=src \
|
||||
-Dsonar.tests=src \
|
||||
-Dsonar.test.inclusions=src/**/*.test.js,src/**/*.test.jsx \
|
||||
@ -66,7 +66,7 @@ podTemplate(
|
||||
withCredentials([azureServicePrincipal('azure-credentials')]) {
|
||||
sh """
|
||||
az login --service-principal -u \$AZURE_CLIENT_ID -p \$AZURE_CLIENT_SECRET -t \$AZURE_TENANT_ID
|
||||
az aks get-credentials --resource-group ictcoe-edu --name ${props.teamid}-aks --overwrite-existing
|
||||
az aks get-credentials --resource-group rg-digitalgarage-01 --name aks-digitalgarage-01 --overwrite-existing
|
||||
kubectl create namespace ${namespace} --dry-run=client -o yaml | kubectl apply -f -
|
||||
"""
|
||||
}
|
||||
@ -87,12 +87,9 @@ podTemplate(
|
||||
|
||||
podman build \
|
||||
--build-arg PROJECT_FOLDER="." \
|
||||
--build-arg REACT_APP_MEMBER_URL="${props.react_app_member_url}" \
|
||||
--build-arg REACT_APP_MYSUB_URL="${props.react_app_mysub_url}" \
|
||||
--build-arg REACT_APP_RECOMMEND_URL="${props.react_app_recommend_url}" \
|
||||
--build-arg BUILD_FOLDER="deployment" \
|
||||
--build-arg BUILD_FOLDER="deployment/container" \
|
||||
--build-arg EXPORT_PORT="${props.export_port}" \
|
||||
-f deployment/Dockerfile-lifesub-web \
|
||||
-f deployment/container/Dockerfile-lifesub-web \
|
||||
-t ${imagePath} .
|
||||
|
||||
podman push ${imagePath}
|
||||
@ -114,6 +111,7 @@ podTemplate(
|
||||
export resources_limits_memory=${props.resources_limits_memory}
|
||||
|
||||
envsubst < deployment/${manifest}.template > deployment/${manifest}
|
||||
echo "Generated manifest file:"
|
||||
cat deployment/${manifest}
|
||||
"""
|
||||
}
|
||||
@ -126,10 +124,11 @@ podTemplate(
|
||||
kubectl -n ${namespace} wait --for=condition=available deployment/lifesub-web --timeout=300s
|
||||
|
||||
echo "Waiting for service external IP..."
|
||||
while [[ -z \$(kubectl -n ${namespace} get svc lifesub-web -o jsonpath='{.status.loadBalancer.ingress[0].ip}') ]]; do
|
||||
while [[ -z \$(kubectl -n ${namespace} get svc lifesub-web-service -o jsonpath='{.status.loadBalancer.ingress[0].ip}') ]]; do
|
||||
sleep 5
|
||||
echo "Still waiting for external IP assignment..."
|
||||
done
|
||||
echo "Service external IP: \$(kubectl -n ${namespace} get svc lifesub-web -o jsonpath='{.status.loadBalancer.ingress[0].ip}')"
|
||||
echo "Service external IP: \$(kubectl -n ${namespace} get svc lifesub-web-service -o jsonpath='{.status.loadBalancer.ingress[0].ip}')"
|
||||
"""
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,9 +1,26 @@
|
||||
# Frontend Deployment
|
||||
# ConfigMap
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: frontend-config
|
||||
namespace: ${namespace}
|
||||
data:
|
||||
runtime-env.js: |
|
||||
window.__runtime_config__ = {
|
||||
MEMBER_URL: 'http://dg0400.20.214.196.128.nip.io/api/auth',
|
||||
MYSUB_URL: 'http://dg0400.20.214.196.128.nip.io/api/mysub',
|
||||
RECOMMEND_URL: 'http://dg0400.20.214.196.128.nip.io/api/recommend'
|
||||
};
|
||||
|
||||
---
|
||||
# Deployment
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: lifesub-web
|
||||
namespace: ${namespace}
|
||||
labels:
|
||||
app: lifesub-web
|
||||
spec:
|
||||
replicas: ${replicas}
|
||||
selector:
|
||||
@ -14,6 +31,8 @@ spec:
|
||||
labels:
|
||||
app: lifesub-web
|
||||
spec:
|
||||
imagePullSecrets:
|
||||
- name: acr-secret
|
||||
containers:
|
||||
- name: lifesub-web
|
||||
image: ${lifesub_web_image_path}
|
||||
@ -27,18 +46,29 @@ spec:
|
||||
limits:
|
||||
cpu: ${resources_limits_cpu}
|
||||
memory: ${resources_limits_memory}
|
||||
volumeMounts:
|
||||
- name: runtime-config
|
||||
mountPath: /usr/share/nginx/html/runtime-env.js
|
||||
subPath: runtime-env.js
|
||||
volumes:
|
||||
- name: runtime-config
|
||||
configMap:
|
||||
name: frontend-config
|
||||
|
||||
---
|
||||
# Frontend Service
|
||||
# Service
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: lifesub-web
|
||||
name: lifesub-web-service
|
||||
namespace: ${namespace}
|
||||
spec:
|
||||
selector:
|
||||
labels:
|
||||
app: lifesub-web
|
||||
spec:
|
||||
type: LoadBalancer
|
||||
ports:
|
||||
- port: 80
|
||||
targetPort: ${export_port}
|
||||
type: LoadBalancer
|
||||
protocol: TCP
|
||||
selector:
|
||||
app: lifesub-web
|
||||
|
||||
@ -1,21 +1,16 @@
|
||||
# Team Settings
|
||||
teamid=unicorn
|
||||
teamid=dg0400
|
||||
root_project=lifesub-web
|
||||
namespace=unicorn-lifesub-ns
|
||||
namespace=dg0400-lifesub-ns
|
||||
|
||||
# Container Registry Settings
|
||||
registry=unicorncr.azurecr.io
|
||||
image_org=lifesub
|
||||
registry=acrdigitalgarage01.azurecr.io
|
||||
image_org=dg0400
|
||||
|
||||
# Application Settings
|
||||
replicas=1
|
||||
export_port=18080
|
||||
|
||||
# Backend Service URLs
|
||||
react_app_member_url=http://20.249.205.95/member
|
||||
react_app_mysub_url=http://20.249.205.95/mysub
|
||||
react_app_recommend_url=http://20.249.205.95/recommend
|
||||
|
||||
# Resource Settings
|
||||
resources_requests_cpu=256m
|
||||
resources_requests_memory=256Mi
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user