Use explicit Docker subnets in API CI

This commit is contained in:
Jeppe Bundgaard
2026-07-01 11:00:13 +02:00
parent 178c84ba60
commit f5e0baaab6
3 changed files with 23 additions and 0 deletions
+12
View File
@@ -88,6 +88,17 @@ prune_unused_docker_networks() {
docker network prune -f >/dev/null 2>&1 || true
}
configure_ci_docker_subnet() {
if [ -n "${CI_DOCKER_SUBNET:-}" ]; then
return
fi
checksum="$(printf '%s' "$COMPOSE_PROJECT_NAME" | cksum | awk '{print $1}')"
subnet_second=$((64 + ((checksum / 256) % 64)))
subnet_third=$((checksum % 256))
export CI_DOCKER_SUBNET="10.${subnet_second}.${subnet_third}.0/24"
}
cleanup() {
status="$?"
collect_logs "$status"
@@ -107,6 +118,7 @@ cleanup() {
}
trap cleanup EXIT INT TERM
configure_ci_docker_subnet
prune_unused_docker_networks
retry_command "${PHP_CI_DOCKER_RETRIES:-3}" docker compose $compose_files up -d redis mysql-debug php1