Skip to content

Commit

Permalink
feat: make MYSQL_WAIT_SECONDS
Browse files Browse the repository at this point in the history
  • Loading branch information
shyim committed Jan 23, 2024
1 parent 46a1093 commit 3c570d3
Show file tree
Hide file tree
Showing 10 changed files with 95 additions and 35 deletions.
3 changes: 2 additions & 1 deletion 8.0/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ ENV APP_ENV=prod \
PHP_MAX_UPLOAD_SIZE=128m \
PHP_MAX_EXECUTION_TIME=300 \
PHP_MEMORY_LIMIT=512m \
PHP_ERROR_REPORTING=E_ALL
PHP_ERROR_REPORTING=E_ALL \
MYSQL_WAIT_SECONDS=20

USER www-data

Expand Down
23 changes: 17 additions & 6 deletions 8.0/rootfs/setup
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,23 @@

set -e

until nc -z -v -w30 $DATABASE_HOST $DATABASE_PORT
do
echo "Waiting for database connection..."
# wait for 5 seconds before check again
sleep 5
done
try=0

if [[ $MYSQL_WAIT_SECONDS != 0 ]]; then
until nc -z -v -w30 $DATABASE_HOST $DATABASE_PORT
do
echo "Waiting for database connection..."
# wait for 5 seconds before check again
sleep 1

try=$((try+1))

if [[ $try -gt $MYSQL_WAIT_SECONDS ]]; then
echo "Error: We have been waiting for database connection too long already; failing."
exit 1
fi
done
fi

update_all_plugins() {
list_with_updates=$(php bin/console plugin:list --json | jq 'map(select(.upgradeVersion != null)) | .[].name' -r)
Expand Down
3 changes: 2 additions & 1 deletion 8.1/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ ENV APP_ENV=prod \
PHP_MAX_UPLOAD_SIZE=128m \
PHP_MAX_EXECUTION_TIME=300 \
PHP_MEMORY_LIMIT=512m \
PHP_ERROR_REPORTING=E_ALL
PHP_ERROR_REPORTING=E_ALL \
MYSQL_WAIT_SECONDS=20

USER www-data

Expand Down
23 changes: 17 additions & 6 deletions 8.1/rootfs/setup
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,23 @@

set -e

until nc -z -v -w30 $DATABASE_HOST $DATABASE_PORT
do
echo "Waiting for database connection..."
# wait for 5 seconds before check again
sleep 5
done
try=0

if [[ $MYSQL_WAIT_SECONDS != 0 ]]; then
until nc -z -v -w30 $DATABASE_HOST $DATABASE_PORT
do
echo "Waiting for database connection..."
# wait for 5 seconds before check again
sleep 1

try=$((try+1))

if [[ $try -gt $MYSQL_WAIT_SECONDS ]]; then
echo "Error: We have been waiting for database connection too long already; failing."
exit 1
fi
done
fi

update_all_plugins() {
list_with_updates=$(php bin/console plugin:list --json | jq 'map(select(.upgradeVersion != null)) | .[].name' -r)
Expand Down
3 changes: 2 additions & 1 deletion 8.2/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ ENV APP_ENV=prod \
PHP_MAX_UPLOAD_SIZE=128m \
PHP_MAX_EXECUTION_TIME=300 \
PHP_MEMORY_LIMIT=512m \
PHP_ERROR_REPORTING=E_ALL
PHP_ERROR_REPORTING=E_ALL \
MYSQL_WAIT_SECONDS=20

USER www-data

Expand Down
23 changes: 17 additions & 6 deletions 8.2/rootfs/setup
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,23 @@

set -e

until nc -z -v -w30 $DATABASE_HOST $DATABASE_PORT
do
echo "Waiting for database connection..."
# wait for 5 seconds before check again
sleep 5
done
try=0

if [[ $MYSQL_WAIT_SECONDS != 0 ]]; then
until nc -z -v -w30 $DATABASE_HOST $DATABASE_PORT
do
echo "Waiting for database connection..."
# wait for 5 seconds before check again
sleep 1

try=$((try+1))

if [[ $try -gt $MYSQL_WAIT_SECONDS ]]; then
echo "Error: We have been waiting for database connection too long already; failing."
exit 1
fi
done
fi

update_all_plugins() {
list_with_updates=$(php bin/console plugin:list --json | jq 'map(select(.upgradeVersion != null)) | .[].name' -r)
Expand Down
3 changes: 2 additions & 1 deletion 8.3/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ ENV APP_ENV=prod \
PHP_MAX_UPLOAD_SIZE=128m \
PHP_MAX_EXECUTION_TIME=300 \
PHP_MEMORY_LIMIT=512m \
PHP_ERROR_REPORTING=E_ALL
PHP_ERROR_REPORTING=E_ALL \
MYSQL_WAIT_SECONDS=20

USER www-data

Expand Down
23 changes: 17 additions & 6 deletions 8.3/rootfs/setup
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,23 @@

set -e

until nc -z -v -w30 $DATABASE_HOST $DATABASE_PORT
do
echo "Waiting for database connection..."
# wait for 5 seconds before check again
sleep 5
done
try=0

if [[ $MYSQL_WAIT_SECONDS != 0 ]]; then
until nc -z -v -w30 $DATABASE_HOST $DATABASE_PORT
do
echo "Waiting for database connection..."
# wait for 5 seconds before check again
sleep 1

try=$((try+1))

if [[ $try -gt $MYSQL_WAIT_SECONDS ]]; then
echo "Error: We have been waiting for database connection too long already; failing."
exit 1
fi
done
fi

update_all_plugins() {
list_with_updates=$(php bin/console plugin:list --json | jq 'map(select(.upgradeVersion != null)) | .[].name' -r)
Expand Down
3 changes: 2 additions & 1 deletion Dockerfile.template
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ ENV APP_ENV=prod \
PHP_MAX_UPLOAD_SIZE=128m \
PHP_MAX_EXECUTION_TIME=300 \
PHP_MEMORY_LIMIT=512m \
PHP_ERROR_REPORTING=E_ALL
PHP_ERROR_REPORTING=E_ALL \
MYSQL_WAIT_SECONDS=20

USER www-data

Expand Down
23 changes: 17 additions & 6 deletions rootfs/setup
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,23 @@

set -e

until nc -z -v -w30 $DATABASE_HOST $DATABASE_PORT
do
echo "Waiting for database connection..."
# wait for 5 seconds before check again
sleep 5
done
try=0

if [[ $MYSQL_WAIT_SECONDS != 0 ]]; then
until nc -z -v -w30 $DATABASE_HOST $DATABASE_PORT
do
echo "Waiting for database connection..."
# wait for 5 seconds before check again
sleep 1

try=$((try+1))

if [[ $try -gt $MYSQL_WAIT_SECONDS ]]; then
echo "Error: We have been waiting for database connection too long already; failing."
exit 1
fi
done
fi

update_all_plugins() {
list_with_updates=$(php bin/console plugin:list --json | jq 'map(select(.upgradeVersion != null)) | .[].name' -r)
Expand Down

0 comments on commit 3c570d3

Please sign in to comment.