From fa73a498a3c555f37fa27d087f7eec2355a9d5ea Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Thu, 23 Jan 2020 12:00:03 +0300 Subject: [PATCH] prevent updater from failing repeatedly on first startup while app volume is not ready --- app/Dockerfile | 1 + app/updater.sh | 15 +++++++++++++++ docker-compose.yml | 11 ++++++++++- 3 files changed, 26 insertions(+), 1 deletion(-) create mode 100755 app/updater.sh diff --git a/app/Dockerfile b/app/Dockerfile index acb263b..eee0e60 100644 --- a/app/Dockerfile +++ b/app/Dockerfile @@ -9,6 +9,7 @@ RUN apk add --no-cache php7 php7-fpm \ git postgresql-client sudo ADD startup.sh / +ADD updater.sh / ADD index.php / RUN sed -i.bak 's/^listen = 127.0.0.1:9000/listen = 9000/' /etc/php7/php-fpm.d/www.conf diff --git a/app/updater.sh b/app/updater.sh new file mode 100755 index 0000000..71caf9e --- /dev/null +++ b/app/updater.sh @@ -0,0 +1,15 @@ +#!/bin/sh -ex + +while ! pg_isready -h $DB_HOST -U $DB_USER; do + echo waiting until $DB_HOST is ready... + sleep 3 +done + +DST_DIR=/var/www/html/tt-rss + +while [ ! -s $DST_DIR/config.php ]; do + echo waiting for $DST_DIR/config.php... + sleep 3 +done + +exec /usr/bin/php /var/www/html/tt-rss/update_daemon2.php diff --git a/docker-compose.yml b/docker-compose.yml index ca18b4b..380a5e4 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -43,12 +43,21 @@ services: - OWNER_UID=${OWNER_UID} - OWNER_GID=${OWNER_GID} restart: unless-stopped + environment: + - DB_TYPE=pgsql + - DB_HOST=db + - DB_NAME=${POSTGRES_USER} + - DB_USER=${POSTGRES_USER} + - DB_PASS=${POSTGRES_PASSWORD} + - OWNER_UID=${OWNER_UID} + - OWNER_GID=${OWNER_GID} + - SELF_URL_PATH=${SELF_URL_PATH} volumes: - app:/var/www/html depends_on: - app user: app - command: "php /var/www/html/tt-rss/update_daemon2.php" + command: /updater.sh web: build: ./web