Skip to content

Commit d2a983d

Browse files
authored
Add ME_CONFIG_MONGODB_URL support to wait_tcp_port (#70)
1 parent 17e2815 commit d2a983d

File tree

5 files changed

+110
-50
lines changed

5 files changed

+110
-50
lines changed

1.0/18-alpine3.18/docker-entrypoint.sh

Lines changed: 22 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

1.0/18-alpine3.19/docker-entrypoint.sh

Lines changed: 22 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

1.0/20-alpine3.18/docker-entrypoint.sh

Lines changed: 22 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

1.0/20-alpine3.19/docker-entrypoint.sh

Lines changed: 22 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docker-entrypoint.sh

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,28 @@ function wait_tcp_port {
1919
exec 6>&-
2020
}
2121

22-
23-
# TODO: Using ME_CONFIG_MONGODB_SERVER is going to be deprecated, a way to parse connection string
24-
# is required for checking port health
25-
26-
# if ME_CONFIG_MONGODB_SERVER has a comma in it, we're pointing to a replica set (https://github.com/mongo-express/mongo-express-docker/issues/21)
27-
28-
if [[ "$ME_CONFIG_MONGODB_SERVER" != *,* ]]; then
29-
# wait for the mongo server to be available
30-
echo Waiting for ${ME_CONFIG_MONGODB_SERVER}:${ME_CONFIG_MONGODB_PORT:-27017}...
31-
wait_tcp_port "${ME_CONFIG_MONGODB_SERVER}" "${ME_CONFIG_MONGODB_PORT:-27017}" "${ME_CONFIG_CONNECT_RETRIES:-5}"
22+
# if ME_CONFIG_MONGODB_URL has a comma in it, we're pointing to a replica set (https://github.com/mongo-express/mongo-express-docker/issues/21)
23+
if [[ "$ME_CONFIG_MONGODB_URL" != *,* ]]; then
24+
work=$ME_CONFIG_MONGODB_URL
25+
# Remove the scheme (should be "mongodb://" or "mongodb+srv://").
26+
work=${work#*://}
27+
# Remove the path component of the URL (should just be a "/").
28+
work=${work%%/*}
29+
# Remove the userinfo.
30+
work=${work#*@}
31+
if [[ "$work" = *:* ]]; then
32+
# Match the host.
33+
host=${work%:*}
34+
# Match the port.
35+
port=${work#*:}
36+
else
37+
host=$work
38+
port=27017
39+
fi
40+
41+
# wait for the mongo server to be available
42+
echo "Waiting for $host:$port..."
43+
wait_tcp_port "$host" "$port"
3244
fi
3345

3446
# run mongo-express

0 commit comments

Comments
 (0)