Skip to content
This repository was archived by the owner on Apr 16, 2024. It is now read-only.

Commit 2c4a815

Browse files
authored
Use kaniko instead dind DK-1985 (#4)
* use kaniko instead dind * remove unsec flag * mkdir folder
1 parent 6309063 commit 2c4a815

File tree

1 file changed

+7
-33
lines changed

1 file changed

+7
-33
lines changed

Jenkinsfile

Lines changed: 7 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@ podTemplate(label: 'k8skafka-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: 'k8skafka-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 ('k8skafka-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: 'k8skafka-controller',
5653

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

59-
container('docker') {
60-
sh "docker build . -t nexus.doodle.com:5000/devops/k8skafka-controller:${env.TAG_NAME}"
61-
sh "docker push nexus.doodle.com:5000/devops/k8skafka-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` --destination='nexus.doodle.com:5000/devops/k8skafka-controller:${env.TAG_NAME}'"
6259
}
6360

6461
container('helm') {
@@ -69,7 +66,6 @@ podTemplate(label: 'k8skafka-controller',
6966
sh "mkdir chart/k8skafka-controller/crds"
7067
sh "cp config/crd/bases/* chart/k8skafka-controller/crds"
7168
sh "helm package chart/k8skafka-controller"
72-
7369
}
7470

7571
container('golang') {
@@ -86,28 +82,6 @@ podTemplate(label: 'k8skafka-controller',
8682
}
8783
}
8884

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

0 commit comments

Comments
 (0)