From d14a4d442f2efdf4bffcedfdf8711d4ebf0982a1 Mon Sep 17 00:00:00 2001 From: boyska Date: Sun, 19 Aug 2018 01:55:53 +0200 Subject: [PATCH] [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" --- docker-compose.yml | 14 +++++++++++++- docker/Dockerfile-tt-rss | 29 +++++------------------------ docker/ttrss-config.php | 2 +- docker/ttrss-openrc-apache | 24 ------------------------ docker/ttrss-openrc-ntpd | 12 ------------ docker/ttrss-openrc-ttrssupdate | 27 --------------------------- docker/wait-db | 12 ++++++++++++ 7 files changed, 31 insertions(+), 89 deletions(-) delete mode 100755 docker/ttrss-openrc-apache delete mode 100755 docker/ttrss-openrc-ntpd delete mode 100755 docker/ttrss-openrc-ttrssupdate create mode 100755 docker/wait-db diff --git a/docker-compose.yml b/docker-compose.yml index 6e08192..9635efd 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -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 diff --git a/docker/Dockerfile-tt-rss b/docker/Dockerfile-tt-rss index c3b9db0..4735268 100644 --- a/docker/Dockerfile-tt-rss +++ b/docker/Dockerfile-tt-rss @@ -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: diff --git a/docker/ttrss-config.php b/docker/ttrss-config.php index 86fd866..208552e 100644 --- a/docker/ttrss-config.php +++ b/docker/ttrss-config.php @@ -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 diff --git a/docker/ttrss-openrc-apache b/docker/ttrss-openrc-apache deleted file mode 100755 index 49cf5f8..0000000 --- a/docker/ttrss-openrc-apache +++ /dev/null @@ -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: diff --git a/docker/ttrss-openrc-ntpd b/docker/ttrss-openrc-ntpd deleted file mode 100755 index 8fe8641..0000000 --- a/docker/ttrss-openrc-ntpd +++ /dev/null @@ -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: diff --git a/docker/ttrss-openrc-ttrssupdate b/docker/ttrss-openrc-ttrssupdate deleted file mode 100755 index 7d3fd1d..0000000 --- a/docker/ttrss-openrc-ttrssupdate +++ /dev/null @@ -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: diff --git a/docker/wait-db b/docker/wait-db new file mode 100755 index 0000000..3fa5627 --- /dev/null +++ b/docker/wait-db @@ -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