From 4342387078099f4242fdab375666b3d6c44f9d4a Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Tue, 2 Feb 2021 11:28:52 +0300 Subject: [PATCH] move container-related files outside of / --- docker-compose.yml | 4 ++-- src/app/Dockerfile | 23 ++++++++++++----------- src/app/config.docker.php | 2 +- src/app/config.php-config.d | 2 +- src/app/startup.sh | 6 +++--- 5 files changed, 19 insertions(+), 18 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 6aecbfe..6ba346f 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -36,7 +36,7 @@ services: - app:/var/www/html depends_on: - db - command: /dcron.sh -f + command: /opt/tt-rss/dcron.sh -f updater: image: cthulhoo/ttrss-fpm-pgsql-static @@ -52,7 +52,7 @@ services: - ./config.d:/opt/tt-rss/config.d:ro depends_on: - app - command: /updater.sh + command: /opt/tt-rss/updater.sh # web: # image: cthulhoo/ttrss-web diff --git a/src/app/Dockerfile b/src/app/Dockerfile index 899663d..94a714a 100644 --- a/src/app/Dockerfile +++ b/src/app/Dockerfile @@ -8,22 +8,23 @@ RUN apk add --no-cache dcron php7 php7-fpm \ php7-pcntl php7-posix php7-zip php7-openssl \ git postgresql-client sudo rsync -ADD startup.sh / -ADD updater.sh / -ADD index.php / -ADD build-prepare.sh / -ADD dcron.sh / +ENV SCRIPT_ROOT=/opt/tt-rss + +RUN mkdir -p /var/www ${SCRIPT_ROOT}/config.d + +ADD startup.sh ${SCRIPT_ROOT} +ADD updater.sh ${SCRIPT_ROOT} +ADD index.php ${SCRIPT_ROOT} +ADD dcron.sh ${SCRIPT_ROOT} ADD backup.sh /etc/periodic/weekly/backup -ADD config.docker.php / +ADD config.docker.php ${SCRIPT_ROOT} +ADD build-prepare.sh ${SCRIPT_ROOT} RUN sed -i.bak 's/^listen = 127.0.0.1:9000/listen = 9000/' /etc/php7/php-fpm.d/www.conf RUN sed -i.bak 's/\(memory_limit =\) 128M/\1 256M/' /etc/php7/php.ini RUN sed -i.bak 's/;clear_env = .*/clear_env = no/i' /etc/php7/php-fpm.d/www.conf -RUN mkdir -p /var/www -RUN mkdir -p /opt/tt-rss/config.d - -RUN sh -c /build-prepare.sh +RUN sh -c ${SCRIPT_ROOT}/build-prepare.sh ENV OWNER_UID=1000 ENV OWNER_GID=1000 @@ -61,4 +62,4 @@ ENV TTRSS_PLUGINS="auth_internal, note, nginx_xaccel" ENV TTRSS_LOG_DESTINATION="sql" ENV TTRSS_CONFIG_VERSION="26" -CMD /startup.sh +CMD ${SCRIPT_ROOT}/startup.sh diff --git a/src/app/config.docker.php b/src/app/config.docker.php index a546b18..5b66bcc 100644 --- a/src/app/config.docker.php +++ b/src/app/config.docker.php @@ -168,7 +168,7 @@ // if necessary (after migrating all new options from this file). // vim:ft=php - $snippets = glob("/opt/tt-rss/config.d/*.php"); + $snippets = glob(getenv("SCRIPT_ROOT")."/config.d/*.php"); foreach ($snippets as $snippet) { require_once $snippet; diff --git a/src/app/config.php-config.d b/src/app/config.php-config.d index 4c6a7a7..ae7a85b 100644 --- a/src/app/config.php-config.d +++ b/src/app/config.php-config.d @@ -1,4 +1,4 @@ - $snippets = glob("/opt/tt-rss/config.d/*.php"); + $snippets = glob(getenv("SCRIPT_ROOT")."/config.d/*.php"); foreach ($snippets as $snippet) { require_once $snippet; diff --git a/src/app/startup.sh b/src/app/startup.sh index 8dbcd86..e835d0a 100755 --- a/src/app/startup.sh +++ b/src/app/startup.sh @@ -21,7 +21,7 @@ SRC_DIR=/src/tt-rss/ export PGPASSWORD=$TTRSS_DB_PASS -[ ! -e /var/www/html/index.php ] && cp /index.php /var/www/html +[ ! -e /var/www/html/index.php ] && cp ${SCRIPT_ROOT}/index.php /var/www/html if [ ! -d $DST_DIR ]; then rsync -aP \ @@ -66,12 +66,12 @@ elif ! $PSQL -c 'select * from ttrss_version'; then fi if [ ! -s $DST_DIR/config.php ]; then - cp /config.docker.php $DST_DIR/config.php + cp ${SCRIPT_ROOT}/config.docker.php $DST_DIR/config.php else if ! egrep -q 'SELF_URL_PATH.*getenv' $DST_DIR/config.php; then echo -e "\nWARNING: you're using old-style config.php, overrides via .env will not work.\n" >/dev/stderr else - cp /config.docker.php $DST_DIR/config.php + cp ${SCRIPT_ROOT}/config.docker.php $DST_DIR/config.php fi fi