-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkapok-build-native.groovy
86 lines (83 loc) · 1.87 KB
/
kapok-build-native.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
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
/**
* 本範例展示如何將一個 Kapok 專案打包成 native image
*/
pipeline {
agent {
kubernetes {
cloud 'SLKE'
yaml """
kind: Pod
spec:
# All containers should have the same UID
securityContext:
runAsUser: 0
containers:
- name: maven
image: harbor.softleader.com.tw/library/maven:3-graalvm-community-21
command: ['cat']
tty: true
resources:
limits:
memory: "1Gi"
cpu: "1"
volumeMounts:
- name: m2
mountPath: /root/.m2
- name: dockersock
mountPath: /var/run/docker.sock
- name: docker
image: docker:dind
command: ['cat']
tty: true
resources:
limits:
memory: "100Mi"
cpu: "100m"
volumeMounts:
- name: dockersock
mountPath: /var/run/docker.sock
volumes:
- name: m2
persistentVolumeClaim:
claimName: m2-claim
- name: dockersock
hostPath:
path: /var/run/docker.sock
"""
}
}
environment {
DATA="/app"
IMAGE_REGISTRY="jenkins-pipeline-examples"
IMAGE_PROJECT="kapok-build-native"
IMAGE_NAME="${IMAGE_REGISTRY}/${IMAGE_PROJECT}/demo:1.0.0"
}
stages {
stage ('Download source code') {
steps {
container('maven') {
sh """
curl -SL 'http://start-kapok.192.168.1.240.nip.io/starter.zip?jvmVersion=21&dependencies=native' -o ${DATA}/demo.zip
unzip -o ${DATA}/demo.zip -d ${DATA}
rm -f ${DATA}/demo.zip
"""
}
}
}
stage ('Compile and build image') {
steps {
container('maven') {
sh """
mvn -f ${DATA}/pom.xml spring-boot:build-image -Pnative -Dcontainer-image-repository=${IMAGE_REGISTRY} -Dcontainer-image-project=${IMAGE_PROJECT}
"""
}
container('docker') {
sh """
docker run --rm ${IMAGE_NAME}
docker rmi -f ${IMAGE_NAME}
"""
}
}
}
}
}