diff --git a/.github/docker-compose.ci.yml b/.github/docker-compose.ci.yml index ed8cef29..7cbe534d 100644 --- a/.github/docker-compose.ci.yml +++ b/.github/docker-compose.ci.yml @@ -82,3 +82,9 @@ services: volumes: ci_php_app: + +networks: + default: + ipam: + config: + - subnet: "${CI_DOCKER_SUBNET:-10.240.0.0/24}" diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index c05fe111..1885f356 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -207,6 +207,10 @@ jobs: staging_port="$(find_free_port "$((websecure_port + 1))" "$((websecure_port + 2000))")" metrics_port="$(find_free_port "$((staging_port + 1))" "$((staging_port + 2000))")" broker_port="$(find_free_port "$((metrics_port + 1))" "$((metrics_port + 2000))")" + checksum="$(printf '%s' "$COMPOSE_PROJECT_NAME" | cksum | awk '{print $1}')" + subnet_second=$((64 + ((checksum / 256) % 64))) + subnet_third=$((checksum % 256)) + ci_docker_subnet="10.${subnet_second}.${subnet_third}.0/24" { echo "TRAEFIK_WEB_PORT=${web_port}" @@ -214,6 +218,7 @@ jobs: echo "TRAEFIK_WEBSECURE_STAGING_PORT=${staging_port}" echo "TRAEFIK_METRICS_PORT=${metrics_port}" echo "EDGE_BROKER_CI_PORT=${broker_port}" + echo "CI_DOCKER_SUBNET=${ci_docker_subnet}" echo "EDGE_GATEWAY_E2E_BASE_URL=http://localhost:${web_port}/api" echo "EDGE_GATEWAY_E2E_COMPOSE_PROJECT=${COMPOSE_PROJECT_NAME}" } >> "$GITHUB_ENV" diff --git a/scripts/php-ci-test.sh b/scripts/php-ci-test.sh index 80b296e5..c66244c5 100644 --- a/scripts/php-ci-test.sh +++ b/scripts/php-ci-test.sh @@ -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