From 4f3ba3d52c5218dbe3f0caed15e663f5cb0479d5 Mon Sep 17 00:00:00 2001 From: Jonathan Piron Date: Tue, 27 Dec 2016 12:11:55 +0100 Subject: [PATCH 1/2] Add support for a root path --- Dockerfile | 3 ++- entrypoint.sh | 19 +++++++++++++++++++ ttrss.nginx.conf | 3 +-- 3 files changed, 22 insertions(+), 3 deletions(-) create mode 100755 entrypoint.sh diff --git a/Dockerfile b/Dockerfile index ff4374b..1c52755 100644 --- a/Dockerfile +++ b/Dockerfile @@ -42,4 +42,5 @@ ENV AUTH_METHOD internal # always re-configure database with current ENV when RUNning container, then monitor all services ADD configure-db.php /configure-db.php ADD supervisord.conf /etc/supervisor/conf.d/supervisord.conf -CMD php /configure-db.php && supervisord -c /etc/supervisor/conf.d/supervisord.conf +ADD entrypoint.sh /entrypoint.sh +ENTRYPOINT ["/entrypoint.sh"] diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100755 index 0000000..a09be81 --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1,19 @@ +#!/bin/bash +set -e + +# remove trailing / if any. +SELF_URL_PATH=${SELF_URL_PATH/%\//} + +# extract the root path from SELF_URL_PATH (i.e http://domain.tld/). +ROOT_PATH=${SELF_URL_PATH/#http*\:\/\/*\//} +if [ "${ROOT_PATH}" == "${SELF_URL_PATH}" ]; then + # no root path in SELF_URL_PATH. + mkdir -p /var/tmp + ln -s "/var/www" "/var/tmp/www" +else + mkdir -p /var/tmp/www + ln -s "/var/www" "/var/tmp/www/${ROOT_PATH}" +fi + +php /configure-db.php +exec supervisord -c /etc/supervisor/conf.d/supervisord.conf diff --git a/ttrss.nginx.conf b/ttrss.nginx.conf index fa46f23..9c9184d 100644 --- a/ttrss.nginx.conf +++ b/ttrss.nginx.conf @@ -1,6 +1,6 @@ server { listen 80; - root /var/www; + root /var/tmp/www; index index.php index.html; @@ -15,4 +15,3 @@ server { include fastcgi_params; } } - From c2f8078a05c6602f036e43092e2691d03ae9c455 Mon Sep 17 00:00:00 2001 From: Jonathan Piron Date: Thu, 12 Jan 2017 14:43:06 +0100 Subject: [PATCH 2/2] Fix symlink creations It was failing at container restart as they already exist. --- entrypoint.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/entrypoint.sh b/entrypoint.sh index a09be81..1011e4c 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -9,10 +9,10 @@ ROOT_PATH=${SELF_URL_PATH/#http*\:\/\/*\//} if [ "${ROOT_PATH}" == "${SELF_URL_PATH}" ]; then # no root path in SELF_URL_PATH. mkdir -p /var/tmp - ln -s "/var/www" "/var/tmp/www" + ln -sf "/var/www" "/var/tmp/www" else mkdir -p /var/tmp/www - ln -s "/var/www" "/var/tmp/www/${ROOT_PATH}" + ln -sf "/var/www" "/var/tmp/www/${ROOT_PATH}" fi php /configure-db.php