-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
134 lines (126 loc) · 4.9 KB
/
docker-compose.yml
File metadata and controls
134 lines (126 loc) · 4.9 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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
# =============================================================================
# OCSASim Development Stack
#
# First-time setup (and any time OSH source/branches change):
# docker compose --profile build build osh-builder # ~5–10 min, gradle build
#
# Day-to-day:
# docker compose up -d --build sim osh-node-1 # bring up sim + node 1
# docker compose logs -f sim # tail the sim's output
# docker compose down # stop containers
# docker compose down -v # also drop the H2 db volume
#
# Other shapes:
# docker compose up -d osh-node-1 osh-node-2 # two nodes, no sim
# docker compose --profile scale up -d --scale osh-node=4
#
# The osh-builder service is profile=build so it never runs as a daemon —
# `docker compose up` ignores it. It exists only to build & tag the local
# image ocsasim/osh-builder:latest, which the osh-node Dockerfile copies from.
# =============================================================================
services:
# ── Build-only image: gradle build of OSH (slow, run on demand) ───────────
osh-builder:
build:
context: ./docker/osh-builder
dockerfile: Dockerfile
image: ocsasim/osh-builder:latest
profiles: [build] # excluded from `docker compose up`
# No ports / volumes / networks — this image is never run, only consumed
# by `COPY --from=ocsasim/osh-builder:latest` in docker/osh-node/Dockerfile.
# ── OSH Node 1 (fixed ports for primary testing) ──────────────────────────
# Host ports deliberately offset from OSH's defaults (8282/1883/8181) so a
# locally-installed OSH on the host doesn't fight this container for the
# well-known ports. Inside the container the standard ports are unchanged,
# so the sim service connects to "osh-node-1:8282" / ":1883" as usual.
osh-node-1:
build:
context: ./docker/osh-node
dockerfile: Dockerfile
container_name: osh-node-1
ports:
- "18282:8282" # HTTP API (Connected Systems)
- "11883:1883" # MQTT broker (embedded HiveMQ)
- "18181:8181" # Admin UI (optional)
volumes:
- osh-node-1-data:/opt/osh-node/db
environment:
- OSH_NODE_NAME=osh-node-1
- JAVA_OPTS=-Xmx512m
networks:
- osh-net
healthcheck:
test: ["CMD", "wget", "-q", "--spider", "http://localhost:8282/sensorhub/api/systems"]
interval: 10s
timeout: 5s
start_period: 30s
retries: 5
# ── OSH Node 2 (offset ports) ────────────────────────────────────────────
osh-node-2:
build:
context: ./docker/osh-node
dockerfile: Dockerfile
container_name: osh-node-2
ports:
- "8382:8282" # HTTP API on host port 8382
- "1984:1883" # MQTT on host port 1984
- "8281:8181" # Admin UI on host port 8281
volumes:
- osh-node-2-data:/opt/osh-node/db
environment:
- OSH_NODE_NAME=osh-node-2
- JAVA_OPTS=-Xmx512m
networks:
- osh-net
healthcheck:
test: ["CMD", "wget", "-q", "--spider", "http://localhost:8282/sensorhub/api/systems"]
interval: 10s
timeout: 5s
start_period: 30s
retries: 5
# ── Scalable OSH Nodes (use --scale osh-node=N) ──────────────────────────
# Ports are NOT fixed — use `docker compose port osh-node <N> 8282` to find them.
# Useful for load/multi-node federation tests.
osh-node:
build:
context: ./docker/osh-node
dockerfile: Dockerfile
ports:
- "8282" # random host port → container 8282
- "1883" # random host port → container 1883
volumes:
- osh-node-shared-data:/opt/osh-node/db
environment:
- JAVA_OPTS=-Xmx512m
networks:
- osh-net
profiles:
- scale # only starts with: docker compose --profile scale up --scale osh-node=N
healthcheck:
test: ["CMD", "wget", "-q", "--spider", "http://localhost:8282/sensorhub/api/systems"]
interval: 10s
timeout: 5s
start_period: 30s
retries: 5
# ── OCSASim sim runner ────────────────────────────────────────────────────
# Connects to osh-node-1 by service name. Override the mounted config to
# point at a different node or change which sims run.
sim:
build:
context: .
dockerfile: docker/sim/Dockerfile
container_name: ocsasim-sim
depends_on:
osh-node-1:
condition: service_healthy
volumes:
- ./examples/sim_config.docker.json:/config/sim_config.json:ro
networks:
- osh-net
networks:
osh-net:
driver: bridge
volumes:
osh-node-1-data:
osh-node-2-data:
osh-node-shared-data: