Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 05dff0c

Browse filesBrowse files
authored
Merge pull request solidnerd#9 from ssddanbrown/db_port_entrypoint_update
Made DB port configurable from DB_HOST env variable
2 parents 309d91f + f8fdc83 commit 05dff0c
Copy full SHA for 05dff0c

File tree

Expand file treeCollapse file tree

1 file changed

+8
-7
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+8
-7
lines changed

‎docker-entrypoint.sh

Copy file name to clipboardExpand all lines: docker-entrypoint.sh
+8-7Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
#!/bin/bash
22
set -e
33

4-
DB_PORT=${DB_PORT:-3306}
5-
64
echoerr() { echo "$@" 1>&2; }
75

6+
# Split out host and port from DB_HOST env variable
7+
IFS=":" read -r DB_HOST_NAME DB_PORT <<< "$DB_HOST"
8+
DB_PORT=${DB_PORT:-3306}
9+
810
if [ ! -f '/var/www/BookStack/.env' ]; then
911
if [[ "${DB_HOST}" ]]; then
1012
cat > /var/www/BookStack/.env <<EOF
@@ -19,7 +21,6 @@ if [ ! -f '/var/www/BookStack/.env' ]; then
1921
2022
# Database details
2123
DB_HOST=${DB_HOST:-localhost}
22-
DB_PORT=${DB_PORT:-3306}
2324
DB_DATABASE=${DB_DATABASE:-bookstack}
2425
DB_USERNAME=${DB_USERNAME:-bookstack}
2526
DB_PASSWORD=${DB_PASSWORD:-password}
@@ -79,15 +80,15 @@ if [ ! -f '/var/www/BookStack/.env' ]; then
7980
# URL used for social login redirects, NO TRAILING SLASH
8081
EOF
8182
else
82-
echo >&2 'error: missing DB_PORT or DB_HOST environment variables'
83+
echo >&2 'error: missing DB_HOST environment variable'
8384
exit 1
8485
fi
8586
fi
8687

87-
echoerr wait-for-db: waiting for ${DB_HOST}:${DB_PORT}
88+
echoerr wait-for-db: waiting for ${DB_HOST_NAME}:${DB_PORT}
8889

8990
timeout 15 bash <<EOT
90-
while ! (echo > /dev/tcp/${DB_HOST}/${DB_PORT}) >/dev/null 2>&1;
91+
while ! (echo > /dev/tcp/${DB_HOST_NAME}/${DB_PORT}) >/dev/null 2>&1;
9192
do sleep 1;
9293
done;
9394
EOT
@@ -98,7 +99,7 @@ if [ $RESULT -eq 0 ]; then
9899
sleep 1
99100
echoerr wait-for-db: done
100101
else
101-
echoerr wait-for-db: timeout out after 15 seconds waiting for ${DB_HOST}:${DB_PORT}
102+
echoerr wait-for-db: timeout out after 15 seconds waiting for ${DB_HOST_NAME}:${DB_PORT}
102103
fi
103104

104105
cd /var/www/BookStack/ && php artisan key:generate && php artisan migrate --force

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.