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

Commit

Permalink
Use kaniko instead dind DK-1985 (#4)
Browse files Browse the repository at this point in the history
* use kaniko instead dind

* remove unsec flag

* mkdir folder
  • Loading branch information
raffis committed May 4, 2021
1 parent 6309063 commit 2c4a815
Showing 1 changed file with 7 additions and 33 deletions.
40 changes: 7 additions & 33 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ podTemplate(label: 'k8skafka-controller',
ttyEnabled: true
),
containerTemplate(
name: 'docker',
image: 'docker:latest',
name: 'kaniko',
command: '/busybox/cat',
image: 'gcr.io/kaniko-project/executor:debug',
ttyEnabled: true
),
containerTemplate(
Expand All @@ -21,17 +22,13 @@ podTemplate(label: 'k8skafka-controller',
),
],
volumes: [
hostPathVolume(mountPath: '/var/run/docker.sock', hostPath: '/var/run/docker.sock'),
secretVolume(secretName: 'dockerauth', mountPath: '/root/dockerauth')
]
) {
node ('k8skafka-controller') {
ansiColor("xterm") {
stage('checkout') {
checkout(scm)

container('docker') {
dockerAuth()
}
}

stage("build") {
Expand All @@ -56,9 +53,9 @@ podTemplate(label: 'k8skafka-controller',

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

container('docker') {
sh "docker build . -t nexus.doodle.com:5000/devops/k8skafka-controller:${env.TAG_NAME}"
sh "docker push nexus.doodle.com:5000/devops/k8skafka-controller:${env.TAG_NAME}"
container(name: 'kaniko', shell: '/busybox/sh') {
sh "cp /root/dockerauth/.dockerconfigjson /kaniko/.docker/config.json"
sh "/kaniko/executor -f `pwd`/Dockerfile -c `pwd` --destination='nexus.doodle.com:5000/devops/k8skafka-controller:${env.TAG_NAME}'"
}

container('helm') {
Expand All @@ -69,7 +66,6 @@ podTemplate(label: 'k8skafka-controller',
sh "mkdir chart/k8skafka-controller/crds"
sh "cp config/crd/bases/* chart/k8skafka-controller/crds"
sh "helm package chart/k8skafka-controller"

}

container('golang') {
Expand All @@ -86,28 +82,6 @@ podTemplate(label: 'k8skafka-controller',
}
}

void dockerAuth() {
// nexus repository
withCredentials([[
$class : 'UsernamePasswordMultiBinding',
credentialsId : 'nexus',
usernameVariable: 'NEXUS_USER',
passwordVariable: 'NEXUS_PASSWORD'
]]) {
sh "docker login nexus.doodle.com:5000 -u ${env.NEXUS_USER} -p ${env.NEXUS_PASSWORD}"
}

// docker hub
withCredentials([[
$class : 'UsernamePasswordMultiBinding',
credentialsId : 'dockerhub',
usernameVariable: 'DOCKERHUB_USER',
passwordVariable: 'DOCKERHUB_PASSWORD'
]]) {
sh "docker login -u ${env.DOCKERHUB_USER} -p ${env.DOCKERHUB_PASSWORD}"
}
}

def bumpImageVersion(String version) {
echo "Update image tag"
def valuesFile = "./chart/k8skafka-controller/values.yaml"
Expand Down

0 comments on commit 2c4a815

Please sign in to comment.