From a0d4fad4d85bdc2b9259171136114b0de50e7ee5 Mon Sep 17 00:00:00 2001 From: Patrick Gansterer Date: Tue, 18 Dec 2018 15:30:55 +0100 Subject: [PATCH] Add multi_coop configuration via environment variable in docker setup If the file app_config.defaults.yml exists in the working directory, the content will be written to the config/app_config.yml and appended by a configuration entry for every foodcoop in the space separated environment variable FOODSOFT_FOODCOOPS. --- Dockerfile | 5 +++-- docker-entrypoint.sh | 13 +++++++++++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index fac934dc..f02998c5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -39,14 +39,15 @@ RUN export DATABASE_URL=mysql2://localhost/temp?encoding=utf8 && \ cp config/app_config.yml.SAMPLE config/app_config.yml && \ cp config/database.yml.MySQL_SAMPLE config/database.yml && \ bundle exec rake db:setup assets:precompile && \ - rm -Rf config/app_config.yml tmp/* && \ + rm -Rf tmp/* && \ /etc/init.d/mysql stop && \ rm -Rf /run/mysqld /tmp/* /var/tmp/* /var/lib/mysql /var/log/mysql* && \ apt-get purge -y --auto-remove mariadb-server && \ rm -Rf /var/lib/apt/lists/* /var/cache/apt/* -# Make relevant dirs writable for app user +# Make relevant dirs and files writable for app user RUN mkdir -p tmp && \ + chown nobody config/app_config.yml && \ chown nobody tmp # Run app as unprivileged user diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh index f76a0d50..cb35ace0 100755 --- a/docker-entrypoint.sh +++ b/docker-entrypoint.sh @@ -6,4 +6,17 @@ if [ -f tmp/pids/server.pid ]; then rm tmp/pids/server.pid fi +if [ -e app_config.defaults.yml ] ; then + cat app_config.defaults.yml > config/app_config.yml + + for FOODCOOP in $FOODSOFT_FOODCOOPS; do + cat << EOF >> config/app_config.yml +$FOODCOOP: + <<: *defaults + database: + database: foodsoft_$FOODCOOP +EOF + done +fi + exec "$@"