diff --git a/.github/workflows/integration-tests.yml b/.github/workflows/integration-tests.yml index 73a0dde..940fb38 100644 --- a/.github/workflows/integration-tests.yml +++ b/.github/workflows/integration-tests.yml @@ -113,6 +113,8 @@ jobs: - name: Enable egress filtering uses: ./ with: + allowed-ips: | + 172.17.0.0/16 allowed-domains: | production.cloudflare.docker.com docker.io @@ -133,3 +135,9 @@ jobs: exit 1; fi; " + + - name: Nginx + run: source test/docker_nginx.sh + + - name: Nginx with port forwarding + run: source test/docker_nginx_port_forwarding.sh diff --git a/test/docker_nginx.sh b/test/docker_nginx.sh new file mode 100644 index 0000000..2414aa3 --- /dev/null +++ b/test/docker_nginx.sh @@ -0,0 +1,30 @@ +#!/bin/bash + +CONTAINER_NAME=nginx-d1c8ad79 + +test() { + local retries=10 + local nginx_container_ip + nginx_container_ip=$(docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' $CONTAINER_NAME) + + echo "Nginx container IP: $nginx_container_ip" + + for ((attempt = 1; attempt <= retries; attempt++)); do + echo "Attempt $attempt..." + if curl --max-time 1 "http://$nginx_container_ip" >/dev/null; then + echo "Successfully connected to nginx container." + exit 0 + else + echo "Connection attempt $attempt failed." + sleep 1 + fi + done + + echo "Failed to connect to nginx container." + exit 1 +} + +# Start nginx container in detached mode and name it 'nginx' +docker run --detach --name $CONTAINER_NAME nginx:1.27 + +test diff --git a/test/docker_nginx_port_forwarding.sh b/test/docker_nginx_port_forwarding.sh new file mode 100644 index 0000000..1e769cb --- /dev/null +++ b/test/docker_nginx_port_forwarding.sh @@ -0,0 +1,26 @@ +#!/bin/bash + +CONTAINER_NAME=nginx-6c5e1575 + +test() { + local retries=10 + + for ((attempt = 1; attempt <= retries; attempt++)); do + echo "Attempt $attempt..." + if curl --max-time 1 "http://127.0.0.1:8080" >/dev/null; then + echo "Successfully connected to nginx container." + exit 0 + else + echo "Connection attempt $attempt failed." + sleep 1 + fi + done + + echo "Failed to connect to nginx container." + exit 1 +} + +# Start nginx container in detached mode and name it 'nginx' +docker run --detach --publish 8080:80 --name $CONTAINER_NAME nginx:1.27 + +test