-
Notifications
You must be signed in to change notification settings - Fork 22
/
Jenkinsfile
96 lines (89 loc) · 2.67 KB
/
Jenkinsfile
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
pipeline {
agent any
options {
buildDiscarder(logRotator(numToKeepStr: '5', daysToKeepStr: '5'))
timestamps()
}
environment {
DOCKER_IMAGE = 'bmd1905/open-webui'
DOCKER_TAG = "${env.BUILD_NUMBER}"
DOCKER_FULL_IMAGE = "${DOCKER_IMAGE}:${DOCKER_TAG}"
DOCKER_REGISTRY_CREDENTIAL = 'dockerhub'
WEBUI_DOCKER_TAG = "${env.BUILD_NUMBER}"
}
stages {
stage('Run Tests') {
steps {
script {
echo 'Running tests...'
// Uncomment and adjust as needed
// sh './run-tests.sh'
}
}
}
stage('Build Docker Image') {
steps {
script {
echo 'Building Docker image using Docker Compose...'
dir('open-webui') {
sh "WEBUI_DOCKER_TAG=${env.BUILD_NUMBER} docker compose -f docker-compose.yaml build"
}
}
}
}
stage('Push Docker Image') {
steps {
script {
echo 'Pushing Docker image to the registry...'
docker.withRegistry('', DOCKER_REGISTRY_CREDENTIAL) {
docker.image("${DOCKER_FULL_IMAGE}").push()
docker.image("${DOCKER_FULL_IMAGE}").push('latest')
}
}
}
}
stage('Deploy to Google Kubernetes Engine') {
agent {
kubernetes {
yaml '''
apiVersion: v1
kind: Pod
spec:
containers:
- name: helm
image: bmd1905/jenkins-k8s:lts-jdk17
imagePullPolicy: Always
command:
- cat
tty: true
'''
}
}
steps {
script {
container('helm') {
sh("kubectl apply -f ./open-webui/kubernetes/manifest/base -n model-serving")
}
}
}
}
}
post {
success {
script {
echo 'Build and Deployment successful.'
}
}
failure {
script {
echo 'Build or Deployment failed!'
}
}
cleanup {
script {
echo 'Cleaning up...'
sh 'docker image prune -f'
}
}
}
}