From 6e058f3d31cd21660500236209fb28025b1a6db1 Mon Sep 17 00:00:00 2001 From: chris Date: Sat, 30 May 2020 12:46:57 +0200 Subject: [PATCH] Make app container wait for DB --- Dockerfile | 1 + entrypoint.sh | 2 ++ wait-for-db.php | 31 +++++++++++++++++++++++++++++++ 3 files changed, 34 insertions(+) create mode 100644 wait-for-db.php diff --git a/Dockerfile b/Dockerfile index a61755f..de571ec 100644 --- a/Dockerfile +++ b/Dockerfile @@ -20,6 +20,7 @@ RUN set -xe;\ FROM reg.zknt.org/zknt/debian-php COPY --from=builder /var/www /var/www COPY entrypoint.sh /entrypoint.sh +COPY wait-for-db.php /wait-for-db.php RUN apt-install php-curl php-zip php-bcmath php-intl php-mbstring php-xml optipng pngquant jpegoptim gifsicle ffmpeg php-imagick php-gd php-redis php-mysql &&\ a2enmod rewrite &&\ sed -i 's/AllowOverride None/AllowOverride All/g' /etc/apache2/apache2.conf diff --git a/entrypoint.sh b/entrypoint.sh index ae84305..6827d82 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -3,6 +3,8 @@ set -xeo pipefail cp -r storage.skel/* storage/ +php /wait-for-db.php + if [[ ! -e storage/.docker.init ]]; then echo "Fresh installation, initializing database..." diff --git a/wait-for-db.php b/wait-for-db.php new file mode 100644 index 0000000..aec9ce2 --- /dev/null +++ b/wait-for-db.php @@ -0,0 +1,31 @@ +