-
Notifications
You must be signed in to change notification settings - Fork 211
/
docker.groovy
57 lines (55 loc) · 2.05 KB
/
docker.groovy
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
parameters {
string(
description: '输入版本号',
name: 'version',
defaultValue: '1.0'
)
}
def version = "${params.version}"
node {
stage('git chekout') {
git branch: 'main',
url: 'https://github.com/PierXuY/ChatGPT-Assistant.git'
}
stage('dockerFile') {
sh 'rm -rf code && mkdir code'
sh 'cp *.py ./code && cp Dockerfile ./code && cp requirements.txt ./code && cp *.sh ./code'
sh 'cp -r ./libs ./text_toolkit ./voice_toolkit ./.streamlit ./code'
dir('code'){
stash 'code'
}
}
stage('parallel docker build') {
parallel (
'docker build && push arm64': {
node('arm64') {
dir('workdir'){
unstash 'code'
}
sh 'cd workdir && docker build . -t pi4k8s/chatgpt-ai:$version-arm64'
sh 'docker push pi4k8s/chatgpt-ai:$version-arm64'
}
},
'docker build && push amd64': {
node('amd64') {
dir('workdir'){
unstash 'code'
}
sh 'cd workdir && docker build . -t pi4k8s/chatgpt-ai:$version-amd64'
sh 'docker push pi4k8s/chatgpt-ai:$version-amd64'
}
}
)
}
stage('manifest'){
try {
sh "docker manifest rm pi4k8s/chatgpt-ai:$version"
}catch(exc){
echo "some thing wrong"
}
sh "docker manifest create pi4k8s/chatgpt-ai:$version pi4k8s/chatgpt-ai:$version-amd64 pi4k8s/chatgpt-ai:$version-arm64"
sh "docker manifest annotate pi4k8s/chatgpt-ai:$version pi4k8s/chatgpt-ai:$version-amd64 --os linux --arch amd64"
sh "docker manifest annotate pi4k8s/chatgpt-ai:$version pi4k8s/chatgpt-ai:$version-arm64 --os linux --arch arm64"
sh "docker manifest push pi4k8s/chatgpt-ai:$version"
}
}