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
This commit is contained in:
Jonny Ervine 2020-02-18 09:50:10 +00:00
parent 8084b08c60
commit 3dcc4b486d
7 changed files with 92 additions and 0 deletions

26
Dockerfile Normal file
View File

@ -0,0 +1,26 @@
FROM harbor.ervine.dev/library/x86_64/alpine/alpine-3.11
MAINTAINER “Jonathan Ervine” <docker@ervine.org>
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

17
Jenkinsfile vendored Normal file
View File

@ -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")
}
}

5
files/etc/crontabs/root Normal file
View File

@ -0,0 +1,5 @@
# min hour day month weekday command
0 * * * * run-parts /etc/periodic/hourly
0 2 * * * run-parts /etc/periodic/daily

View File

@ -0,0 +1,8 @@
/var/log/get_iplayer*.log {
notifempty
weekly
rotate 4
compress
delaycompress
missingok
}

View File

@ -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

View File

@ -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

18
files/start Executable file
View File

@ -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