From cbde54034d36bacfa4eac7d7434941e408901904 Mon Sep 17 00:00:00 2001 From: x86dev Date: Fri, 4 Sep 2015 17:12:37 +0200 Subject: [PATCH] Implemented rolling release support: - Now basing on image 'kdelfour/supervisor-docker' - Cron script will check and update TT-RSS and all plugins on a daily basis automatically - SSL/TLS encryption is off by default so that TT-RSS is running on port 80 by default now - SSL/TLS can be enabled with setting "-e TTRSS_SSL_ENABLED=1" - A lot of cleanups --- 10_ttrss.sh | 18 ----- Dockerfile | 67 +++++++------------ service-nginx.conf | 4 ++ service-nginx.sh | 6 -- service-php5-fpm.conf | 4 ++ service-php5-fpm.sh | 6 -- service-ttrss-update.conf | 4 ++ service-ttrss-update.sh | 6 -- setup-ttrss.sh | 59 ++++++++++++++++ configure-db.php => ttrss-configure-db.php | 8 ++- ...php => ttrss-configure-plugin-mobilize.php | 4 +- ttrss-nginx.conf | 10 +-- utils.php => ttrss-utils.php | 0 update-ttrss.sh | 65 ++++++++++++++++++ 14 files changed, 173 insertions(+), 88 deletions(-) delete mode 100755 10_ttrss.sh create mode 100755 service-nginx.conf delete mode 100755 service-nginx.sh create mode 100755 service-php5-fpm.conf delete mode 100755 service-php5-fpm.sh create mode 100755 service-ttrss-update.conf delete mode 100755 service-ttrss-update.sh create mode 100755 setup-ttrss.sh rename configure-db.php => ttrss-configure-db.php (91%) rename configure-plugin-mobilize.php => ttrss-configure-plugin-mobilize.php (94%) rename utils.php => ttrss-utils.php (100%) create mode 100755 update-ttrss.sh diff --git a/10_ttrss.sh b/10_ttrss.sh deleted file mode 100755 index 4ca89a2..0000000 --- a/10_ttrss.sh +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/sh - -set -eu -set -x - -php /root/configure-db.php -php /root/configure-plugin-mobilize.php - -# Generate the TLS certificate for our Tiny Tiny RSS server instance. -openssl req -new -newkey rsa:2048 -days 3650 -nodes -x509 \ - -subj "/C=US/ST=World/L=World/O=ttrss/CN=ttrss" \ - -keyout "/etc/ssl/private/ttrss.key" \ - -out "/etc/ssl/certs/ttrss.cert" -chmod 600 "/etc/ssl/private/ttrss.key" -chmod 600 "/etc/ssl/certs/ttrss.cert" - -# Configure Nginx so that is doesn't show its version number in the HTTP headers. -sed -i -e "s/.*server_tokens.*/server_tokens off;/g" /etc/nginx/nginx.conf diff --git a/Dockerfile b/Dockerfile index 0f0ff07..54fb359 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,13 +1,13 @@ -FROM phusion/baseimage +FROM kdelfour/supervisor-docker # Initially was based on work of Christian Lück MAINTAINER Andreas Löffler RUN DEBIAN_FRONTEND=noninteractive apt-get update && apt-get install -y \ nginx git ca-certificates php5-fpm php5-cli php5-curl php5-gd php5-json \ - php5-pgsql + php5-pgsql # php5-mysql -# add ttrss as the only nginx site +# add ttrss as the only Nginx site ADD ttrss-nginx.conf /etc/nginx/sites-available/ttrss RUN ln -s /etc/nginx/sites-available/ttrss /etc/nginx/sites-enabled/ttrss RUN rm /etc/nginx/sites-enabled/default @@ -21,32 +21,8 @@ RUN sed -i -e "s/;daemonize\s*=\s*yes/daemonize = no/g" /etc/php5/fpm/php-fpm.co # (see /var/log/nginx/error.log for more information then) RUN sed -i -e "s/listen\s*=.*/listen = \/var\/run\/php5-fpm.sock/g" /etc/php5/fpm/pool.d/www.conf -# install ttrss and patch configuration -RUN git clone https://github.com/gothfox/Tiny-Tiny-RSS.git /var/www/ttrss -WORKDIR /var/www/ttrss -RUN cp config.php-dist config.php -RUN sed -i -e "/'SELF_URL_PATH'/s/ '.*'/ 'http:\/\/localhost\/'/" config.php - -# install Feedly theme -RUN git clone https://github.com/levito/tt-rss-feedly-theme.git -RUN ln -s /var/www/ttrss/tt-rss-feedly-theme/feedly /var/www/ttrss/themes/feedly -RUN ln -s /var/www/ttrss/tt-rss-feedly-theme/feedly.css /var/www/ttrss/themes/feedly.css - -# install ttrss-mobilize plugin -RUN git clone https://github.com/sepich/tt-rss-mobilize.git /var/www/ttrss/plugins/mobilize -ADD ttrss-plugin-mobilize.pgsql /var/www/ttrss/plugins/mobilize/ttrss-plugin-mobilize.pgsql - -# patch ttrss-mobilize plugin for getting it to work -RUN sed -i -e "s/> /var/log/service-nginx.log 2>&1 diff --git a/service-php5-fpm.conf b/service-php5-fpm.conf new file mode 100755 index 0000000..d18a6b6 --- /dev/null +++ b/service-php5-fpm.conf @@ -0,0 +1,4 @@ +[program:php5-fpm] +command=/usr/sbin/php5-fpm +user=root +redirect_stderr=true diff --git a/service-php5-fpm.sh b/service-php5-fpm.sh deleted file mode 100755 index 6ee3e94..0000000 --- a/service-php5-fpm.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/sh - -set -eu -set -x - -/usr/sbin/php5-fpm >> /var/log/service-php5-fpm.log 2>&1 diff --git a/service-ttrss-update.conf b/service-ttrss-update.conf new file mode 100755 index 0000000..8963820 --- /dev/null +++ b/service-ttrss-update.conf @@ -0,0 +1,4 @@ +[program:ttrss-daemon] +command=/usr/bin/php /var/www/ttrss/update_daemon2.php +user=www-data +redirect_stderr=true diff --git a/service-ttrss-update.sh b/service-ttrss-update.sh deleted file mode 100755 index 0a9c217..0000000 --- a/service-ttrss-update.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/sh - -set -eu -set -x - -exec /sbin/setuser www-data /usr/bin/php /var/www/ttrss/update_daemon2.php >> /var/log/service-ttrss-update.log 2>&1 diff --git a/setup-ttrss.sh b/setup-ttrss.sh new file mode 100755 index 0000000..cb32633 --- /dev/null +++ b/setup-ttrss.sh @@ -0,0 +1,59 @@ +#!/bin/sh + +set -e + +setup_nginx() +{ + if [ -z "$TTRSS_HOST" ]; then + TTRSS_HOST=ttrss + fi + + if [ "$TTRSS_SSL_ENABLED" = "1" ]; then + if [ ! -f "/etc/ssl/private/ttrss.key" ]; then + # Generate the TLS certificate for our Tiny Tiny RSS server instance. + openssl req -new -newkey rsa:2048 -days 3650 -nodes -x509 \ + -subj "/C=US/ST=World/L=World/O=$TTRSS_HOST/CN=$TTRSS_HOST" \ + -keyout "/etc/ssl/private/ttrss.key" \ + -out "/etc/ssl/certs/ttrss.crt" + fi + chmod 600 "/etc/ssl/private/ttrss.key" + chmod 600 "/etc/ssl/certs/ttrss.crt" + else + # Turn off SSL. + sed -i -e "s/listen\s*443\s*;/listen 80;/g" /etc/nginx/sites-enabled/ttrss + sed -i -e "s/ssl\s*on\s*;/ssl off;/g" /etc/nginx/sites-enabled/ttrss + sed -i -e "/\s*ssl_*/d" /etc/nginx/sites-enabled/ttrss + fi + + # Configure Nginx so that is doesn't show its version number in the HTTP headers. + sed -i -e "s/.*server_tokens.*/server_tokens off;/g" /etc/nginx/nginx.conf +} + +setup_ttrss() +{ + TTRSS_PATH=/var/www/ttrss + + mkdir -p ${TTRSS_PATH} + git clone https://tt-rss.org/gitlab/fox/tt-rss.git ${TTRSS_PATH} + git clone https://github.com/sepich/tt-rss-mobilize.git ${TTRSS_PATH}/plugins/mobilize + git clone https://github.com/hrk/tt-rss-newsplus-plugin.git ${TTRSS_PATH}/plugins/api_newsplus + git clone https://github.com/levito/tt-rss-feedly-theme.git ${TTRSS_PATH}/themes/feedly-git + + # Add initial config. + cp ${TTRSS_PATH}/config.php-dist ${TTRSS_PATH}/config.php + + # Patch URL path. + sed -i -e "/'SELF_URL_PATH'/s/ '.*'/ 'http:\/\/localhost\/'/" ${TTRSS_PATH}/config.php + + # Enable additional system plugins: api_newsplus. + sed -i -e "s/.*define('PLUGINS'.*/define('PLUGINS', 'api_newsplus, auth_internal, note, updater');/g" ${TTRSS_PATH}/config.php +} + +echo "Setup: Installing Tiny Tiny RSS ..." +setup_ttrss +setup_nginx + +echo "Setup: Applying updates ..." +/srv/update-ttrss.sh --no-start + +echo "Setup: Done" diff --git a/configure-db.php b/ttrss-configure-db.php similarity index 91% rename from configure-db.php rename to ttrss-configure-db.php index bedda6e..fe6f84a 100644 --- a/configure-db.php +++ b/ttrss-configure-db.php @@ -1,11 +1,13 @@ #!/usr/bin/env php