-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJenkinsfile
More file actions
118 lines (109 loc) · 3.8 KB
/
Jenkinsfile
File metadata and controls
118 lines (109 loc) · 3.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
pipeline {
agent any
stages {
stage('Checkout') {
steps {
git url: 'https://github.com/Yeoun-project/yeoun.git', branch: 'develop'
}
}
stage('Build And Deploy') {
parallel {
stage('Frontend') {
stages {
stage('Frontend Generate Env') {
steps {
withCredentials([
string(credentialsId: 'yeoun-front-vite-api-base-url', variable: 'VITE_API_BASE_URL'),
string(credentialsId: 'yeoun-front-vite-oauth-google', variable: 'VITE_OAUTH_GOOGLE'),
string(credentialsId: 'yeoun-front-vite-oauth-kakao', variable: 'VITE_OAUTH_KAKAO'),
string(credentialsId: 'yeoun-front-vite-oauth-naver', variable: 'VITE_OAUTH_NAVER'),
]) {
sh '''
cat <<EOF > frontend/.env.production
VITE_API_BASE_URL=$VITE_API_BASE_URL
VITE_OAUTH_GOOGLE=$VITE_OAUTH_GOOGLE
VITE_OAUTH_KAKAO=$VITE_OAUTH_KAKAO
VITE_OAUTH_NAVER=$VITE_OAUTH_NAVER
EOF
'''
}
}
}
stage('Frontend Build') {
steps {
sh '''
docker build \
-f frontend/Dockerfile \
-t yeoun-front:latest .
'''
}
}
stage('Frontend Deploy') {
steps {
sh '''
docker rm -f yeoun-front || true
docker run -d \
--restart=always \
--name yeoun-front \
--network yeoun-network \
-p 80:80 -p 443:443 \
-e TZ=Asia/Seoul \
-v /etc/letsencrypt:/etc/letsencrypt \
-v /home/ubuntu/certbot:/var/www/certbot \
yeoun-front:latest
'''
}
}
}
}
stage('Backend') {
stages {
stage('Backend Build') {
steps {
sh 'docker build -t yeoun-back:latest ./backend'
}
}
stage('Backend Deploy') {
steps {
withCredentials([
string(credentialsId: 'yeoun-back-jwt-secret', variable: 'JWT_SECRET'),
string(credentialsId: 'yeoun-back-db-host', variable: 'DB_HOST'),
string(credentialsId: 'yeoun-back-db-port', variable: 'DB_PORT'),
string(credentialsId: 'yeoun-back-db-password', variable: 'DB_PASSWORD'),
string(credentialsId: 'yeoun-back-oci-compute-host', variable: 'OCI_COMPUTE_HOST'),
string(credentialsId: 'yeoun-back-google-client-id', variable: 'GOOGLE_CLIENT_ID'),
string(credentialsId: 'yeoun-back-google-client-secret', variable: 'GOOGLE_SECRET'),
string(credentialsId: 'yeoun-back-naver-client-id', variable: 'NAVER_CLIENT_ID'),
string(credentialsId: 'yeoun-back-naver-client-secret', variable: 'NAVER_CLIENT_SECRET'),
string(credentialsId: 'yeoun-back-kakao-client-id', variable: 'KAKAO_CLIENT_ID')
] ){
sh '''
docker rm -f yeoun-back || true
docker run -d \
--restart=always \
--name yeoun-back \
--network yeoun-network \
-p 8080:8080 \
-e TZ=Asia/Seoul \
-e DB_HOST=$DB_HOST \
-e DB_PORT=$DB_PORT \
-e DB_PASSWORD=$DB_PASSWORD \
-e JWT_SECRET=$JWT_SECRET \
-e OCI_COMPUTE_HOST=$OCI_COMPUTE_HOST \
-e GOOGLE_CLIENT_ID=$GOOGLE_CLIENT_ID \
-e GOOGLE_SECRET=$GOOGLE_SECRET \
-e NAVER_CLIENT_ID=$NAVER_CLIENT_ID \
-e NAVER_CLIENT_SECRET=$NAVER_CLIENT_SECRET \
-e KAKAO_CLIENT_ID=$KAKAO_CLIENT_ID \
-e SPRING_PROFILES_ACTIVE=prod \
yeoun-back:latest
'''
}
}
}
}
}
}
}
}
}