Skip to content

Commit

Permalink
Add more docker scenarios
Browse files Browse the repository at this point in the history
  • Loading branch information
larose committed Jun 23, 2024
1 parent 226acc4 commit dcf8e04
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 0 deletions.
8 changes: 8 additions & 0 deletions .github/workflows/integration-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
30 changes: 30 additions & 0 deletions test/docker_nginx.sh
Original file line number Diff line number Diff line change
@@ -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
26 changes: 26 additions & 0 deletions test/docker_nginx_port_forwarding.sh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit dcf8e04

Please sign in to comment.