From 7e86ed44118cc5294c556802ca74635fee1eb093 Mon Sep 17 00:00:00 2001 From: Daniel von Obernitz Date: Tue, 8 Jul 2025 15:59:15 +0200 Subject: [PATCH] Create config files at startup instead of image creation --- Dockerfile | 15 ++++----------- docker-go-entrypoint.sh | 13 ++++++++++++- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/Dockerfile b/Dockerfile index 2b18712..17fec3d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -64,19 +64,12 @@ VOLUME /etc/ssl/groupoffice COPY ./etc/php.ini $PHP_INI_DIR #configure apache -ADD ./etc/apache2/sites-available/000-default.conf $APACHE_CONFDIR/sites-available/000-default.conf +COPY ./etc/apache2/sites-available/000-default.conf $APACHE_CONFDIR/sites-available/000-default.conf -RUN mkdir -p /etc/groupoffice/multi_instance && chown -R www-data:www-data /etc/groupoffice +#default database connection config +COPY ./etc/groupoffice/docker-config.php.tpl /usr/local/share/groupoffice-docker-config.php.tpl #default group-office config -ADD ./etc/groupoffice/docker-config.php.tpl /usr/local/share/groupoffice-docker-config.php.tpl -ADD ./etc/groupoffice/config.php /etc/groupoffice/config.php - -#For persistant configuration -VOLUME /etc/groupoffice - -RUN mkdir -p /var/lib/groupoffice/multi_instance && chown -R www-data:www-data /var/lib/groupoffice -#Group-Office data: -VOLUME /var/lib/groupoffice +COPY ./etc/groupoffice/config.php /usr/local/share/groupoffice-config.php COPY docker-go-entrypoint.sh /usr/local/bin/ diff --git a/docker-go-entrypoint.sh b/docker-go-entrypoint.sh index 445bf8d..9b14208 100755 --- a/docker-go-entrypoint.sh +++ b/docker-go-entrypoint.sh @@ -1,6 +1,18 @@ #!/bin/sh set -e +if [ ! -d /etc/groupoffice/multi_instance ]; then + mkdir -p /etc/groupoffice/multi_instance && chown -R www-data:www-data /etc/groupoffice +fi + +if [ ! -d /var/lib/groupoffice/multi_instance ]; then + mkdir -p /var/lib/groupoffice/multi_instance && chown -R www-data:www-data /var/lib/groupoffice +fi + +if [ ! -f /etc/groupoffice/config.php ]; then + cp /usr/local/share/groupoffice-config.php /etc/groupoffice/config.php +fi + cp /usr/local/share/groupoffice-docker-config.php.tpl /etc/groupoffice/docker-config.php sed -i 's/{dbHost}/'${MYSQL_HOST}'/' /etc/groupoffice/docker-config.php @@ -8,6 +20,5 @@ sed -i 's/{dbName}/'${MYSQL_DATABASE}'/' /etc/groupoffice/docker-config.php sed -i 's/{dbUser}/'${MYSQL_USER}'/' /etc/groupoffice/docker-config.php sed -i 's/{dbPass}/'${MYSQL_PASSWORD}'/' /etc/groupoffice/docker-config.php - #call original entry point docker-php-entrypoint "$@"