Skip to content

Commit

Permalink
Update docker compose test
Browse files Browse the repository at this point in the history
Allows the docker compose test to access the app via
host.docker.internal.

Signed-off-by: Nino Kodabande <[email protected]>
  • Loading branch information
Nino-K committed Feb 10, 2025
1 parent b99b113 commit d6161f5
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 0 deletions.
5 changes: 5 additions & 0 deletions bats/tests/compose/compose.bats
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ verify_running_container() {
verify_running_container "http://${HOST_IP}:8000" "$expected_output"
}

@test 'verify connectivity via host.docker.internal' {
local expected_output="Hello World!"
verify_running_container "http://localhost:8080/app" "$expected_output"
}

@test 'compose down' {
run ctrctl compose --project-directory "$TESTDATA_DIR_HOST" down
assert_success
Expand Down
2 changes: 2 additions & 0 deletions bats/tests/compose/testdata/compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ services:
nginx:
container_name: nginx
image: nginx
volumes:
- ./nginx.conf:/etc/nginx/nginx.conf
ports:
- '127.0.0.1:8080:80'
web:
Expand Down
29 changes: 29 additions & 0 deletions bats/tests/compose/testdata/nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
worker_processes 1;

error_log stderr info;

events {
worker_connections 1024;
}

http {
include mime.types;
sendfile on;
proxy_read_timeout 5s;

server {
listen 80;
server_name localhost;

# Serve the default nginx welcome page
location / {
root /usr/share/nginx/html;
index index.html;
}

# Proxy requests to /app to the backend service
location /app {
proxy_pass http://host.docker.internal:8000/;
}
}
}

0 comments on commit d6161f5

Please sign in to comment.