fix(deploy): reuse existing proxy subnet
This commit is contained in:
@@ -91,6 +91,24 @@ require_var() {
|
||||
return 0
|
||||
}
|
||||
|
||||
resolve_existing_web_proxy_subnet() {
|
||||
if [ -n "${WEB_PROXY_SUBNET:-}" ]; then
|
||||
return 0
|
||||
fi
|
||||
|
||||
local project_name="${COMPOSE_PROJECT_NAME:-$(basename "$PWD")}" network_name subnet
|
||||
network_name="${project_name}_web_proxy"
|
||||
if ! docker network inspect "$network_name" >/dev/null 2>&1; then
|
||||
return 0
|
||||
fi
|
||||
|
||||
subnet="$(docker network inspect -f '{{range .IPAM.Config}}{{println .Subnet}}{{end}}' "$network_name" 2>/dev/null | head -n 1 | tr -d '[:space:]')"
|
||||
if [[ "$subnet" =~ ^([0-9]{1,3}\.){3}[0-9]{1,3}/([0-9]|[12][0-9]|3[0-2])$ ]]; then
|
||||
export WEB_PROXY_SUBNET="$subnet"
|
||||
echo "Reusing WEB_PROXY_SUBNET from the existing ${network_name} Docker network."
|
||||
fi
|
||||
}
|
||||
|
||||
validate_deploy_config() {
|
||||
local failed=0 octet subnet_address microsoft_tenant
|
||||
local -a subnet_octets=()
|
||||
@@ -386,6 +404,8 @@ verify_volume_backup() {
|
||||
report_backup "$target"
|
||||
}
|
||||
|
||||
resolve_existing_web_proxy_subnet
|
||||
|
||||
if ! validate_deploy_config; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user