From 25f8884f1ea4040ac9670c71636c5b68ffb5c76d Mon Sep 17 00:00:00 2001 From: Jonathan Ervine Date: Mon, 20 Jul 2020 23:52:28 +0800 Subject: [PATCH] Switched to node builder --- Dockerfile | 3 +-- Jenkinsfile | 55 +++++++++++++++++++++++++++++++---------------------- start.sh | 2 ++ 3 files changed, 35 insertions(+), 25 deletions(-) mode change 100644 => 100755 start.sh diff --git a/Dockerfile b/Dockerfile index 8dafb95..7d60626 100644 --- a/Dockerfile +++ b/Dockerfile @@ -15,7 +15,7 @@ ENV LANG='en_US.UTF-8' \ RUN echo http://dl-4.alpinelinux.org/alpine/edge/testing >> /etc/apk/repositories && \ apk -U update && \ - apk -U upgrade && \ + apk -U upgrade --ignore alpine-baselayout && \ apk -U add \ libmediainfo \ ca-certificates \ @@ -26,7 +26,6 @@ RUN echo http://dl-4.alpinelinux.org/alpine/edge/testing >> /etc/apk/repositorie rm -rf /var/cache/apk/* ADD start.sh /usr/local/bin/start.sh -RUN chmod 755 /usr/local/bin/start.sh RUN wget https://update.sonarr.tv/v2/master/mono/NzbDrone.master.tar.gz -O nzbdrone.tar.gz && \ tar zxvf nzbdrone.tar.gz && \ diff --git a/Jenkinsfile b/Jenkinsfile index a66d4d0..dd4e349 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,26 +1,35 @@ -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-sonarr", credentialsId: 'jenkins-to-git' - - sh "git rev-parse HEAD > .git/commit-id" - def commit_id = readFile('.git/commit-id').trim() - println commit_id +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 +""" + ) { - try { - stage "build" - def app = docker.build "library/x86_64/alpine/sonarr" - - stage "publish" - app.push("v2.0.0.5344") - app.push("v2") - - stage('Deploy on K8s'){ - sh "/usr/local/bin/kubectl -n media delete po sonarr-0" - } - } - catch (err) { - currentBuild.result = 'FAILURE' - } + node(POD_LABEL) { + stage('Build with Kaniko') { + git url: 'ssh://git@git.ervine.org/jonny/x86_64-alpine-sonarr.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/sonarr:2.0.0.5344 --destination=harbor.ervine.dev/library/x86_64/alpine/sonarr:2' + } } + } } + diff --git a/start.sh b/start.sh old mode 100644 new mode 100755 index d3cad1f..4d54391 --- a/start.sh +++ b/start.sh @@ -2,5 +2,7 @@ ## ## Script to start the sonarr server ## +addgroup -g $GID $USER +adduser -D -u $UID -G $USER -H $USER until [ -f "/config/nzbdrone.db" ]; do sleep 1; done /usr/bin/mono --debug /NzbDrone/NzbDrone.exe --nobrowser --data=/config