Skip to content

Commit 178d81f

Browse files
authored
Merge pull request #11 from DoodleScheduling/kaniko-DK-1985
Use kaniko instead dind DK-1985
2 parents e78c232 + 1a39e69 commit 178d81f

File tree

2 files changed

+8
-32
lines changed

2 files changed

+8
-32
lines changed

Jenkinsfile

Lines changed: 8 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,16 +53,17 @@ 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` --destination='nexus.doodle.com:5000/devops/k8sdb-controller:${env.TAG_NAME}'"
6259
}
6360

6461
container('helm') {
6562
bumpChartVersion(version)
6663
bumpImageVersion(env.TAG_NAME)
6764

6865
tgz="k8sdb-controller-${version}.tgz"
66+
sh "mkdir chart/k8sdb-controller/crds"
6967
sh "cp config/crd/bases/* chart/k8sdb-controller/crds"
7068
sh "helm package chart/k8sdb-controller"
7169
}
@@ -84,28 +82,6 @@ podTemplate(label: 'k8sdb-controller',
8482
}
8583
}
8684

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-
10985
def bumpImageVersion(String version) {
11086
echo "Update image tag"
11187
def valuesFile = "./chart/k8sdb-controller/values.yaml"

chart/k8sdb-controller/crds/.gitkeep

Whitespace-only changes.

0 commit comments

Comments
 (0)