Skip to content

Commit 9832094

Browse files
committed
use kaniko instead dind
1 parent e78c232 commit 9832094

File tree

1 file changed

+7
-32
lines changed

1 file changed

+7
-32
lines changed

Jenkinsfile

Lines changed: 7 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@ podTemplate(label: 'k8sdb-controller',
99
ttyEnabled: true
1010
),
1111
containerTemplate(
12-
name: 'docker',
13-
image: 'docker:latest',
12+
name: 'kaniko',
13+
command: '/busybox/cat',
14+
image: 'gcr.io/kaniko-project/executor:debug',
1415
ttyEnabled: true
1516
),
1617
containerTemplate(
@@ -21,17 +22,13 @@ podTemplate(label: 'k8sdb-controller',
2122
),
2223
],
2324
volumes: [
24-
hostPathVolume(mountPath: '/var/run/docker.sock', hostPath: '/var/run/docker.sock'),
25+
secretVolume(secretName: 'dockerauth', mountPath: '/root/dockerauth')
2526
]
2627
) {
2728
node ('k8sdb-controller') {
2829
ansiColor("xterm") {
2930
stage('checkout') {
3031
checkout(scm)
31-
32-
container('docker') {
33-
dockerAuth()
34-
}
3532
}
3633

3734
stage("build") {
@@ -56,9 +53,9 @@ podTemplate(label: 'k8sdb-controller',
5653

5754
version = "$major.$minor.$patch$group"
5855

59-
container('docker') {
60-
sh "docker build . -t nexus.doodle.com:5000/devops/k8sdb-controller:${env.TAG_NAME}"
61-
sh "docker push nexus.doodle.com:5000/devops/k8sdb-controller:${env.TAG_NAME}"
56+
container(name: 'kaniko', shell: '/busybox/sh') {
57+
sh "cp /root/dockerauth/.dockerconfigjson /kaniko/.docker/config.json"
58+
sh "/kaniko/executor -f `pwd`/Dockerfile -c `pwd` --insecure --skip-tls-verify --cache=true --destination='nexus.doodle.com:5000/devops/k8sdb-controller:${env.TAG_NAME}'"
6259
}
6360

6461
container('helm') {
@@ -84,28 +81,6 @@ podTemplate(label: 'k8sdb-controller',
8481
}
8582
}
8683

87-
void dockerAuth() {
88-
// nexus repository
89-
withCredentials([[
90-
$class : 'UsernamePasswordMultiBinding',
91-
credentialsId : 'nexus',
92-
usernameVariable: 'NEXUS_USER',
93-
passwordVariable: 'NEXUS_PASSWORD'
94-
]]) {
95-
sh "docker login nexus.doodle.com:5000 -u ${env.NEXUS_USER} -p ${env.NEXUS_PASSWORD}"
96-
}
97-
98-
// docker hub
99-
withCredentials([[
100-
$class : 'UsernamePasswordMultiBinding',
101-
credentialsId : 'dockerhub',
102-
usernameVariable: 'DOCKERHUB_USER',
103-
passwordVariable: 'DOCKERHUB_PASSWORD'
104-
]]) {
105-
sh "docker login -u ${env.DOCKERHUB_USER} -p ${env.DOCKERHUB_PASSWORD}"
106-
}
107-
}
108-
10984
def bumpImageVersion(String version) {
11085
echo "Update image tag"
11186
def valuesFile = "./chart/k8sdb-controller/values.yaml"

0 commit comments

Comments
 (0)