-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstart.sh
More file actions
39 lines (30 loc) · 1016 Bytes
/
Copy pathstart.sh
File metadata and controls
39 lines (30 loc) · 1016 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/bin/bash
# Exit if a command fails, if an unset variable is used,
# or if a command in a pipeline fails.
set -euo pipefail
# Stop existing containers and remove volumes so the database resets.
docker compose down -v
# Build and start the containers in the background.
docker compose up -d --build
# Wait for the tunnel service to print a public Cloudflare URL.
url=""
max_retries=30
for ((i=1; i<=max_retries; i++)); do
sleep 1
# Look through the tunnel logs for a trycloudflare URL.
url=$(docker compose logs tunnel 2>&1 | grep -Eo 'https://[^[:space:]]+\.trycloudflare\.com' | head -n 1 || true)
# Stop checking once a URL is found.
if [ -n "$url" ]; then
break
fi
echo "Waiting for tunnel URL... ($i/$max_retries)"
done
# Print the URL if found, otherwise show an error message.
if [ -n "$url" ]; then
echo "Application is online."
echo "Public URL: $url"
else
echo "Timed out waiting for Cloudflare Tunnel URL."
echo "Check logs with: docker compose logs tunnel"
exit 1
fi