From d0762a88956e8c7768b9638f5519885c5e3b6193 Mon Sep 17 00:00:00 2001 From: Jonathan Ervine Date: Tue, 21 Jul 2020 20:48:04 +0800 Subject: [PATCH] Switched to node builder --- Dockerfile | 19 ++++-------------- Jenkinsfile | 56 ++++++++++++++++++++++++++++++----------------------- start.sh | 5 ++++- 3 files changed, 40 insertions(+), 40 deletions(-) mode change 100644 => 100755 start.sh diff --git a/Dockerfile b/Dockerfile index dfc9e42..2f1e243 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ # Base on latest (edge) alpine image -FROM harbor.ervine.dev/library/x86_64/alpine/alpine-3.10 +FROM harbor.ervine.dev/library/x86_64/alpine/alpine:3.10.5 MAINTAINER “Jonathan Ervine” @@ -9,30 +9,19 @@ ENV LANG='en_US.UTF-8' \ LANGUAGE='en_US.UTF-8' \ BUILD_DATE='06-04-2020' \ TERM='xterm' \ - HTPC_USER='mediaservice' \ - HTPC_GROUP='mediaservice' \ - HTPC_UID='1003' \ - HTPC_GID='1003' RUN echo http://dl-4.alpinelinux.org/alpine/edge/testing >> /etc/apk/repositories && \ apk update && \ - apk -U upgrade && \ - apk -U add \ - python3 git + apk -U upgrade --ignore alpine-baselayout && \ + apk -U add python3 git ADD UTC /etc/localtime RUN git clone https://github.com/barbequesauce/watcher3 && \ - rm -rf /var/cache/apk/* && \ - addgroup -g $HTPC_GID $HTPC_GROUP && \ - adduser -D -u $HTPC_UID -G $HTPC_GROUP -H $HTPC_USER && \ - chown -R $HTPC_USER:$HTPC_GROUP /watcher3 + rm -rf /var/cache/apk/* ADD start.sh /usr/local/bin/start.sh -RUN chmod 755 /usr/local/bin/start.sh EXPOSE 9090 -USER $HTPC_USER - CMD [ "/usr/local/bin/start.sh" ] diff --git a/Jenkinsfile b/Jenkinsfile index ff9ccd9..8161b09 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,27 +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-watcher", 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-3.10/watcher" - - stage "publish" - app.push("${env.BUILD_NUMBER}") - app.push("latest") - app.push("3.10.5") +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 +""" + ) { - stage('Deploy on K8s'){ - sh "/usr/local/bin/kubectl -n media delete po watcher-0" - } - } - catch (err) { - currentBuild.result = 'FAILURE' - } + node(POD_LABEL) { + stage('Build with Kaniko') { + git url: 'ssh://git@git.ervine.org/jonny/x86_64-alpine-watcher.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/watcher:3.10.5 --destination=harbor.ervine.dev/library/x86_64/alpine/watcher:3.10' + } } + } } + diff --git a/start.sh b/start.sh old mode 100644 new mode 100755 index fb6c577..a1b8be3 --- a/start.sh +++ b/start.sh @@ -1,6 +1,9 @@ #!/bin/sh ## -## Script to start the sonarr server +## Script to start the Watcher3 server ## +addgroup -g $GID $USER +adduser -D -u $UID -G $USER -H $USER +chown -R $UID:$GID /watcher3 /config until [ -f "/config/watcher.sqlite" ]; do sleep 10; done /usr/bin/python3 /watcher3/watcher.py --userdata=/config/