aboutsummaryrefslogtreecommitdiff
path: root/Docker
diff options
context:
space:
mode:
authorGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2021-01-11 22:36:50 +0100
committerGravatar GitHub <noreply@github.com> 2021-01-11 22:36:50 +0100
commit8dfe2097992307b572b42647b53a76dd5d93aaa9 (patch)
tree5c5cecd7437ee584cc540a98f5597196f74fa4de /Docker
parentfd8258775643eb0d898679f210c00de07c79eadc (diff)
Possiblity to autoinstall in Docker Compose (#3353)
* Possiblity to autoinstall in Docker Compose #fix https://github.com/FreshRSS/FreshRSS/issues/3349 It is simply calling our existing CLI: do-install.php and create-user.php https://github.com/FreshRSS/FreshRSS/tree/master/cli FreshRSS will typically be ready a few seconds before the database, so introduce a tolerance when the database is not available / up (yet) by trying a few times to connect. Also useful to avoid service interruption when DB service is restarted. Example: ```yml freshrss-app: image: freshrss/freshrss container_name: freshrss-app hostname: freshrss-app restart: unless-stopped ports: - "8080:80" depends_on: - freshrss-db volumes: - data:/var/www/FreshRSS/data - extensions:/var/www/FreshRSS/extensions environment: CRON_MIN: '*/20' FRESHRSS_ENV: development FRESHRSS_INSTALL: |- --api_enabled --base_url https://rss.example.net --db-base freshrss --db-host freshrss-db --db-password freshrss --db-type pgsql --db-user freshrss --default_user admin --language en FRESHRSS_USER: |- --api_password freshrss --email user@example.net --language en --password freshrss --user admin TZ: Europe/Paris ``` * Minor type f in find * shellcheck
Diffstat (limited to 'Docker')
-rw-r--r--Docker/docker-compose.yml12
-rwxr-xr-xDocker/entrypoint.sh59
2 files changed, 57 insertions, 14 deletions
diff --git a/Docker/docker-compose.yml b/Docker/docker-compose.yml
index e478f404e..8fcc6f6d6 100644
--- a/Docker/docker-compose.yml
+++ b/Docker/docker-compose.yml
@@ -9,9 +9,9 @@ services:
volumes:
- db:/var/lib/postgresql/data
environment:
- - POSTGRES_USER=freshrss
- - POSTGRES_PASSWORD=freshrss
- - POSTGRES_DB=freshrss
+ POSTGRES_USER: freshrss
+ POSTGRES_PASSWORD: freshrss
+ POSTGRES_DB: freshrss
freshrss-app:
image: freshrss/freshrss:latest
@@ -26,10 +26,8 @@ services:
- data:/var/www/FreshRSS/data
- extensions:/var/www/FreshRSS/extensions
environment:
- - CRON_MIN=*/20
- - TZ=Europe/Copenhagen
- labels:
- - "traefik.port=80"
+ CRON_MIN: '*/20'
+ TZ: Europe/Paris
volumes:
db:
diff --git a/Docker/entrypoint.sh b/Docker/entrypoint.sh
index a0cf3be15..87c0a0f85 100755
--- a/Docker/entrypoint.sh
+++ b/Docker/entrypoint.sh
@@ -2,15 +2,12 @@
php -f ./cli/prepare.php >/dev/null
-chown -R :www-data .
-chmod -R g+r . && chmod -R g+w ./data/
-
-find /etc/php*/ -name php.ini -exec sed -r -i "\\#^;?date.timezone#s#^.*#date.timezone = $TZ#" {} \;
-find /etc/php*/ -name php.ini -exec sed -r -i "\\#^;?post_max_size#s#^.*#post_max_size = 32M#" {} \;
-find /etc/php*/ -name php.ini -exec sed -r -i "\\#^;?upload_max_filesize#s#^.*#upload_max_filesize = 32M#" {} \;
+find /etc/php*/ -type f -name php.ini -exec sed -r -i "\\#^;?date.timezone#s#^.*#date.timezone = $TZ#" {} \;
+find /etc/php*/ -type f -name php.ini -exec sed -r -i "\\#^;?post_max_size#s#^.*#post_max_size = 32M#" {} \;
+find /etc/php*/ -type f -name php.ini -exec sed -r -i "\\#^;?upload_max_filesize#s#^.*#upload_max_filesize = 32M#" {} \;
if [ -n "$LISTEN" ]; then
- find /etc/apache2/ -name FreshRSS.Apache.conf -exec sed -r -i "\\#^Listen#s#^.*#Listen $LISTEN#" {} \;
+ find /etc/apache2/ -type f -name FreshRSS.Apache.conf -exec sed -r -i "\\#^Listen#s#^.*#Listen $LISTEN#" {} \;
fi
if [ -n "$CRON_MIN" ]; then
@@ -23,4 +20,52 @@ if [ -n "$CRON_MIN" ]; then
crontab -l | sed -r "\\#FreshRSS#s#^[^ ]+ #$CRON_MIN #" | crontab -
fi
+if [ -n "$FRESHRSS_INSTALL" ]; then
+ # shellcheck disable=SC2046
+ php -f ./cli/do-install.php -- \
+ $(echo "$FRESHRSS_INSTALL" | sed -r 's/[\r\n]+/\n/g' | paste -s -) \
+ 1>/tmp/out.txt 2>/tmp/err.txt
+ EXITCODE=$?
+ grep -v 'Remember to' /tmp/out.txt
+ grep -v 'Please use' /tmp/err.txt 1>&2
+
+ if [ $EXITCODE -eq 3 ]; then
+ echo 'ℹ️ FreshRSS already installed; no change performed.'
+ elif [ $EXITCODE -eq 0 ]; then
+ echo '✅ FreshRSS successfully installed.'
+ else
+ rm -f /tmp/out.txt /tmp/err.txt
+ echo '❌ FreshRSS error during installation!'
+ exit $EXITCODE
+ fi
+
+ rm -f /tmp/out.txt /tmp/err.txt
+fi
+
+if [ -n "$FRESHRSS_USER" ]; then
+ # shellcheck disable=SC2046
+ php -f ./cli/create-user.php -- \
+ $(echo "$FRESHRSS_USER" | sed -r 's/[\r\n]+/\n/g' | paste -s -) \
+ 1>/tmp/out.txt 2>/tmp/err.txt
+ EXITCODE=$?
+ grep -v 'Remember to' /tmp/out.txt
+ cat /tmp/err.txt 1>&2
+
+ if [ $EXITCODE -eq 3 ]; then
+ echo 'ℹ️ FreshRSS user already exists; no change performed.'
+ elif [ $EXITCODE -eq 0 ]; then
+ echo '✅ FreshRSS user successfully created.'
+ ./cli/list-users.php | xargs -n1 ./cli/actualize-user.php --user
+ else
+ rm -f /tmp/out.txt /tmp/err.txt
+ echo '❌ FreshRSS error during the creation of a user!'
+ exit $EXITCODE
+ fi
+
+ rm -f /tmp/out.txt /tmp/err.txt
+fi
+
+chown -R :www-data .
+chmod -R g+r . && chmod -R g+w ./data/
+
exec "$@"