Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ docker-compose logs -f --tail=10 haproxy
You can run the following command to see application behavior.

```bash
bin/demo-request.sh 100 # An account No must be pass!
docker-compose run --rm demo-request 100 # An account No must be pass!
```

To stop the containers and remove all data, run the following command.
Expand Down
6 changes: 4 additions & 2 deletions bin/demo-request.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,11 @@ function decorate_stdout {
fi
}

readonly host="${APP_HOST:-localhost}"

while sleep 0.1
do
curl --noproxy localhost --max-time 1 --fail -sS -X POST \
"localhost:${APP_PORT:-8080}/accounts/${account_no}/deposit?amount=100&transactionId=$(date +%s%3N)" \
curl --noproxy "${host}" --max-time 1 --fail -sS -X POST \
"${host}:${APP_PORT:-8080}/accounts/${account_no}/deposit?amount=100&transactionId=$(date +%s%3N)" \
1> >(decorate_stdin) 2> >(decorate_stdout)
done
13 changes: 13 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,16 @@ services:
ports:
- 127.0.0.1:${APP_PORT:-8080}:8080
- 127.0.0.1:${STATS_PORT:-8081}:8081

demo-request:
profiles: ['oneshot']
build:
context: ./docker/demo-request
args:
http_proxy:
https_proxy:
volumes:
- ./bin/demo-request.sh:/usr/local/bin/demo-request
entrypoint: ['/usr/local/bin/demo-request']
environment:
APP_HOST: haproxy
6 changes: 6 additions & 0 deletions docker/demo-request/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
FROM ubuntu:20.04

RUN set -xe; \
apt-get update; \
apt-get install --yes curl; \
: done