From b197a23af2f45661655c46c0efa9d14ca0b7ce13 Mon Sep 17 00:00:00 2001 From: Jonathan Ervine Date: Mon, 20 Jul 2020 22:25:31 +0800 Subject: [PATCH] Switched to node builder --- Dockerfile | 10 ++-------- Jenkinsfile | 56 ++++++++++++++++++++++++++++++----------------------- 2 files changed, 34 insertions(+), 32 deletions(-) diff --git a/Dockerfile b/Dockerfile index 6834f89..ec999f5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -11,13 +11,8 @@ ENV LANG='en_US.UTF-8' \ RUN echo http://dl-4.alpinelinux.org/alpine/edge/testing >> /etc/apk/repositories && \ apk update && \ - apk -U upgrade && \ - apk -U add \ - python \ - py-lxml \ - py-simplejson \ - openssl \ - py-openssl + apk -U upgrade --ignore alpine-baselayout && \ + apk -U add python py-lxml py-simplejson openssl py-openssl RUN wget https://github.com/CouchPotato/CouchPotatoServer/archive/$VERSION.tar.gz -O couchpotato.tar.gz && \ tar zxvf couchpotato.tar.gz && \ @@ -31,5 +26,4 @@ COPY start.sh /usr/local/bin/start.sh EXPOSE 5050 - CMD [ "/usr/local/bin/start.sh" ] diff --git a/Jenkinsfile b/Jenkinsfile index e78f143..adea551 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,26 +1,34 @@ -node("docker-node") { - docker.withRegistry('https://harbor.ervine.dev', 'jenkins-to-harbor') { - - git branch: "master", url: "ssh://git@git.ervine.org/jonny/x86_64-alpine-cp", credentialsId: 'jenkins-to-git' - - sh "git rev-parse HEAD > .git/commit-id" - def commit_id = readFile('.git/commit-id').trim() - println commit_id - - try { - stage "build" - def app = docker.build "library/x86_64/alpine/couchpotato" - - stage "publish" - app.push("${env.BUILD_NUMBER}") - app.push("latest") - - stage('Deploy on K8s'){ - sh "/usr/local/bin/kubectl -n media delete po cp-0 && kubectl -n media delete po cp-kids-0" - } - } - catch (err) { - currentBuild.result = 'FAILURE' - } +podTemplate(yaml: """ +kind: Pod +spec: + containers: + - name: kaniko + image: gcr.io/kaniko-project/executor:debug-539ddefcae3fd6b411a95982a830d987f4214251 + imagePullPolicy: Always + command: + - /busybox/cat + tty: true + volumeMounts: + - name: jenkins-docker-cfg + mountPath: /kaniko/.docker + volumes: + - name: jenkins-docker-cfg + projected: + sources: + - secret: + name: regcred + items: + - key: .dockerconfigjson + path: config.json +""" + ) { + + node(POD_LABEL) { + stage('Build with Kaniko') { + git url: 'ssh://git@git.ervine.org/jonny/x86_64-alpine-cp.git', credentialsId: 'jenkins-to-git' + container('kaniko') { + sh '/kaniko/executor -f `pwd`/Dockerfile -c `pwd` --cache=true --destination=harbor.ervine.dev/library/x86_64/alpine/cp:3.12.0 --destination=harbor.ervine.dev/library/x86_64/alpine/cp:3.12' + } } + } }