From: Thomas Bruederli Date: Sun, 6 Mar 2022 21:00:15 +0000 (+0100) Subject: improve DB init/update to avoid false error messages X-Git-Url: http://git.99rst.org/?a=commitdiff_plain;h=2672a50f1c603494fb1bac4c985ec08444f036e1;p=roundcube-roundcubemail-docker.git improve DB init/update to avoid false error messages --- diff --git a/apache/Dockerfile b/apache/Dockerfile index 3197591..37640e9 100644 --- a/apache/Dockerfile +++ b/apache/Dockerfile @@ -102,6 +102,9 @@ RUN set -ex; \ rm -rf /usr/src/roundcubemail/installer; \ chown -R www-data:www-data /usr/src/roundcubemail/logs +# copy the latest version of initdb.sh which supports the --update flag +RUN curl -fL https://raw.githubusercontent.com/roundcube/roundcubemail/master/bin/initdb.sh > /usr/src/roundcubemail/bin/initdb.sh && chmod +x /usr/src/roundcubemail/bin/initdb.sh + # include the wait-for-it.sh script RUN curl -fL https://raw.githubusercontent.com/vishnubob/wait-for-it/master/wait-for-it.sh > /wait-for-it.sh && chmod +x /wait-for-it.sh diff --git a/apache/docker-entrypoint.sh b/apache/docker-entrypoint.sh index 50afaa6..3937945 100755 --- a/apache/docker-entrypoint.sh +++ b/apache/docker-entrypoint.sh @@ -121,7 +121,7 @@ if [[ "$1" == apache2* ]] || [ "$1" == php-fpm ]; then done # initialize or update DB - bin/initdb.sh --dir=$PWD/SQL --create || bin/updatedb.sh --dir=$PWD/SQL --package=roundcube || echo "Failed to initialize database. Please run $PWD/bin/initdb.sh and $PWD/bin/updatedb.sh manually." + bin/initdb.sh --dir=$PWD/SQL --update || echo "Failed to initialize/update the database. Please start with an empty database and restart the container." if [ ! -z "${ROUNDCUBEMAIL_TEMP_DIR}" ]; then mkdir -p ${ROUNDCUBEMAIL_TEMP_DIR} && chown www-data ${ROUNDCUBEMAIL_TEMP_DIR} diff --git a/fpm-alpine/Dockerfile b/fpm-alpine/Dockerfile index 08fc22d..dcaf641 100644 --- a/fpm-alpine/Dockerfile +++ b/fpm-alpine/Dockerfile @@ -94,6 +94,9 @@ RUN set -ex; \ chown -R www-data:www-data /usr/src/roundcubemail/logs; \ apk del .fetch-deps +# copy the latest version of initdb.sh which supports the --update flag +RUN curl -fL https://raw.githubusercontent.com/roundcube/roundcubemail/master/bin/initdb.sh > /usr/src/roundcubemail/bin/initdb.sh && chmod +x /usr/src/roundcubemail/bin/initdb.sh + # include the wait-for-it.sh script RUN curl -fL https://raw.githubusercontent.com/vishnubob/wait-for-it/master/wait-for-it.sh > /wait-for-it.sh && chmod +x /wait-for-it.sh diff --git a/fpm-alpine/docker-entrypoint.sh b/fpm-alpine/docker-entrypoint.sh index 50afaa6..3937945 100755 --- a/fpm-alpine/docker-entrypoint.sh +++ b/fpm-alpine/docker-entrypoint.sh @@ -121,7 +121,7 @@ if [[ "$1" == apache2* ]] || [ "$1" == php-fpm ]; then done # initialize or update DB - bin/initdb.sh --dir=$PWD/SQL --create || bin/updatedb.sh --dir=$PWD/SQL --package=roundcube || echo "Failed to initialize database. Please run $PWD/bin/initdb.sh and $PWD/bin/updatedb.sh manually." + bin/initdb.sh --dir=$PWD/SQL --update || echo "Failed to initialize/update the database. Please start with an empty database and restart the container." if [ ! -z "${ROUNDCUBEMAIL_TEMP_DIR}" ]; then mkdir -p ${ROUNDCUBEMAIL_TEMP_DIR} && chown www-data ${ROUNDCUBEMAIL_TEMP_DIR} diff --git a/fpm/Dockerfile b/fpm/Dockerfile index 62e0939..2c7f25e 100644 --- a/fpm/Dockerfile +++ b/fpm/Dockerfile @@ -101,13 +101,16 @@ RUN set -ex; \ rm -rf /usr/src/roundcubemail/installer; \ chown -R www-data:www-data /usr/src/roundcubemail/logs +# copy the latest version of initdb.sh which supports the --update flag +RUN curl -fL https://raw.githubusercontent.com/roundcube/roundcubemail/master/bin/initdb.sh > /usr/src/roundcubemail/bin/initdb.sh && chmod +x /usr/src/roundcubemail/bin/initdb.sh + # include the wait-for-it.sh script RUN curl -fL https://raw.githubusercontent.com/vishnubob/wait-for-it/master/wait-for-it.sh > /wait-for-it.sh && chmod +x /wait-for-it.sh # use custom PHP settings COPY php.ini /usr/local/etc/php/conf.d/roundcube-defaults.ini -COPY docker-entrypoint.sh / +COPY --chmod=0755 docker-entrypoint.sh / ENTRYPOINT ["/docker-entrypoint.sh"] CMD ["php-fpm"] diff --git a/fpm/docker-entrypoint.sh b/fpm/docker-entrypoint.sh index 50afaa6..3937945 100755 --- a/fpm/docker-entrypoint.sh +++ b/fpm/docker-entrypoint.sh @@ -121,7 +121,7 @@ if [[ "$1" == apache2* ]] || [ "$1" == php-fpm ]; then done # initialize or update DB - bin/initdb.sh --dir=$PWD/SQL --create || bin/updatedb.sh --dir=$PWD/SQL --package=roundcube || echo "Failed to initialize database. Please run $PWD/bin/initdb.sh and $PWD/bin/updatedb.sh manually." + bin/initdb.sh --dir=$PWD/SQL --update || echo "Failed to initialize/update the database. Please start with an empty database and restart the container." if [ ! -z "${ROUNDCUBEMAIL_TEMP_DIR}" ]; then mkdir -p ${ROUNDCUBEMAIL_TEMP_DIR} && chown www-data ${ROUNDCUBEMAIL_TEMP_DIR} diff --git a/templates/Dockerfile-alpine.templ b/templates/Dockerfile-alpine.templ index 7a9bacc..151eba1 100644 --- a/templates/Dockerfile-alpine.templ +++ b/templates/Dockerfile-alpine.templ @@ -94,13 +94,16 @@ RUN set -ex; \ chown -R www-data:www-data /usr/src/roundcubemail/logs; \ apk del .fetch-deps +# copy the latest version of initdb.sh which supports the --update flag +RUN curl -fL https://raw.githubusercontent.com/roundcube/roundcubemail/master/bin/initdb.sh > /usr/src/roundcubemail/bin/initdb.sh && chmod +x /usr/src/roundcubemail/bin/initdb.sh + # include the wait-for-it.sh script RUN curl -fL https://raw.githubusercontent.com/vishnubob/wait-for-it/master/wait-for-it.sh > /wait-for-it.sh && chmod +x /wait-for-it.sh # use custom PHP settings COPY php.ini /usr/local/etc/php/conf.d/roundcube-defaults.ini -COPY docker-entrypoint.sh / +COPY --chmod=0755 docker-entrypoint.sh / ENTRYPOINT ["/docker-entrypoint.sh"] CMD ["%%CMD%%"] diff --git a/templates/Dockerfile-debian.templ b/templates/Dockerfile-debian.templ index 905e78f..02f12a8 100644 --- a/templates/Dockerfile-debian.templ +++ b/templates/Dockerfile-debian.templ @@ -101,13 +101,16 @@ RUN set -ex; \ rm -rf /usr/src/roundcubemail/installer; \ chown -R www-data:www-data /usr/src/roundcubemail/logs +# copy the latest version of initdb.sh which supports the --update flag +RUN curl -fL https://raw.githubusercontent.com/roundcube/roundcubemail/master/bin/initdb.sh > /usr/src/roundcubemail/bin/initdb.sh && chmod +x /usr/src/roundcubemail/bin/initdb.sh + # include the wait-for-it.sh script RUN curl -fL https://raw.githubusercontent.com/vishnubob/wait-for-it/master/wait-for-it.sh > /wait-for-it.sh && chmod +x /wait-for-it.sh # use custom PHP settings COPY php.ini /usr/local/etc/php/conf.d/roundcube-defaults.ini -COPY docker-entrypoint.sh / +COPY --chmod=0755 docker-entrypoint.sh / ENTRYPOINT ["/docker-entrypoint.sh"] CMD ["%%CMD%%"] diff --git a/templates/docker-entrypoint.sh b/templates/docker-entrypoint.sh index 50afaa6..3937945 100644 --- a/templates/docker-entrypoint.sh +++ b/templates/docker-entrypoint.sh @@ -121,7 +121,7 @@ if [[ "$1" == apache2* ]] || [ "$1" == php-fpm ]; then done # initialize or update DB - bin/initdb.sh --dir=$PWD/SQL --create || bin/updatedb.sh --dir=$PWD/SQL --package=roundcube || echo "Failed to initialize database. Please run $PWD/bin/initdb.sh and $PWD/bin/updatedb.sh manually." + bin/initdb.sh --dir=$PWD/SQL --update || echo "Failed to initialize/update the database. Please start with an empty database and restart the container." if [ ! -z "${ROUNDCUBEMAIL_TEMP_DIR}" ]; then mkdir -p ${ROUNDCUBEMAIL_TEMP_DIR} && chown www-data ${ROUNDCUBEMAIL_TEMP_DIR}