From 311f2ff3bd2c082de6eb62cb42a24be35ad2143a Mon Sep 17 00:00:00 2001 From: Jonny Ervine Date: Tue, 18 Feb 2020 09:27:43 +0000 Subject: [PATCH 1/9] new file: Dockerfile new file: Jenkinsfile Initial commit --- Dockerfile | 40 ++++++++++++++++++++++++++++++++++++++++ Jenkinsfile | 17 +++++++++++++++++ 2 files changed, 57 insertions(+) create mode 100644 Dockerfile create mode 100644 Jenkinsfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..4dd2c89 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,40 @@ +# Base on latest (edge) alpine image +FROM harbor.ervine.dev/library/x86_64/alpine/alpine-3.11 + +LABEL maintainer “Jonathan Ervine” architecture="x86_64" date="17022020" + +# Install updates +ENV LANG='en_US.UTF-8' \ + LANGUAGE='en_US.UTF-8' \ + TERM='xterm' \ + VERSION='master' \ + CP_USER='mediaservice' \ + CP_GROUP='mediaservice' \ + CP_UID='1003' \ + CP_GID='1003' + +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 \ + py-openssl + +RUN wget https://github.com/CouchPotato/CouchPotatoServer/archive/$VERSION.tar.gz -O couchpotato.tar.gz && \ + tar zxvf couchpotato.tar.gz && \ + mv CouchPotatoServer-$VERSION couchpotato && \ + rm -rf couchpotato.tar.gz && \ + apk del make gcc g++ && \ + rm -rf /tmp/src && \ + rm -rf /var/cache/apk/* && \ + addgroup -g $CP_GID $CP_GROUP && \ + adduser -D -u $CP_UID -G $CP_GROUP -H $CP_USER && \ + chown -R $CP_USER:$CP_GROUP /couchpotato + +EXPOSE 5050 + +USER $CP_USER + +CMD [ "/usr/bin/python", "/couchpotato/CouchPotato.py", "--console_log", "--data_dir=/config" ] diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 0000000..c69c0f8 --- /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-cp", 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/couchpotato" + + stage "publish" + app.push("${env.BUILD_NUMBER}") + app.push("latest") + } +} From 27621fba185335fb4050c24ef2a373b0e7993347 Mon Sep 17 00:00:00 2001 From: Jonny Ervine Date: Mon, 2 Mar 2020 09:25:11 +0000 Subject: [PATCH 2/9] modified: Jenkinsfile Add code to automatically deploy to k8s --- Jenkinsfile | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index c69c0f8..e226ba7 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -6,12 +6,21 @@ 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/couchpotato" - stage "build" - def app = docker.build "library/x86_64/alpine/couchpotato" - - 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 cp-0 && kubectl -n media delete po cp-kids-0" + } + } + catch (err) { + currentBuild.result = 'FAILURE' + } } } From 53c499792125ee471e10470ea149ccbe1cb9d0ed Mon Sep 17 00:00:00 2001 From: Jonathan Ervine Date: Wed, 13 May 2020 21:07:46 +0800 Subject: [PATCH 3/9] modified: Dockerfile Updating to using python3 --- Dockerfile | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Dockerfile b/Dockerfile index 4dd2c89..07b33d8 100644 --- a/Dockerfile +++ b/Dockerfile @@ -17,10 +17,10 @@ RUN echo http://dl-4.alpinelinux.org/alpine/edge/testing >> /etc/apk/repositorie apk update && \ apk -U upgrade && \ apk -U add \ - python \ - py-lxml \ - py-simplejson \ - py-openssl + python3 \ + py3-lxml \ + py3-simplejson \ + py3-openssl RUN wget https://github.com/CouchPotato/CouchPotatoServer/archive/$VERSION.tar.gz -O couchpotato.tar.gz && \ tar zxvf couchpotato.tar.gz && \ @@ -37,4 +37,4 @@ EXPOSE 5050 USER $CP_USER -CMD [ "/usr/bin/python", "/couchpotato/CouchPotato.py", "--console_log", "--data_dir=/config" ] +CMD [ "/usr/bin/python3", "/couchpotato/CouchPotato.py", "--console_log", "--data_dir=/config" ] From f4b5ac434d97f6eb41e7702c963ae51ce96b1c52 Mon Sep 17 00:00:00 2001 From: Jonathan Ervine Date: Wed, 13 May 2020 21:32:41 +0800 Subject: [PATCH 4/9] modified: Dockerfile Use python2 --- Dockerfile | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Dockerfile b/Dockerfile index 07b33d8..6521e1d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -17,10 +17,10 @@ RUN echo http://dl-4.alpinelinux.org/alpine/edge/testing >> /etc/apk/repositorie apk update && \ apk -U upgrade && \ apk -U add \ - python3 \ - py3-lxml \ - py3-simplejson \ - py3-openssl + python \ + py-lxml \ + py-simplejson \ + py-openssl RUN wget https://github.com/CouchPotato/CouchPotatoServer/archive/$VERSION.tar.gz -O couchpotato.tar.gz && \ tar zxvf couchpotato.tar.gz && \ @@ -37,4 +37,4 @@ EXPOSE 5050 USER $CP_USER -CMD [ "/usr/bin/python3", "/couchpotato/CouchPotato.py", "--console_log", "--data_dir=/config" ] +CMD [ "/usr/bin/python2", "/couchpotato/CouchPotato.py", "--console_log", "--data_dir=/config" ] From ca01e93e9c4f1c7ec8ed3f542387003403c4d35f Mon Sep 17 00:00:00 2001 From: Jonathan Ervine Date: Thu, 28 May 2020 00:00:55 +0800 Subject: [PATCH 5/9] modified: Dockerfile new file: start.sh Added start script --- Dockerfile | 16 +++++----------- start.sh | 9 +++++++++ 2 files changed, 14 insertions(+), 11 deletions(-) create mode 100755 start.sh diff --git a/Dockerfile b/Dockerfile index 6521e1d..caf654f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -7,11 +7,7 @@ LABEL maintainer “Jonathan Ervine” architecture="x86_64" ENV LANG='en_US.UTF-8' \ LANGUAGE='en_US.UTF-8' \ TERM='xterm' \ - VERSION='master' \ - CP_USER='mediaservice' \ - CP_GROUP='mediaservice' \ - CP_UID='1003' \ - CP_GID='1003' + VERSION='master' RUN echo http://dl-4.alpinelinux.org/alpine/edge/testing >> /etc/apk/repositories && \ apk update && \ @@ -28,13 +24,11 @@ RUN wget https://github.com/CouchPotato/CouchPotatoServer/archive/$VERSION.tar.g rm -rf couchpotato.tar.gz && \ apk del make gcc g++ && \ rm -rf /tmp/src && \ - rm -rf /var/cache/apk/* && \ - addgroup -g $CP_GID $CP_GROUP && \ - adduser -D -u $CP_UID -G $CP_GROUP -H $CP_USER && \ - chown -R $CP_USER:$CP_GROUP /couchpotato + rm -rf /var/cache/apk/* + +COPY start.sh /usr/local/bin/start.sh EXPOSE 5050 -USER $CP_USER -CMD [ "/usr/bin/python2", "/couchpotato/CouchPotato.py", "--console_log", "--data_dir=/config" ] +CMD [ "/usr/local/bin/start.sh" ] diff --git a/start.sh b/start.sh new file mode 100755 index 0000000..6431e71 --- /dev/null +++ b/start.sh @@ -0,0 +1,9 @@ +#!/bin/sh +# +## Script to kick off Couchpotato Movies media orgnaiser +# +addgroup -g $GID coucpotato +adduser -D -u $UID -G couchpotato -H couchpotato +chown -R $UID:$GID /couchpotato +su - $UID +/usr/bin/python2 /couchpotato/CouchPotato.py --console_log --data_dir=/config" ] From 23ec3dfcf4002319cfde49b5fa4e08cfe384c01b Mon Sep 17 00:00:00 2001 From: Jonathan Ervine Date: Thu, 28 May 2020 00:15:02 +0800 Subject: [PATCH 6/9] modified: start.sh Fixed typo --- start.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/start.sh b/start.sh index 6431e71..9bc1371 100755 --- a/start.sh +++ b/start.sh @@ -6,4 +6,4 @@ addgroup -g $GID coucpotato adduser -D -u $UID -G couchpotato -H couchpotato chown -R $UID:$GID /couchpotato su - $UID -/usr/bin/python2 /couchpotato/CouchPotato.py --console_log --data_dir=/config" ] +/usr/bin/python2 /couchpotato/CouchPotato.py --console_log --data_dir=/config From 49939239c283778ba470fd1fd38554f03f15fe51 Mon Sep 17 00:00:00 2001 From: Jonathan Ervine Date: Thu, 28 May 2020 16:26:42 +0800 Subject: [PATCH 7/9] modified: start.sh Updated startup script --- start.sh | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/start.sh b/start.sh index 9bc1371..8a4ee8d 100755 --- a/start.sh +++ b/start.sh @@ -2,8 +2,7 @@ # ## Script to kick off Couchpotato Movies media orgnaiser # -addgroup -g $GID coucpotato -adduser -D -u $UID -G couchpotato -H couchpotato -chown -R $UID:$GID /couchpotato -su - $UID -/usr/bin/python2 /couchpotato/CouchPotato.py --console_log --data_dir=/config +addgroup -g $GID $USER +adduser -D -u $UID -G $USER -H $USER +chown -R $UID:$GID /couchpotato /config +su - $USER -c "/usr/bin/python2 /couchpotato/CouchPotato.py --console_log --data_dir=/config" From 037270af172c4e61e288aa2a7f53a56fafebd808 Mon Sep 17 00:00:00 2001 From: Jonathan Ervine Date: Thu, 28 May 2020 16:44:43 +0800 Subject: [PATCH 8/9] modified: Dockerfile Added openssl to docker image --- Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Dockerfile b/Dockerfile index caf654f..0e72354 100644 --- a/Dockerfile +++ b/Dockerfile @@ -16,6 +16,7 @@ RUN echo http://dl-4.alpinelinux.org/alpine/edge/testing >> /etc/apk/repositorie python \ py-lxml \ py-simplejson \ + openssl \ py-openssl RUN wget https://github.com/CouchPotato/CouchPotatoServer/archive/$VERSION.tar.gz -O couchpotato.tar.gz && \ From 8fe1ba70d5e807ec2801cf4dcc2c9f4bb3a24cad Mon Sep 17 00:00:00 2001 From: Jonathan Ervine Date: Thu, 4 Jun 2020 23:32:42 +0800 Subject: [PATCH 9/9] modified: Jenkinsfile --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index e226ba7..1775b23 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-cp", credentialsId: 'jenkins-to-git' + git branch: "3.11.6", 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()