-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose.yaml
More file actions
72 lines (68 loc) · 2.09 KB
/
Copy pathdocker-compose.yaml
File metadata and controls
72 lines (68 loc) · 2.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
version: '3.8'
services:
mock-server:
image: andboson/mock-server:latest
ports:
- "8081:8081"
environment:
- EXPECTATIONS_FILE=/app/data/expectations.yaml
volumes:
# Mount your local expectations file and response json into the container
- ./internal/testdata/:/app/data/:ro
restart: unless-stopped
# Run as non-root user (matching Dockerfile)
user: "1001:1001"
# another instance with inline JSON configuration
mock-server2:
image: andboson/mock-server:latest
ports:
- "8882:8082"
environment:
SERVER_ADDR_HTTP: ":8082"
EXPECTATIONS_CONFIG_JSON: |-
[
{
"method": "GET",
"path": "/api/hello",
"status": 200,
"headers": {
"Content-Type": "application/json"
},
"mock": "{\"message\": \"Hello from inline config!\"}"
},
{
"method": "POST",
"path": "/api/data",
"status": 200,
"headers": {
"Content-Type": "application/json"
},
"mock": "{\"status\": \"data received\"}"
}
]
restart: unless-stopped
# Run as non-root user (matching Dockerfile)
user: "1001:1001"
# Simple curl tests to verify the mock server
curl-tests:
image: curlimages/curl:latest
depends_on:
- mock-server
command: >
/bin/sh -c "
echo 'Waiting for server...';
sleep 2;
echo '';
echo 'Testing GET /api/hello';
curl http://mock-server:8081/api/hello;
echo '';echo '--------';
echo 'Testing GET /api/users/123';
curl http://mock-server:8081/api/users/123;
echo '';echo '--------';
echo 'Testing POST /api/v1/submit';
curl -X POST -d 'this is important data' http://mock-server:8081/api/v1/submit;
echo '';echo '--------';
echo 'Testing POST /test2/submit';
curl -X POST -d '{"foo":"bar"}' http://mock-server:8081/test2/submit;
echo '';echo '--------';
"