From 5da3d73fd3cb4fe285eedeca382400a7d91a2637 Mon Sep 17 00:00:00 2001 From: Bartek Fabiszewski Date: Fri, 22 May 2020 22:33:47 +0200 Subject: [PATCH] Put uploads dir in docker volume --- .docker/init.sh | 17 ++++++++++------- .docker/run.sh | 4 ++-- .travis.yml | 3 ++- 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/.docker/init.sh b/.docker/init.sh index 33b6aff..65d0ba4 100644 --- a/.docker/init.sh +++ b/.docker/init.sh @@ -12,6 +12,9 @@ sed -i "s/^nobody:.*$/nobody:x:50:/" /etc/group # Prepare ulogger filesystem grep '^[$ /var/www/html/config.php +mkdir -p /data/uploads +rm -rf /var/www/html/uploads +ln -s /data/uploads /var/www/html/uploads chown nobody:nobody /var/www/html/uploads chmod 775 /var/www/html/uploads @@ -24,7 +27,7 @@ else fi if [ "$ULOGGER_DB_DRIVER" = "pgsql" ]; then - export PGDATA=/data + export PGDATA=/data/pgsql mkdir -p ${PGDATA} /run/postgresql /etc/postgres chown postgres:postgres ${PGDATA} /run/postgresql /etc/postgres su postgres -c "initdb --auth-host=md5 --auth-local=trust --locale=en_US.utf-8 --encoding=utf8" @@ -43,15 +46,15 @@ if [ "$ULOGGER_DB_DRIVER" = "pgsql" ]; then sed -i "s/^\$dbdsn = .*$/\$dbdsn = \"pgsql:host=localhost;port=5432;dbname=ulogger\";/" /var/www/html/config.php elif [ "$ULOGGER_DB_DRIVER" = "sqlite" ]; then mkdir -p /data/sqlite - chown -R nobody:nobody /data + chown -R nobody:nobody /data/sqlite sqlite3 -init /var/www/html/scripts/ulogger.sqlite /data/sqlite/ulogger.db .exit - sqlite3 -line /data/ulogger.db "INSERT INTO users (login, password, admin) VALUES ('${ULOGGER_ADMIN_USER}', '\$2y\$10\$7OvZrKgonVZM9lkzrTbiou.CVhO3HjPk5y0W9L68fVwPs/osBRIMq', 1)" + sqlite3 -line /data/sqlite/ulogger.db "INSERT INTO users (login, password, admin) VALUES ('${ULOGGER_ADMIN_USER}', '\$2y\$10\$7OvZrKgonVZM9lkzrTbiou.CVhO3HjPk5y0W9L68fVwPs/osBRIMq', 1)" sed -i "s/^\$dbdsn = .*$/\$dbdsn = \"sqlite:\/data\/sqlite\/ulogger.db\";/" /var/www/html/config.php else - mkdir -p /run/mysqld - chown mysql:mysql /run/mysqld - mysql_install_db --user=mysql --datadir=/data - mysqld_safe --datadir=/data & + mkdir -p /run/mysqld /data/mysql + chown mysql:mysql /run/mysqld /data/mysql + mysql_install_db --user=mysql --datadir=/data/mysql + mysqld_safe --datadir=/data/mysql & mysqladmin --silent --wait=30 ping mysqladmin -u root password "${DB_ROOT_PASS}" mysql -u root -p"${DB_ROOT_PASS}" < /var/www/html/scripts/ulogger.mysql diff --git a/.docker/run.sh b/.docker/run.sh index 69a94a3..3dfc692 100644 --- a/.docker/run.sh +++ b/.docker/run.sh @@ -13,9 +13,9 @@ grep '^\$' /var/www/html/config.php # start services if [ "$ULOGGER_DB_DRIVER" = "pgsql" ]; then - su postgres -c 'pg_ctl -D /data start' + su postgres -c 'pg_ctl -D /data/pgsql start' elif [ "$ULOGGER_DB_DRIVER" = "mysql" ]; then - mysqld_safe --datadir=/data & + mysqld_safe --datadir=/data/mysql & fi nginx php-fpm7 -F diff --git a/.travis.yml b/.travis.yml index 21c6f9e..eb06118 100644 --- a/.travis.yml +++ b/.travis.yml @@ -34,7 +34,8 @@ before_install: sqlite*) sudo apt-get update -qq sudo apt-get install sqlite3 - mkdir -p /tmp/data/sqlite + rm -rf /tmp/data + mkdir -p /tmp/data/sqlite /tmp/data/uploads sqlite3 -init scripts/ulogger.sqlite /tmp/data/sqlite/ulogger.db .exit sudo chown -R travis:travis /tmp/data sudo chmod -R 777 /tmp/data