From 50aca7187f2a43f7188829c9ca9a940fc50da5a2 Mon Sep 17 00:00:00 2001 From: Jonathan Ervine Date: Mon, 16 Mar 2020 20:10:26 +0800 Subject: [PATCH 01/11] new file: Dockerfile new file: Jenkinsfile Initial commit --- Dockerfile | 23 +++++++++++++++++++++++ Jenkinsfile | 25 +++++++++++++++++++++++++ 2 files changed, 48 insertions(+) create mode 100644 Dockerfile create mode 100644 Jenkinsfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..b6d81de --- /dev/null +++ b/Dockerfile @@ -0,0 +1,23 @@ +# 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' \ + VERSION='develop' \ + SONARR_USER='mediaservice' \ + SONARR_GROUP='mediaservice' \ + SONARR_UID='1003' \ + SONARR_GID='1003' + +RUN echo http://dl-4.alpinelinux.org/alpine/edge/testing >> /etc/apk/repositories && \ + apk -U update && \ + apk -U upgrade && \ + apk -U add nfs-utils + rm -rf /tmp/src && \ + rm -rf /var/cache/apk/* + +CMD [ "/bin/sh" ] diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 0000000..b2b45b3 --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,25 @@ +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-sonarr-sidecar", 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/sonarr-sidecar" + + stage "publish" + app.push("${env.BUILD_NUMBER}") + app.push("3.11.3") + app.push("latest") + + } + } + catch (err) { + currentBuild.result = 'FAILURE' + } + } +} -- 2.45.2 From 40745cd8a33041a8e42febe14d698ae16737f08a Mon Sep 17 00:00:00 2001 From: Jonathan Ervine Date: Mon, 16 Mar 2020 20:16:45 +0800 Subject: [PATCH 02/11] modified: Jenkinsfile Fixed typo --- Jenkinsfile | 1 - 1 file changed, 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index b2b45b3..f3b649b 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -17,7 +17,6 @@ node("docker-node") { app.push("latest") } - } catch (err) { currentBuild.result = 'FAILURE' } -- 2.45.2 From 6a441ce922d46ca7c182fa14dd028e0b5b09aa87 Mon Sep 17 00:00:00 2001 From: Jonathan Ervine Date: Mon, 16 Mar 2020 20:18:04 +0800 Subject: [PATCH 03/11] modified: Dockerfile Added missing '\' --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index b6d81de..0891bbf 100644 --- a/Dockerfile +++ b/Dockerfile @@ -16,7 +16,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 add nfs-utils + apk -U add nfs-utils \ rm -rf /tmp/src && \ rm -rf /var/cache/apk/* -- 2.45.2 From 1db9edf1f1598bc8f44f7c4ac4b182790bbcf532 Mon Sep 17 00:00:00 2001 From: Jonathan Ervine Date: Mon, 16 Mar 2020 20:27:48 +0800 Subject: [PATCH 04/11] modified: Dockerfile new file: start.sh Added script file to start the container --- Dockerfile | 5 ++++- start.sh | 6 ++++++ 2 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 start.sh diff --git a/Dockerfile b/Dockerfile index 0891bbf..8bd1b3d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -20,4 +20,7 @@ RUN echo http://dl-4.alpinelinux.org/alpine/edge/testing >> /etc/apk/repositorie rm -rf /tmp/src && \ rm -rf /var/cache/apk/* -CMD [ "/bin/sh" ] +COPY start.sh /usr/local/bin/start.sh +RUN chmod 755 /usr/local/bin/start.sh + +CMD [ "/usr/local/bin/start.sh" ] diff --git a/start.sh b/start.sh new file mode 100644 index 0000000..8e91516 --- /dev/null +++ b/start.sh @@ -0,0 +1,6 @@ +#!/bin/sh +## +## Script to automate the copy of Sonarr databases +## +echo -e 'Starting the sidecar container to periodically backup the sonarr databases' +sleep 3600 -- 2.45.2 From b45cc7989167183d0f23fa7b6db22c9f6358738c Mon Sep 17 00:00:00 2001 From: Jonathan Ervine Date: Mon, 16 Mar 2020 20:53:12 +0800 Subject: [PATCH 05/11] modified: Dockerfile Added e2fsprogs --- Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 8bd1b3d..fd390ae 100644 --- a/Dockerfile +++ b/Dockerfile @@ -16,8 +16,8 @@ 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 add nfs-utils \ - rm -rf /tmp/src && \ + apk -U add nfs-utils e2fsprogs && \ +# rm -rf /tmp/src && \ rm -rf /var/cache/apk/* COPY start.sh /usr/local/bin/start.sh -- 2.45.2 From fa1994033566bb28e9d8da7511be4c25b557ad8c Mon Sep 17 00:00:00 2001 From: Jonathan Ervine Date: Mon, 16 Mar 2020 21:33:06 +0800 Subject: [PATCH 06/11] modified: Dockerfile modified: start.sh Added loop to start.sh script --- Dockerfile | 4 ++-- start.sh | 18 +++++++++++++++++- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index fd390ae..05da303 100644 --- a/Dockerfile +++ b/Dockerfile @@ -16,8 +16,8 @@ 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 add nfs-utils e2fsprogs && \ -# rm -rf /tmp/src && \ + apk -U add nfs-utils e2fsprogs util-linux&& \ + rm -rf /tmp/src && \ rm -rf /var/cache/apk/* COPY start.sh /usr/local/bin/start.sh diff --git a/start.sh b/start.sh index 8e91516..77fe5a4 100644 --- a/start.sh +++ b/start.sh @@ -3,4 +3,20 @@ ## Script to automate the copy of Sonarr databases ## echo -e 'Starting the sidecar container to periodically backup the sonarr databases' -sleep 3600 +echo -e 'Create the ramdisk file' +dd if=/dev/zero of=/ramdisk/image.ext4 count=0 bs=1 seek=400M +echo -e 'Create filesystem on ramdisk file' +mkfs.ext4 /ramdisk/image.ext4 +echo -e 'Mount the ramdisk file to /mnt/sonarr-ramdisk-mount' +mount /ramdisk/image.ext4 /mnt/sonarr-ramdisk-mount +echo -e 'Copy the config from the remote share to the ramdisk' +cp -fvp /config/*.* /mnt/sonarr-ramdisk-mount +echo -e 'Set up the filesystem freeze, copy, unfreeze loop' +while true; do + sleep 890 + sync /mnt/sonarr-ramdisk-mount/*.* + fsfreeze --freeze /mnt/sonarr-ramdisk-mount + sleep 10 + cp -fvp /mnt/sonarr-ramdisk-mount/*.* /config/ + fsfreeze --unfreeze /mnt/sonarr-ramdisk-mount +done -- 2.45.2 From 3f8078758c273be47c9315111ceb4a6757bbd2c2 Mon Sep 17 00:00:00 2001 From: Jonny Ervine Date: Mon, 16 Mar 2020 14:53:37 +0000 Subject: [PATCH 07/11] modified: start.sh Trying to get the /config to mount the subPaths --- start.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/start.sh b/start.sh index 77fe5a4..adf2136 100644 --- a/start.sh +++ b/start.sh @@ -10,13 +10,13 @@ mkfs.ext4 /ramdisk/image.ext4 echo -e 'Mount the ramdisk file to /mnt/sonarr-ramdisk-mount' mount /ramdisk/image.ext4 /mnt/sonarr-ramdisk-mount echo -e 'Copy the config from the remote share to the ramdisk' -cp -fvp /config/*.* /mnt/sonarr-ramdisk-mount +cp -fvp /sonarr-config/*.* /mnt/sonarr-ramdisk-mount echo -e 'Set up the filesystem freeze, copy, unfreeze loop' while true; do sleep 890 sync /mnt/sonarr-ramdisk-mount/*.* fsfreeze --freeze /mnt/sonarr-ramdisk-mount sleep 10 - cp -fvp /mnt/sonarr-ramdisk-mount/*.* /config/ + cp -fvp /mnt/sonarr-ramdisk-mount/*.* /sonarr-config/ fsfreeze --unfreeze /mnt/sonarr-ramdisk-mount done -- 2.45.2 From 2d0443dd180bf49ef3b420683c419ec7cc84e19c Mon Sep 17 00:00:00 2001 From: Jonathan Ervine Date: Tue, 17 Mar 2020 17:07:52 +0800 Subject: [PATCH 08/11] modified: start.sh Added date/tinestamp to automated backup job --- start.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/start.sh b/start.sh index adf2136..f0ad4d5 100644 --- a/start.sh +++ b/start.sh @@ -14,6 +14,7 @@ cp -fvp /sonarr-config/*.* /mnt/sonarr-ramdisk-mount echo -e 'Set up the filesystem freeze, copy, unfreeze loop' while true; do sleep 890 + date sync /mnt/sonarr-ramdisk-mount/*.* fsfreeze --freeze /mnt/sonarr-ramdisk-mount sleep 10 -- 2.45.2 From 8834c79bcfa648ef813b95878f6214e02fd1fc53 Mon Sep 17 00:00:00 2001 From: Jonathan Ervine Date: Thu, 19 Mar 2020 16:28:17 +0800 Subject: [PATCH 09/11] modified: start.sh Changed ownership of ramdisk when mounted --- start.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/start.sh b/start.sh index f0ad4d5..596dc55 100644 --- a/start.sh +++ b/start.sh @@ -9,6 +9,7 @@ echo -e 'Create filesystem on ramdisk file' mkfs.ext4 /ramdisk/image.ext4 echo -e 'Mount the ramdisk file to /mnt/sonarr-ramdisk-mount' mount /ramdisk/image.ext4 /mnt/sonarr-ramdisk-mount +chown 1003:1003 /mnt/sonarr-ramdisk-mount echo -e 'Copy the config from the remote share to the ramdisk' cp -fvp /sonarr-config/*.* /mnt/sonarr-ramdisk-mount echo -e 'Set up the filesystem freeze, copy, unfreeze loop' -- 2.45.2 From 679792442f01e7ce0d9461717a31cf9aa6e7bed6 Mon Sep 17 00:00:00 2001 From: Jonathan Ervine Date: Thu, 19 Mar 2020 17:04:53 +0800 Subject: [PATCH 10/11] modified: start.sh Switched to local (emptyDir) rather than ramdisk --- start.sh | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/start.sh b/start.sh index 596dc55..02fb99a 100644 --- a/start.sh +++ b/start.sh @@ -3,22 +3,16 @@ ## Script to automate the copy of Sonarr databases ## echo -e 'Starting the sidecar container to periodically backup the sonarr databases' -echo -e 'Create the ramdisk file' -dd if=/dev/zero of=/ramdisk/image.ext4 count=0 bs=1 seek=400M -echo -e 'Create filesystem on ramdisk file' -mkfs.ext4 /ramdisk/image.ext4 -echo -e 'Mount the ramdisk file to /mnt/sonarr-ramdisk-mount' -mount /ramdisk/image.ext4 /mnt/sonarr-ramdisk-mount -chown 1003:1003 /mnt/sonarr-ramdisk-mount +chown 1003:1003 /mnt/sonarr-local-config echo -e 'Copy the config from the remote share to the ramdisk' -cp -fvp /sonarr-config/*.* /mnt/sonarr-ramdisk-mount +cp -fvp /sonarr-config/*.* /mnt/sonarr-local-config echo -e 'Set up the filesystem freeze, copy, unfreeze loop' while true; do sleep 890 date - sync /mnt/sonarr-ramdisk-mount/*.* - fsfreeze --freeze /mnt/sonarr-ramdisk-mount + sync /mnt/sonarr-local/config/*.* + fsfreeze --freeze /mnt/sonarr-local-config sleep 10 - cp -fvp /mnt/sonarr-ramdisk-mount/*.* /sonarr-config/ - fsfreeze --unfreeze /mnt/sonarr-ramdisk-mount + cp -fvp /mnt/sonarr-local-config/*.* /sonarr-config/ + fsfreeze --unfreeze /mnt/sonarr-local-config done -- 2.45.2 From f000a197fb44fd23fdac8dc87643b1276bce4d43 Mon Sep 17 00:00:00 2001 From: Jonathan Ervine Date: Fri, 5 Jun 2020 15:25:35 +0800 Subject: [PATCH 11/11] modified: Jenkinsfile modified: start.sh --- Jenkinsfile | 4 ++-- start.sh | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index f3b649b..3ccbe06 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-sonarr-sidecar", credentialsId: 'jenkins-to-git' + git branch: "3.11.6", url: "ssh://git@git.ervine.org/jonny/x86_64-alpine-sonarr-sidecar", credentialsId: 'jenkins-to-git' sh "git rev-parse HEAD > .git/commit-id" def commit_id = readFile('.git/commit-id').trim() @@ -13,7 +13,7 @@ node("docker-node") { stage "publish" app.push("${env.BUILD_NUMBER}") - app.push("3.11.3") + app.push("3.11.6") app.push("latest") } diff --git a/start.sh b/start.sh index 02fb99a..de2bdda 100644 --- a/start.sh +++ b/start.sh @@ -10,7 +10,7 @@ echo -e 'Set up the filesystem freeze, copy, unfreeze loop' while true; do sleep 890 date - sync /mnt/sonarr-local/config/*.* + sync /mnt/sonarr-local-config/*.* fsfreeze --freeze /mnt/sonarr-local-config sleep 10 cp -fvp /mnt/sonarr-local-config/*.* /sonarr-config/ -- 2.45.2