-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
53 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,7 @@ | ||
docker build -t qtvhao/trycloudflare-docker . | ||
docker push qtvhao/trycloudflare-docker | ||
|
||
TUNNEL=$(docker run -it --rm -v /var/run/docker.sock:/var/run/docker.sock qtvhao/trycloudflare-docker \ | ||
bash get-tunnel.sh docker-compose.yml trycloudflare-docker) | ||
|
||
echo "Tunnel: $TUNNEL" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
docker_compose_file="$1" | ||
project_name="$2" | ||
|
||
set -e | ||
tunnel_container=$(docker compose -f $docker_compose_file -p $project_name ps -q cloudflared-tunnel) | ||
docker inspect -f '{{.State.Running}}' $tunnel_container >/dev/null | ||
if [ $? -eq 0 ]; then | ||
true | ||
else | ||
exit 1 | ||
fi | ||
matcher=".trycloudflare.com" | ||
while true; do | ||
logs=$(docker compose -f $docker_compose_file -p $project_name logs cloudflared-tunnel) | ||
echo "$logs" | grep -oP "Unauthorized" > /dev/null && echo "Unauthorized" && exit 1 | ||
echo "$logs" | grep -oP '(?<=https://).*(?=.trycloudflare.com)' | head -n 1 > /dev/null | ||
if [ $? -eq 0 ]; then | ||
TRYCLOUDFLARE_DOMAIN="$(echo "$logs" | grep -oP '(?<=https://).*(?=.trycloudflare.com)' | head -n 1)" | ||
if [ -z "$TRYCLOUDFLARE_DOMAIN" ]; then | ||
continue; | ||
fi | ||
echo "$TRYCLOUDFLARE_DOMAIN""$matcher" | ||
break; | ||
else | ||
echo "Not ready yet..." | ||
sleep 1 | ||
continue | ||
fi | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
docker_compose_file="$1" | ||
project_name="$2" | ||
# docker compose -f $docker_compose_file -p $project_name logs | ||
sh get-tunnel-admin-domain.sh "$docker_compose_file" "$project_name" | ||
sh get-exist-tunnel.sh "$docker_compose_file" "$project_name" > /dev/null || sh start-tunnel.sh "$docker_compose_file" "$project_name" > /dev/null | ||
sh get-exist-tunnel.sh "$docker_compose_file" "$project_name" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
docker_compose_file="$1" | ||
project_name="$2" | ||
docker compose -f $docker_compose_file -p $project_name down |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
docker_compose_file="$1" | ||
project_name="$2" | ||
|
||
logs=$(docker compose -f $docker_compose_file -p $project_name logs cloudflared-tunnel) | ||
echo "$logs" | grep -oP "Unauthorized" > /dev/null && bash reset-tunnel.sh | ||
|
||
docker compose -f $docker_compose_file -p $project_name up -d |