Skip to content

Commit

Permalink
Migrate docker-compose to new format
Browse files Browse the repository at this point in the history
  • Loading branch information
csandanov committed Aug 5, 2024
1 parent 71e39ad commit bba11af
Show file tree
Hide file tree
Showing 15 changed files with 30 additions and 44 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ Applied to all presets by default, can be disabled via `$NGINX_VHOST_NO_DEFAULTS

- Pass real IP from a reverse proxy via `$NGINX_SET_REAL_IP_FROM`, e.g. `172.17.0.0/16` for docker network
- Pass multiple real IP from reverse proxies via `$NGINX_SET_REAL_IPS_FROM`
In a docker-compose.yml this can be done like this:
In a `compose.yml` this can be done like this:
```
environment:
NGINX_SET_REAL_IPS_FROM: "[\"172.17.0.0/16\", \"192.168.0.10\"]"
Expand Down
2 changes: 0 additions & 2 deletions tests/basic/docker-compose.yml → tests/basic/compose.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
version: "2"

services:
nginx:
image: $IMAGE
Expand Down
10 changes: 5 additions & 5 deletions tests/basic/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,20 @@ fi
git_url=https://github.com/wodby/nginx.git

clean_exit() {
docker-compose down
docker compose down
}
trap clean_exit EXIT

docker-compose up -d
docker compose up -d

run_action() {
docker-compose exec -T nginx make "${@:2}" -f /usr/local/bin/actions.mk
docker compose exec -T nginx make "${@:2}" -f /usr/local/bin/actions.mk
}

run_action check-ready max_try=10

docker-compose exec -T nginx tests.sh
docker-compose down
docker compose exec -T nginx tests.sh
docker compose down

cid="$(docker run -d -e NGINX_HTTP2=1 --name "nginx" "${IMAGE}")"
trap "docker rm -vf $cid > /dev/null" EXIT
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
version: "2"

services:
nginx:
image: $IMAGE
Expand Down
6 changes: 3 additions & 3 deletions tests/drupal/10/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ if [[ -n "${DEBUG}" ]]; then
fi

nginx_exec() {
docker-compose exec -T nginx "${@}"
docker compose exec -T nginx "${@}"
}

clean_exit() {
docker-compose down -v
docker compose down -v
}
trap clean_exit EXIT

docker-compose up -d
docker compose up -d

nginx_exec make check-ready -f /usr/local/bin/actions.mk

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
version: "2"

services:
nginx:
image: $IMAGE
Expand Down
6 changes: 3 additions & 3 deletions tests/drupal/7/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ if [[ -n "${DEBUG}" ]]; then
fi

nginx_exec() {
docker-compose exec -T nginx "${@}"
docker compose exec -T nginx "${@}"
}

clean_exit() {
docker-compose down -v
docker compose down -v
}
trap clean_exit EXIT

docker-compose up -d
docker compose up -d

nginx_exec make check-ready -f /usr/local/bin/actions.mk

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
version: "2"

services:
nginx:
image: $IMAGE
Expand Down
6 changes: 3 additions & 3 deletions tests/drupal/9/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ if [[ -n "${DEBUG}" ]]; then
fi

nginx_exec() {
docker-compose exec -T nginx "${@}"
docker compose exec -T nginx "${@}"
}

clean_exit() {
docker-compose down -v
docker compose down -v
}
trap clean_exit EXIT

docker-compose up -d
docker compose up -d

nginx_exec make check-ready -f /usr/local/bin/actions.mk

Expand Down
2 changes: 0 additions & 2 deletions tests/matomo/docker-compose.yml → tests/matomo/compose.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
version: "2"

services:
nginx:
image: $IMAGE
Expand Down
10 changes: 5 additions & 5 deletions tests/matomo/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,19 @@ if [[ -n "${DEBUG}" ]]; then
fi

check_endpoint() {
docker-compose exec -T nginx curl -s -S -I "localhost/${1}" | grep -q "${2}"
docker compose exec -T nginx curl -s -S -I "localhost/${1}" | grep -q "${2}"
echo "OK"
}

clean_exit() {
docker-compose down
docker compose down
}
trap clean_exit EXIT

docker-compose up -d
docker compose up -d

docker-compose exec -T nginx make check-ready -f /usr/local/bin/actions.mk
docker-compose exec -T matomo make init -f /usr/local/bin/actions.mk
docker compose exec -T nginx make check-ready -f /usr/local/bin/actions.mk
docker compose exec -T matomo make init -f /usr/local/bin/actions.mk

echo -n "Checking homepage endpoint... "
check_endpoint "" "200 OK"
Expand Down
2 changes: 0 additions & 2 deletions tests/php/docker-compose.yml → tests/php/compose.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
version: "2"

services:
nginx:
image: $IMAGE
Expand Down
10 changes: 5 additions & 5 deletions tests/php/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ if [[ -n "${DEBUG}" ]]; then
fi

clean_exit() {
docker-compose down
docker compose down
}
trap clean_exit EXIT

docker-compose up -d
docker compose up -d

docker-compose exec -T nginx make check-ready max_try=10 -f /usr/local/bin/actions.mk
docker-compose exec -T php sh -c 'echo "<?php echo '\''Hello World!'\'';" > /var/www/html/index.php'
docker compose exec -T nginx make check-ready max_try=10 -f /usr/local/bin/actions.mk
docker compose exec -T php sh -c 'echo "<?php echo '\''Hello World!'\'';" > /var/www/html/index.php'

echo -n "Checking php endpoint... "
docker-compose exec -T nginx curl -s -S "localhost" | grep -q "Hello World!"
docker compose exec -T nginx curl -s -S "localhost" | grep -q "Hello World!"
echo "OK"
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
version: "2"

services:
nginx:
image: $IMAGE
Expand Down
10 changes: 5 additions & 5 deletions tests/wordpress/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,19 @@ if [[ -n "${DEBUG}" ]]; then
fi

check_endpoint() {
docker-compose exec -T nginx curl -s -S -I "localhost/${1}" | grep -q "${2}"
docker compose exec -T nginx curl -s -S -I "localhost/${1}" | grep -q "${2}"
echo "OK"
}

clean_exit() {
docker-compose down
docker compose down
}
trap clean_exit EXIT

docker-compose up -d
docker compose up -d

docker-compose exec -T nginx make check-ready -f /usr/local/bin/actions.mk
docker-compose exec -T wordpress make init -f /usr/local/bin/actions.mk
docker compose exec -T nginx make check-ready -f /usr/local/bin/actions.mk
docker compose exec -T wordpress make init -f /usr/local/bin/actions.mk

echo -n "Checking homepage endpoint... "
check_endpoint "" "302 Found"
Expand Down

0 comments on commit bba11af

Please sign in to comment.