Use explicit Docker subnets in API CI
This commit is contained in:
@@ -82,3 +82,9 @@ services:
|
|||||||
|
|
||||||
volumes:
|
volumes:
|
||||||
ci_php_app:
|
ci_php_app:
|
||||||
|
|
||||||
|
networks:
|
||||||
|
default:
|
||||||
|
ipam:
|
||||||
|
config:
|
||||||
|
- subnet: "${CI_DOCKER_SUBNET:-10.240.0.0/24}"
|
||||||
|
|||||||
@@ -207,6 +207,10 @@ jobs:
|
|||||||
staging_port="$(find_free_port "$((websecure_port + 1))" "$((websecure_port + 2000))")"
|
staging_port="$(find_free_port "$((websecure_port + 1))" "$((websecure_port + 2000))")"
|
||||||
metrics_port="$(find_free_port "$((staging_port + 1))" "$((staging_port + 2000))")"
|
metrics_port="$(find_free_port "$((staging_port + 1))" "$((staging_port + 2000))")"
|
||||||
broker_port="$(find_free_port "$((metrics_port + 1))" "$((metrics_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}"
|
echo "TRAEFIK_WEB_PORT=${web_port}"
|
||||||
@@ -214,6 +218,7 @@ jobs:
|
|||||||
echo "TRAEFIK_WEBSECURE_STAGING_PORT=${staging_port}"
|
echo "TRAEFIK_WEBSECURE_STAGING_PORT=${staging_port}"
|
||||||
echo "TRAEFIK_METRICS_PORT=${metrics_port}"
|
echo "TRAEFIK_METRICS_PORT=${metrics_port}"
|
||||||
echo "EDGE_BROKER_CI_PORT=${broker_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_BASE_URL=http://localhost:${web_port}/api"
|
||||||
echo "EDGE_GATEWAY_E2E_COMPOSE_PROJECT=${COMPOSE_PROJECT_NAME}"
|
echo "EDGE_GATEWAY_E2E_COMPOSE_PROJECT=${COMPOSE_PROJECT_NAME}"
|
||||||
} >> "$GITHUB_ENV"
|
} >> "$GITHUB_ENV"
|
||||||
|
|||||||
@@ -88,6 +88,17 @@ prune_unused_docker_networks() {
|
|||||||
docker network prune -f >/dev/null 2>&1 || true
|
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() {
|
cleanup() {
|
||||||
status="$?"
|
status="$?"
|
||||||
collect_logs "$status"
|
collect_logs "$status"
|
||||||
@@ -107,6 +118,7 @@ cleanup() {
|
|||||||
}
|
}
|
||||||
trap cleanup EXIT INT TERM
|
trap cleanup EXIT INT TERM
|
||||||
|
|
||||||
|
configure_ci_docker_subnet
|
||||||
prune_unused_docker_networks
|
prune_unused_docker_networks
|
||||||
retry_command "${PHP_CI_DOCKER_RETRIES:-3}" docker compose $compose_files up -d redis mysql-debug php1
|
retry_command "${PHP_CI_DOCKER_RETRIES:-3}" docker compose $compose_files up -d redis mysql-debug php1
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user