diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index d29eccc..64204d7 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -14,11 +14,11 @@ jobs: steps: - uses: actions/checkout@v4 - name: Start Bouncer - run: docker compose up --build -d bouncer test-box - + run: | + rm -f docker-compose.override.yml + docker compose up --build -d bouncer test-box - name: Give it a moment... run: sleep 5 - - name: No-SSL Connect to Web A run: | docker compose exec test-box curl -s -D - http://a.example.org > a.nossl.http @@ -29,7 +29,6 @@ jobs: docker compose exec test-box curl -s -k -D - https://a.example.org 2>&1 > a.ssl.http; grep "HTTP/1.1 200 OK" a.ssl.http; grep "<h1>Website A</h1>" a.ssl.http; - - name: No-SSL Connect to Web B run: | docker compose exec test-box curl -s -D - http://b.example.org 2>&1 > b.nossl.http @@ -40,7 +39,6 @@ jobs: docker compose exec test-box curl -s -k -D - https://b.example.org 2>&1 > b.ssl.http grep "HTTP/1.1 200 OK" b.ssl.http grep "<h1>Website B</h1>" b.ssl.http - - name: No-SSL Connect to SSL-redirect run: | docker compose exec test-box curl -s -D - http://redirect-to-ssl.example.org 2>&1 > redirect.nossl.http @@ -53,20 +51,16 @@ jobs: docker compose exec test-box curl -s -k -D - https://redirect-to-ssl.example.org 2>&1 > redirect.ssl.http grep "HTTP/1.1 200 OK" redirect.ssl.http grep "<h1>Website redirect-to-ssl</h1>" redirect.ssl.http - - name: Connect to Plural multiple times and verify it loadbalances run: | rm -f plural_requests for i in {1..20}; do docker compose exec test-box curl -s -k https://plural.example.org 2>&1 >> plural_requests done - requests=$(cat plural_requests | grep "Running on" | sort | uniq | wc -l) echo "Unique Servers: $requests" - # We should have exactly 3 test $requests -eq 3 - - name: Cleanup if: always() run: docker compose down -v --remove-orphans diff --git a/.gitignore b/.gitignore index f6c586b..edcef9f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,4 @@ .idea -/docker-compose.override.yml /.php-cs-fixer.cache /.github/cache -/.secrets \ No newline at end of file +/.secrets diff --git a/bin/bouncer b/bin/bouncer index 9ba99ed..e54583e 100755 --- a/bin/bouncer +++ b/bin/bouncer @@ -3,6 +3,11 @@ use Bouncer\Bouncer; define("APP_ROOT", realpath(__DIR__ . "/../")); +# If vendor/autoload.php does not exist, we should bomb out and scream +if (!file_exists(APP_ROOT . '/vendor/autoload.php')) { + echo "You must run composer install before running this script\n"; + exit(1); +} require_once APP_ROOT . '/vendor/autoload.php'; (new Bouncer())->run(); diff --git a/docker-compose.override.yml b/docker-compose.override.yml new file mode 100644 index 0000000..30c611f --- /dev/null +++ b/docker-compose.override.yml @@ -0,0 +1,19 @@ +services: + bouncer: + volumes: + - /var/run/docker.sock:/var/run/docker.sock + - ./src:/app/src + - ./templates:/app/templates + - ./vendor:/app/vendor + web-a: + volumes: + - ./tests/testsites:/app/public + web-b: + volumes: + - ./tests/testsites:/app/public + web-plural: + volumes: + - ./tests/testsites:/app/public + web-redirect-ssl: + volumes: + - ./tests/testsites:/app/public diff --git a/docker-compose.yml b/docker-compose.yml index ad98c69..ff22836 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -10,9 +10,6 @@ services: - php:cli=docker-image://ghcr.io/benzine-framework/php:cli-8.2 volumes: - /var/run/docker.sock:/var/run/docker.sock - - ./src:/app/src - - ./templates:/app/templates - - ./vendor:/app/vendor networks: default: aliases: @@ -36,8 +33,6 @@ services: target: test-app additional_contexts: - php:nginx=docker-image://ghcr.io/benzine-framework/php:nginx-8.2 - volumes: - - ./tests/testsites:/app/public environment: - BOUNCER_DOMAIN=a.example.org - BOUNCER_TARGET_PORT=80