From 5414f927323aef5654a176367b4cec6b10e866d3 Mon Sep 17 00:00:00 2001 From: Jonny Ervine Date: Wed, 19 Feb 2020 06:24:48 +0000 Subject: [PATCH 1/5] new file: Dockerfile new file: Jenkinsfile Initial commit --- Dockerfile | 38 ++++++++++++++++++++++++++++++++++++++ Jenkinsfile | 17 +++++++++++++++++ 2 files changed, 55 insertions(+) create mode 100644 Dockerfile create mode 100644 Jenkinsfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..a2f781c --- /dev/null +++ b/Dockerfile @@ -0,0 +1,38 @@ +# Base on latest (edge) alpine image +FROM harbor.ervine.dev/library/x86_64/alpine/alpine-3.11 + +MAINTAINER “Jonathan Ervine” + +# Install updates +ENV LANG='en_US.UTF-8' \ + LANGUAGE='en_US.UTF-8' \ + TERM='xterm' \ + TORRENT_USER='mediaservice' \ + TORRENT_GROUP='mediaservice' \ + TORRENT_UID='1003' \ + TORRENT_GID='1003' + +RUN echo http://dl-4.alpinelinux.org/alpine/edge/testing >> /etc/apk/repositories && \ + apk update && \ + apk -U upgrade && \ + apk -U add \ + transmission-daemon && \ + wget https://github.com/Secretmapper/combustion/archive/release.zip && \ + unzip release.zip && \ + mv combustion-release/* /usr/share/transmission/web/ && \ + rmdir combustion-release && \ + rm release.zip + +#ADD UTC /etc/localtime + +RUN rm -rf /var/cache/apk/* && \ + addgroup -g $TORRENT_GID $TORRENT_GROUP && \ + adduser -D -u $TORRENT_UID -G $TORRENT_GROUP -H $TORRENT_USER + +EXPOSE 9091 + +VOLUME /config + +USER $TORRENT_USER + +CMD [ "/usr/bin/transmission-daemon", "-f", "-g", "/config/" ] diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 0000000..c3112f8 --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,17 @@ +node("docker-node") { + docker.withRegistry('https://harbor.ervine.dev', 'jenkins-to-harbor') { + + git branch: "3.11.3", url: "ssh://git@git.ervine.org:2222/jonny/x86_64-alpine-transmission", credentialsId: 'jenkins-to-git' + + sh "git rev-parse HEAD > .git/commit-id" + def commit_id = readFile('.git/commit-id').trim() + println commit_id + + stage "build" + def app = docker.build "library/x86_64/alpine/transmission" + + stage "publish" + app.push("${env.BUILD_NUMBER}") + app.push("latest") + } +} -- 2.45.2 From c12a5472eaeeb52d8c000fb5a316d1027d47a218 Mon Sep 17 00:00:00 2001 From: Jonny Ervine Date: Mon, 2 Mar 2020 03:01:56 +0000 Subject: [PATCH 2/5] modified: Jenkinsfile Added code to auto-deploy to k8s --- Jenkinsfile | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index c3112f8..c058410 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -6,12 +6,22 @@ node("docker-node") { 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/transmission" - stage "build" - def app = docker.build "library/x86_64/alpine/transmission" - - stage "publish" - app.push("${env.BUILD_NUMBER}") - app.push("latest") + stage "publish" + app.push("${env.BUILD_NUMBER}") + app.push("latest") + + stage('Deploy on K8s'){ + sh "/usr/local/bin/kubectl -n media delete po transmission-0" + } + } + catch (err) { + currentBuild.result = 'FAILURE' + } + } } -- 2.45.2 From 15ae7e32f650a0b4b76d8623d4437ee5f48271b7 Mon Sep 17 00:00:00 2001 From: Jonathan Ervine Date: Fri, 5 Jun 2020 15:27:24 +0800 Subject: [PATCH 3/5] modified: Jenkinsfile --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index c058410..5816a86 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,7 +1,7 @@ node("docker-node") { docker.withRegistry('https://harbor.ervine.dev', 'jenkins-to-harbor') { - git branch: "3.11.3", url: "ssh://git@git.ervine.org:2222/jonny/x86_64-alpine-transmission", credentialsId: 'jenkins-to-git' + git branch: "3.11.6", url: "ssh://git@git.ervine.org/jonny/x86_64-alpine-transmission", credentialsId: 'jenkins-to-git' sh "git rev-parse HEAD > .git/commit-id" def commit_id = readFile('.git/commit-id').trim() -- 2.45.2 From 4e3c0f60c56d4bda5eded8e08c3cfdbd838f2985 Mon Sep 17 00:00:00 2001 From: Jonathan Ervine Date: Mon, 20 Jul 2020 15:29:21 +0800 Subject: [PATCH 4/5] Using node builder --- Dockerfile | 4 ++-- Jenkinsfile | 56 ++++++++++++++++++++++++++++++----------------------- 2 files changed, 34 insertions(+), 26 deletions(-) diff --git a/Dockerfile b/Dockerfile index a2f781c..c0c4bf6 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.11 +FROM harbor.ervine.dev/library/x86_64/alpine/alpine:3.12 MAINTAINER “Jonathan Ervine” @@ -14,7 +14,7 @@ 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 upgrade --ignore alpine-baselayout && \ apk -U add \ transmission-daemon && \ wget https://github.com/Secretmapper/combustion/archive/release.zip && \ diff --git a/Jenkinsfile b/Jenkinsfile index 5816a86..def7e40 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,27 +1,35 @@ -node("docker-node") { - docker.withRegistry('https://harbor.ervine.dev', 'jenkins-to-harbor') { - - git branch: "3.11.6", url: "ssh://git@git.ervine.org/jonny/x86_64-alpine-transmission", 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/transmission" - - stage "publish" - app.push("${env.BUILD_NUMBER}") - app.push("latest") - - stage('Deploy on K8s'){ - sh "/usr/local/bin/kubectl -n media delete po transmission-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-transmission.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/transmission:latest --destination=harbor.ervine.dev/library/x86_64/alpine/transmission:3.12.0 --destination=harbor.ervine.dev/library/x86_64/alpine/transmission:3.12' + } } + } } + -- 2.45.2 From e43dde5973a784eea9ae340a07910db565938185 Mon Sep 17 00:00:00 2001 From: Jonathan Ervine Date: Mon, 20 Jul 2020 15:35:18 +0800 Subject: [PATCH 5/5] Added start script --- Dockerfile | 9 +++------ start.sh | 7 +++++++ 2 files changed, 10 insertions(+), 6 deletions(-) create mode 100755 start.sh diff --git a/Dockerfile b/Dockerfile index c0c4bf6..bcdfbae 100644 --- a/Dockerfile +++ b/Dockerfile @@ -7,10 +7,6 @@ MAINTAINER “Jonathan Ervine” ENV LANG='en_US.UTF-8' \ LANGUAGE='en_US.UTF-8' \ TERM='xterm' \ - TORRENT_USER='mediaservice' \ - TORRENT_GROUP='mediaservice' \ - TORRENT_UID='1003' \ - TORRENT_GID='1003' RUN echo http://dl-4.alpinelinux.org/alpine/edge/testing >> /etc/apk/repositories && \ apk update && \ @@ -23,6 +19,8 @@ RUN echo http://dl-4.alpinelinux.org/alpine/edge/testing >> /etc/apk/repositorie rmdir combustion-release && \ rm release.zip +COPY start.sh /usr/loca/bin/start.sh + #ADD UTC /etc/localtime RUN rm -rf /var/cache/apk/* && \ @@ -33,6 +31,5 @@ EXPOSE 9091 VOLUME /config -USER $TORRENT_USER -CMD [ "/usr/bin/transmission-daemon", "-f", "-g", "/config/" ] +CMD [ "/usr/local/bin/start.sh" ] diff --git a/start.sh b/start.sh new file mode 100755 index 0000000..fb6d982 --- /dev/null +++ b/start.sh @@ -0,0 +1,7 @@ +#!/bin/sh +# +## Script to kick off Transmission +# +addgroup -g $GID $USER +adduser -D -u $UID -G $USER -H $USER +su - $USER -c "/usr/bin/transmission-daemon -f -g /config/" -- 2.45.2