tt-rss updates feeds (introducing OpenRC)

this is a big change: OpenRC introduced to tt-rss container.
However, this also means that environment variables set in
docker-compose.yml are not passed to apache.
This commit is contained in:
boyska 2018-08-10 02:27:17 +02:00
parent efbcbc8204
commit 212791c70a
4 changed files with 67 additions and 5 deletions

View file

@ -1,7 +1,30 @@
FROM ulsmith/alpine-apache-php7 FROM ulsmith/alpine-apache-php7
RUN apk add --update php7-pgsql php7-fileinfo && apk del php7-pdo_mysql php7-pdo_odbc php7-pdo_sqlite db php7-redis php7-ftp && rm -rf /var/cache/apk/ RUN apk add --update php7-pgsql php7-fileinfo openrc postgresql-client && apk del php7-pdo_mysql php7-pdo_odbc php7-pdo_sqlite db php7-redis php7-ftp && rm -rf /var/cache/apk/
RUN mkdir -p /app/public/tt-rss/ /var/cache/tt-rss/images /var/cache/tt-rss/upload /var/cache/tt-rss/export /var/cache/tt-rss/js /var/lock/tt-rss/ RUN mkdir -p /app/public/tt-rss/ /var/cache/tt-rss/images \
RUN chown -R apache:root /app/public /var/cache/tt-rss/ /var/lock/tt-rss/ /var/cache/tt-rss/upload /var/cache/tt-rss/export/ \
/var/cache/tt-rss/js /var/lock/tt-rss/ && \
chown -R apache:root /app/public /var/cache/tt-rss/ /var/lock/tt-rss/ && \
# thanks https://github.com/neeravkumar/dockerfiles/blob/master/alpine-openrc/Dockerfile
# Tell openrc its running inside a container, till now that has meant LXC
sed -i 's/#rc_sys=""/rc_sys="lxc"/g' /etc/rc.conf &&\
# Tell openrc loopback and net are already there, since docker handles the networking
echo 'rc_provide="loopback net"' >> /etc/rc.conf &&\
# can't get ttys unless you run the container in privileged mode
sed -i '/tty/d' /etc/inittab &&\
# can't set hostname since docker sets it
sed -i 's/hostname $opts/# hostname $opts/g' /etc/init.d/hostname &&\
# can't mount tmpfs since not privileged
sed -i 's/mount -t tmpfs/# mount -t tmpfs/g' /lib/rc/sh/init.sh &&\
# can't do cgroups
sed -i 's/cgroup_add_service$/# cgroup_add_service /g' /lib/rc/sh/openrc-run.sh
COPY tt-rss/* /app/public/tt-rss/ COPY tt-rss/* /app/public/tt-rss/
COPY docker/ttrss-openrc-apache /etc/init.d/apache
COPY docker/ttrss-openrc-ttrssupdate /etc/init.d/ttrssupdate
RUN rc-update add apache && rc-update add ttrssupdate
ENTRYPOINT []
CMD ["/sbin/init"]
# vim: set ft=dockerfile: # vim: set ft=dockerfile:

16
docker/ttrss-openrc-apache Executable file
View file

@ -0,0 +1,16 @@
#!/sbin/runscript
start() {
ebegin "Starting Apache (with wrapper)"
start-stop-daemon --background --start --exec /bootstrap/start.sh \
--make-pidfile --pidfile /var/run/apache-start.pid
eend $?
}
stop() {
ebegin "Stopping Apache (with wrapper)"
start-stop-daemon --stop --exec /bootstrap/start.sh \
--pidfile /var/run/apache-start.pid
eend $?
}

20
docker/ttrss-openrc-ttrssupdate Executable file
View file

@ -0,0 +1,20 @@
#!/sbin/openrc-run
name="ttrssupdate"
description="continously update tt-rss feeds"
command="/usr/bin/php7"
command_args="/app/public/tt-rss/update.php --daemon"
command_user="apache"
pidfile="/run/$name.pid"
start_stop_daemon_args=""
start_pre() {
for _ in $(seq 1 60); do
if env PGPASSWORD=password-dev psql -h db -U ttrss -w ttrss; then
return 0
fi
einfo "Waiting... ( $? )"
sleep 1
done
return 1
}

View file

@ -14,9 +14,12 @@ def task_build():
'''builda il container docker''' '''builda il container docker'''
return { return {
'uptodate': [up2date_anyimages], 'uptodate': [up2date_anyimages],
'file_dep': ['docker-compose.yml', 'docker/Dockerfile-tt-rss'], 'file_dep': ['docker-compose.yml', 'docker/Dockerfile-tt-rss',
'docker/ttrss-openrc-apache',
'docker/ttrss-openrc-ttrssupdate'],
'actions': [COMPOSE + ' build'], 'actions': [COMPOSE + ' build'],
'clean': [run_task_func(task__build_rm), run_task_func(task__build_rmi)], 'clean': [run_task_func(task__build_rm),
run_task_func(task__build_rmi)],
'doc': ''' 'doc': '''
This task recreates every docker container. While it is automatically run for most changes in the This task recreates every docker container. While it is automatically run for most changes in the
development environment, please remember that if you want to run it manually to grab changes in the development environment, please remember that if you want to run it manually to grab changes in the