From 3dcc4b486d028d2183ef4d07bf02909ae3182625 Mon Sep 17 00:00:00 2001 From: Jonny Ervine Date: Tue, 18 Feb 2020 09:50:10 +0000 Subject: [PATCH 1/3] new file: Dockerfile new file: Jenkinsfile new file: files/etc/crontabs/root new file: files/etc/logrotate.d/get_iplayer new file: files/etc/periodic/daily/get_iplayer_update new file: files/etc/periodic/hourly/get_iplayer_pvr new file: files/start Initial commit --- Dockerfile | 26 +++++++++++++++++++++ Jenkinsfile | 17 ++++++++++++++ files/etc/crontabs/root | 5 ++++ files/etc/logrotate.d/get_iplayer | 8 +++++++ files/etc/periodic/daily/get_iplayer_update | 12 ++++++++++ files/etc/periodic/hourly/get_iplayer_pvr | 6 +++++ files/start | 18 ++++++++++++++ 7 files changed, 92 insertions(+) create mode 100644 Dockerfile create mode 100644 Jenkinsfile create mode 100644 files/etc/crontabs/root create mode 100644 files/etc/logrotate.d/get_iplayer create mode 100644 files/etc/periodic/daily/get_iplayer_update create mode 100644 files/etc/periodic/hourly/get_iplayer_pvr create mode 100755 files/start diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..59ef116 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,26 @@ +FROM harbor.ervine.dev/library/x86_64/alpine/alpine-3.11 +MAINTAINER “Jonathan Ervine” + +ENV GETIPLAYER_OUTPUT=/config GETIPLAYER_PROFILE=/config/.get_iplayer PUID=1000 PGID=100 PORT=1935 +EXPOSE 1935 +VOLUME /config + +RUN apk --update --no-cache add ffmpeg perl-cgi perl-mojolicious perl-lwp-protocol-https perl-xml-libxml jq logrotate su-exec tini + +RUN wget -qnd "https://bitbucket.org/shield007/atomicparsley/raw/68337c0c05ec4ba2ad47012303121aaede25e6df/downloads/build_linux_x86_64/AtomicParsley" && \ + install -m 755 -t /usr/local/bin ./AtomicParsley && \ + rm ./AtomicParsley + +RUN wget -qO - "https://api.github.com/repos/get-iplayer/get_iplayer/releases/latest" > /tmp/latest.json && \ + echo get_iplayer release `jq -r .name /tmp/latest.json` && \ + wget -qO - "`jq -r .tarball_url /tmp/latest.json`" | tar -zxf - && \ + cd get-iplayer* && \ + install -m 755 -t /usr/local/bin ./get_iplayer ./get_iplayer.cgi && \ + cd / && \ + rm -rf get-iplayer* && \ + rm /tmp/latest.json + +COPY files/ / + +ENTRYPOINT ["/sbin/tini", "--"] +CMD /start diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 0000000..f9da245 --- /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-get_iplayer", 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/get_iplayer" + + stage "publish" + app.push("${env.BUILD_NUMBER}") + app.push("latest") + } +} diff --git a/files/etc/crontabs/root b/files/etc/crontabs/root new file mode 100644 index 0000000..34fa92a --- /dev/null +++ b/files/etc/crontabs/root @@ -0,0 +1,5 @@ + +# min hour day month weekday command +0 * * * * run-parts /etc/periodic/hourly +0 2 * * * run-parts /etc/periodic/daily + diff --git a/files/etc/logrotate.d/get_iplayer b/files/etc/logrotate.d/get_iplayer new file mode 100644 index 0000000..521784f --- /dev/null +++ b/files/etc/logrotate.d/get_iplayer @@ -0,0 +1,8 @@ +/var/log/get_iplayer*.log { + notifempty + weekly + rotate 4 + compress + delaycompress + missingok +} diff --git a/files/etc/periodic/daily/get_iplayer_update b/files/etc/periodic/daily/get_iplayer_update new file mode 100644 index 0000000..3e11877 --- /dev/null +++ b/files/etc/periodic/daily/get_iplayer_update @@ -0,0 +1,12 @@ +#!/bin/sh +# +# Check for get_iplayer update. +# When updating will kill any active downloads launched from web front-end, but not those launched by hourly background PVR. +# +( + OLD=`get_iplayer -V 2>&1 | sed -nE 's/get_iplayer v(\d+)\.(\d+).*/\1\2/p'` # e.g. 321 + wget -qO - "https://api.github.com/repos/get-iplayer/get_iplayer/releases/latest" > /tmp/latest.json + NEW=`jq -r .name /tmp/latest.json | sed -nE 's/v(\d+)\.(\d+).*/\1\2/p'` # e.g. 322 + [ ! -z "$OLD" ] && [ ! -z "$NEW" ] && [ $OLD -lt $NEW ] && echo "Updating get_iplayer $OLD -> $NEW" 1>&2 && wget -qO - "`jq -r .tarball_url /tmp/latest.json`" | tar -zxf - && cd get-iplayer* && install -m 755 -t /usr/local/bin ./get_iplayer ./get_iplayer.cgi && cd $OLDPWD && rm -rf get-iplayer* && PID=`ps | grep "/usr/local/bin/get_iplayer.cgi" | grep -v grep | cut -c1-6` && [ ! -z "$PID" ] && kill $PID +) 2>> /var/log/get_iplayer_update.log +rm -f /tmp/latest.json diff --git a/files/etc/periodic/hourly/get_iplayer_pvr b/files/etc/periodic/hourly/get_iplayer_pvr new file mode 100644 index 0000000..6a1e4f3 --- /dev/null +++ b/files/etc/periodic/hourly/get_iplayer_pvr @@ -0,0 +1,6 @@ +#!/bin/sh +# +# Run pvr +# +umask 2 +su-exec $PUID:$PGID /usr/local/bin/get_iplayer --pvr --quiet 2>> /var/log/get_iplayer.log diff --git a/files/start b/files/start new file mode 100755 index 0000000..7863cbc --- /dev/null +++ b/files/start @@ -0,0 +1,18 @@ +#!/bin/sh +# +# Docker entrypoint +# + +# Ensure up-to-date +/etc/periodic/daily/get_iplayer_update + +# Start cron with output to syslog +/sbin/syslogd +/usr/sbin/crond + +# Restart if killed, e.g. due to update +umask 2 +while true; do + /usr/local/bin/get_iplayer -V + su-exec $PUID:$PGID /usr/local/bin/get_iplayer.cgi -p $PORT +done From 0a456c942c6f8f9faf79eb7fc54913b54efc122d Mon Sep 17 00:00:00 2001 From: Jonathan Ervine Date: Wed, 15 Apr 2020 18:27:19 +0800 Subject: [PATCH 2/3] modified: Jenkinsfile Version 3.25 --- Jenkinsfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Jenkinsfile b/Jenkinsfile index f9da245..065d6c5 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -12,6 +12,7 @@ node("docker-node") { stage "publish" app.push("${env.BUILD_NUMBER}") + app.push("3.25") app.push("latest") } } From 2f9b9d0e161d4ca80e8408c6824f5ed639d08fa0 Mon Sep 17 00:00:00 2001 From: Jonathan Ervine Date: Thu, 4 Jun 2020 23:44:52 +0800 Subject: [PATCH 3/3] modified: Jenkinsfile --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 065d6c5..27ea5ac 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-get_iplayer", credentialsId: 'jenkins-to-git' + git branch: "3.11.6", url: "ssh://git@git.ervine.org/jonny/x86_64-alpine-get_iplayer", credentialsId: 'jenkins-to-git' sh "git rev-parse HEAD > .git/commit-id" def commit_id = readFile('.git/commit-id').trim()