Skip to content

Commit d82398d

Browse files
authored
add docker compose quick start (#80)
1 parent 73c49cc commit d82398d

File tree

1 file changed

+84
-1
lines changed

1 file changed

+84
-1
lines changed

docs/quick-start/docker-compose.md

Lines changed: 84 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,86 @@
11
# docker compose quick start
22

3-
to be done
3+
You can turn an [app sim config](../specification/README.md) into a docker compose
4+
file using the [docker compose generator](../../scripts/generators/docker-compose/).
5+
6+
The generator is available as docker image and you can retrieve it by running
7+
8+
```shell
9+
docker pull cisco-open/app-simulator-generators-docker-compose:latest
10+
```
11+
12+
To try it out, create the a file called `config.yaml` with the following content
13+
in a new folder:
14+
15+
```yaml
16+
services:
17+
frontend:
18+
type: java
19+
port: 3000
20+
endpoints:
21+
http:
22+
/upload:
23+
- http://processing/magicByte
24+
- http://processing/virus
25+
processing:
26+
type: java
27+
endpoints:
28+
http:
29+
/magicByte:
30+
- cache,128
31+
/virus:
32+
- http://virus-scanner/scan
33+
virus-scanner:
34+
type: nodejs
35+
endpoints:
36+
http:
37+
scan:
38+
- sleep,1500
39+
- call: error,500,Scan failed
40+
probability: 0.1
41+
- sleep,500
42+
loaders:
43+
user-1:
44+
type: curl
45+
wait: 0
46+
sleep: 2
47+
urls:
48+
- http://frontend/upload
49+
- http://frontend/upload
50+
- http://frontend/upload
51+
```
52+
53+
To generate a `docker-compose.yaml` from this file run
54+
55+
```shell
56+
docker run --rm -t -i --v ${PWD}:/mnt cisco-open/app-simulator-generators-docker-compose --config /mnt/config.yaml --output /mnt/docker-compose.yaml
57+
```
58+
59+
Review the `docker-compose.yaml` generated and then run the simulation via:
60+
61+
```shell
62+
docker compose up
63+
```
64+
65+
This will bring up the three services (`frontend`, `processing` and `virus-scanner`) and a loader (`user-1`). Run `docker ps` to verify that all
66+
services are up and running:
67+
68+
```shell
69+
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
70+
aebccbe1bc54 ghcr.io/cisco-open/app-simulator-services-java:edge "/entrypoint.sh" 4 seconds ago Up 3 seconds 8080/tcp, 0.0.0.0:3000->80/tcp test-app-sim-frontend-1
71+
75218ac52b90 ghcr.io/cisco-open/app-simulator-services-java:edge "/entrypoint.sh" 4 seconds ago Up 3 seconds 8080/tcp test-app-sim-processing-1
72+
75d7433f85c0 ghcr.io/cisco-open/app-simulator-services-nodejs:edge "docker-entrypoint.s…" 4 seconds ago Up 3 seconds 80/tcp test-app-sim-virus-scanner-1
73+
5f86a8738e15 ghcr.io/cisco-open/app-simulator-loaders-curl:edge "/usr/bin/entrypoint…" 4 seconds ago Up 3 seconds test-app-sim-user-1-1
74+
```
75+
76+
The loader will continuously load from the `/upload` endpoint. You can also reach that endpoint yourself, either by opening <http://localhost:3000/upload>
77+
in the browser or by running the following:
78+
79+
```shell
80+
curl http://localhost:3000/upload
81+
```
82+
83+
The `docker-compose.yaml` that was generated now works independent of the generator. You can use it wherever you want and you can modify it
84+
to your needs.
85+
86+
If you want to learn more about app-simulator and how you can use it for your own needs, we recommend that you continue with the [tutorial](../tutorial/1-two-java-services.md).

0 commit comments

Comments
 (0)