[TT] stop using OpenRC
it was becoming too complex; now we are running multiple containers from the same image. Coordination between those processes is not needed (db is where it happens), so it should work. waiting psql to be alive is a duty moved to a wrapper script "wait-db"
This commit is contained in:
parent
e9805d28bb
commit
d14a4d442f
7 changed files with 31 additions and 89 deletions
|
@ -18,7 +18,7 @@ services:
|
|||
build:
|
||||
context: .
|
||||
dockerfile: ./docker/Dockerfile-tt-rss
|
||||
container_name: feedati_tt_rss
|
||||
container_name: feedati_tt_php
|
||||
volumes:
|
||||
- ./tt-rss:/app/public/tt-rss/
|
||||
- ./docker/ttrss-config.php:/app/public/tt-rss/config.php:ro
|
||||
|
@ -29,6 +29,18 @@ services:
|
|||
- APACHE_SERVER_NAME=tt-rss
|
||||
- PHP_DISPLAY_ERRORS=stdout
|
||||
- PHP_DISPLAY_STARTUP_ERROR=1
|
||||
tt-rss-update:
|
||||
image: feedati/tt-rss:latest
|
||||
volumes:
|
||||
- ./tt-rss:/app/public/tt-rss/
|
||||
- ./docker/ttrss-config.php:/app/public/tt-rss/config.php:ro
|
||||
container_name: feedati_tt_update
|
||||
environment:
|
||||
- PHP_DISPLAY_ERRORS=stdout
|
||||
- PHP_DISPLAY_STARTUP_ERROR=1
|
||||
entrypoint: 'wait-db php7 /app/public/tt-rss/update.php --daemon'
|
||||
depends_on:
|
||||
- db
|
||||
|
||||
rss-bridge:
|
||||
image: feedati/rss-bridge:latest
|
||||
|
|
|
@ -2,35 +2,16 @@ FROM ulsmith/alpine-apache-php7
|
|||
RUN apk update && apk upgrade && apk add util-linux 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/
|
||||
|
||||
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
|
||||
COPY docker/ttrss-openrc-ntpd /etc/init.d/ntpd
|
||||
COPY docker/wait-db /usr/bin/
|
||||
|
||||
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/ && \
|
||||
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 '/hostname $opts/d' /etc/init.d/hostname &&\
|
||||
# can't mount tmpfs since not privileged
|
||||
sed -i '/mount -t tmpfs/d' /lib/rc/sh/init.sh &&\
|
||||
# can't do cgroups
|
||||
sed -i '/cgroup_add_service$/d' /lib/rc/sh/openrc-run.sh &&\
|
||||
sed -i '/^ntpd/d' /bootstrap/start.sh &&\
|
||||
echo -e 'log_errors = On\nerror_log = syslog' >> /etc/php7/php.ini &&\
|
||||
sed -i -r 's@ErrorLog .*@ErrorLog "|/usr/bin/logger -n syslog -T -P 514 -t apacheErr"@i' /etc/apache2/httpd.conf &&\
|
||||
echo 'TransferLog "|/usr/bin/logger -n syslog -T -P 514 -t apacheLog"' >> /etc/apache2/httpd.conf &&\
|
||||
rc-update add ntpd && rc-update add apache && rc-update add ttrssupdate
|
||||
echo -e 'log_errors = On\nerror_log = syslog' >> /etc/php7/php.ini &&\
|
||||
sed -i '/^Listen/d' /etc/apache2/httpd.conf &&\
|
||||
sed -i -r 's@ErrorLog .*@ErrorLog "/proc/self/fd/2"@i' /etc/apache2/httpd.conf &&\
|
||||
echo -e 'TransferLog "/proc/self/fd/1"\nListen 0.0.0.0:80' >> /etc/apache2/httpd.conf
|
||||
|
||||
|
||||
ENTRYPOINT []
|
||||
CMD ["/sbin/init"]
|
||||
|
||||
# vim: set ft=dockerfile:
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
// *** Basic settings (important!) ***
|
||||
// ***********************************
|
||||
|
||||
define('SELF_URL_PATH', 'http://localhost/tt-rss/');
|
||||
define('SELF_URL_PATH', 'http://feedati-fe/tt-rss/');
|
||||
// Full URL of your tt-rss installation. This should be set to the
|
||||
// location of tt-rss directory, e.g. http://example.org/tt-rss/
|
||||
// You need to set this option correctly otherwise several features
|
||||
|
|
|
@ -1,24 +0,0 @@
|
|||
#!/sbin/runscript
|
||||
|
||||
depend() {
|
||||
need ntpd
|
||||
}
|
||||
|
||||
|
||||
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
|
||||
start-stop-daemon --stop --exec httpd \
|
||||
--pidfile /var/run/apache2/httpd.pid
|
||||
eend $?
|
||||
}
|
||||
# vim: set ft=sh bkc=yes:
|
|
@ -1,12 +0,0 @@
|
|||
#!/sbin/openrc-run
|
||||
|
||||
name="ntpd"
|
||||
description="update clock"
|
||||
command="/usr/sbin/ntpd"
|
||||
command_user="root"
|
||||
pidfile="/run/$name.pid"
|
||||
command_args="-s -p $pidfile"
|
||||
start_stop_daemon_args=""
|
||||
|
||||
|
||||
# vim: set ft=sh bkc=yes:
|
|
@ -1,27 +0,0 @@
|
|||
#!/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"
|
||||
command_background=true
|
||||
start_stop_daemon_args=""
|
||||
|
||||
depend() {
|
||||
need ntpd
|
||||
}
|
||||
|
||||
start_pre() {
|
||||
for _ in $(seq 1 60); do
|
||||
if env PGPASSWORD=password-dev psql -h db -U ttrss -w ttrss -c "" -q; then
|
||||
return 0
|
||||
fi
|
||||
einfo "Waiting..."
|
||||
sleep 1
|
||||
done
|
||||
einfo "Timeout! postgresql wasn't ready in 60 seconds; aborting ${name} start ($description)"
|
||||
return 1
|
||||
}
|
||||
# vim: set ft=sh bkc=yes:
|
12
docker/wait-db
Executable file
12
docker/wait-db
Executable file
|
@ -0,0 +1,12 @@
|
|||
#!/bin/bash
|
||||
timeout=60
|
||||
for _ in $(seq 1 "$timeout"); do
|
||||
if env PGPASSWORD=password-dev psql -h db -U ttrss -w ttrss -c "" -q 2> /dev/null; then
|
||||
echo "DB ready"
|
||||
exec "$@"
|
||||
fi
|
||||
echo "Waiting..." >&2
|
||||
sleep 1
|
||||
done
|
||||
echo "Timeout! postgresql wasn't ready in 60 seconds" >&2
|
||||
exit 1
|
Loading…
Reference in a new issue