diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..05da303 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,26 @@ +# 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 e2fsprogs util-linux&& \ + rm -rf /tmp/src && \ + rm -rf /var/cache/apk/* + +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/Jenkinsfile b/Jenkinsfile new file mode 100644 index 0000000..3ccbe06 --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,24 @@ +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-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.6") + app.push("latest") + + } + catch (err) { + currentBuild.result = 'FAILURE' + } + } +} diff --git a/start.sh b/start.sh new file mode 100644 index 0000000..de2bdda --- /dev/null +++ b/start.sh @@ -0,0 +1,18 @@ +#!/bin/sh +## +## Script to automate the copy of Sonarr databases +## +echo -e 'Starting the sidecar container to periodically backup the sonarr databases' +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-local-config +echo -e 'Set up the filesystem freeze, copy, unfreeze loop' +while true; do + sleep 890 + date + sync /mnt/sonarr-local-config/*.* + fsfreeze --freeze /mnt/sonarr-local-config + sleep 10 + cp -fvp /mnt/sonarr-local-config/*.* /sonarr-config/ + fsfreeze --unfreeze /mnt/sonarr-local-config +done