forked from chirpstack/chirpstack-docker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
206 lines (187 loc) · 6.63 KB
/
docker-compose.yml
File metadata and controls
206 lines (187 loc) · 6.63 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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
version: '3.8'
services:
postgres:
image: postgres:14-alpine
container_name: chirpstack-postgres
restart: unless-stopped
volumes:
- postgresqldata:/var/lib/postgresql/data
- postgres-init-scripts:/docker-entrypoint-initdb.d:ro
environment:
- POSTGRES_USER=chirpstack
- POSTGRES_PASSWORD=chirpstack
- POSTGRES_DB=chirpstack
depends_on:
config-init:
condition: service_completed_successfully
networks:
- chirpstack-net
redis:
image: redis:7-alpine
container_name: chirpstack-redis
restart: unless-stopped
command: redis-server --save 300 1 --save 60 100 --appendonly no
volumes:
- redisdata:/data
networks:
- chirpstack-net
mosquitto:
image: eclipse-mosquitto:2
container_name: chirpstack-mosquitto
restart: unless-stopped
ports:
- "${MQTT_PORT:-1883}:1883"
volumes:
- mosquitto-config:/mosquitto/config
- mosquitto-data:/mosquitto/data
- mosquitto-log:/mosquitto/log
networks:
- chirpstack-net
config-init:
image: alpine:latest
container_name: chirpstack-config-init
environment:
- CHIRPSTACK_API_SECRET=${CHIRPSTACK_API_SECRET:-}
- CHIRPSTACK_REGION=${CHIRPSTACK_REGION:-eu868}
- CHIRPSTACK_NETWORK_ID=${CHIRPSTACK_NETWORK_ID:-000000}
command:
- /bin/sh
- -c
- |
set -e
echo "Installing dependencies..."
apk add --no-cache git openssl
echo "Cloning ChirpStack Docker repository..."
git clone https://github.com/chirpstack/chirpstack-docker.git /tmp/chirpstack-repo
echo "Copying configuration files..."
mkdir -p /etc/chirpstack
cp -r /tmp/chirpstack-repo/configuration/chirpstack/* /etc/chirpstack/
mkdir -p /etc/chirpstack-gateway-bridge
cp -r /tmp/chirpstack-repo/configuration/chirpstack-gateway-bridge/* /etc/chirpstack-gateway-bridge/
mkdir -p /mosquitto/config
cp -r /tmp/chirpstack-repo/configuration/mosquitto/config/* /mosquitto/config/
mkdir -p /postgres-init
cp -r /tmp/chirpstack-repo/configuration/postgresql/initdb/* /postgres-init/
chmod +x /postgres-init/*.sh
echo ""
# Check if secret file already exists (from previous deployment)
if [ -f /etc/chirpstack/.api-secret ]; then
echo "Using existing API secret from previous deployment"
API_SECRET=$(cat /etc/chirpstack/.api-secret)
# Check if user provided a secret via environment variable
elif [ -n "$$CHIRPSTACK_API_SECRET" ]; then
echo "Using API secret from environment variable"
API_SECRET="$$CHIRPSTACK_API_SECRET"
echo "$$CHIRPSTACK_API_SECRET" > /etc/chirpstack/.api-secret
else
echo "No API secret provided - generating new random secret..."
API_SECRET=$(openssl rand -base64 32)
echo "$$API_SECRET" > /etc/chirpstack/.api-secret
echo ""
echo "Generated API Secret:"
echo "$$API_SECRET"
echo ""
echo "This secret is used for API tokens and will persist across restarts."
echo "Retrieve anytime from: docker exec chirpstack-server cat /etc/chirpstack/.api-secret"
echo ""
echo "***********"
echo ""
fi
# Update configurations
sed -i "s|secret=\"you-must-replace-this\"|secret=\"$$API_SECRET\"|g" /etc/chirpstack/chirpstack.toml
sed -i "s|net_id=\"000000\"|net_id=\"$$CHIRPSTACK_NETWORK_ID\"|g" /etc/chirpstack/chirpstack.toml
echo ""
echo "Region: $$CHIRPSTACK_REGION"
echo "Network ID: $$CHIRPSTACK_NETWORK_ID"
echo ""
echo "Configuration initialized successfully!"
volumes:
- chirpstack-config:/etc/chirpstack
- gateway-bridge-config:/etc/chirpstack-gateway-bridge
- mosquitto-config:/mosquitto/config
- postgres-init-scripts:/postgres-init
networks:
- chirpstack-net
chirpstack:
image: chirpstack/chirpstack:4
container_name: chirpstack-server
command: -c /etc/chirpstack
restart: unless-stopped
volumes:
- chirpstack-config:/etc/chirpstack:ro
environment:
- POSTGRESQL_HOST=postgres
- REDIS_HOST=redis
- MQTT_BROKER_HOST=mosquitto
depends_on:
config-init:
condition: service_completed_successfully
postgres:
condition: service_started
redis:
condition: service_started
mosquitto:
condition: service_started
ports:
- "${CHIRPSTACK_HTTP_PORT:-8080}:8080"
networks:
- chirpstack-net
chirpstack-gateway-bridge:
image: chirpstack/chirpstack-gateway-bridge:4
container_name: chirpstack-gateway-bridge
restart: unless-stopped
ports:
- "${GATEWAY_UDP_PORT:-1700}:1700/udp"
volumes:
- gateway-bridge-config:/etc/chirpstack-gateway-bridge:ro
environment:
- INTEGRATION__MQTT__EVENT_TOPIC_TEMPLATE=${CHIRPSTACK_REGION:-eu868}/gateway/{{ .GatewayID }}/event/{{ .EventType }}
- INTEGRATION__MQTT__STATE_TOPIC_TEMPLATE=${CHIRPSTACK_REGION:-eu868}/gateway/{{ .GatewayID }}/state/{{ .StateType }}
- INTEGRATION__MQTT__COMMAND_TOPIC_TEMPLATE=${CHIRPSTACK_REGION:-eu868}/gateway/{{ .GatewayID }}/command/#
- INTEGRATION__MQTT__SERVER=tcp://mosquitto:1883
depends_on:
config-init:
condition: service_completed_successfully
mosquitto:
condition: service_started
networks:
- chirpstack-net
chirpstack-gateway-bridge-basicstation:
image: chirpstack/chirpstack-gateway-bridge:4
container_name: chirpstack-gateway-bridge-bs
restart: unless-stopped
command: -c /etc/chirpstack-gateway-bridge/chirpstack-gateway-bridge-basicstation-${CHIRPSTACK_REGION:-eu868}.toml
ports:
- "${GATEWAY_BASICSTATION_PORT:-3001}:3001"
volumes:
- gateway-bridge-config:/etc/chirpstack-gateway-bridge:ro
depends_on:
config-init:
condition: service_completed_successfully
mosquitto:
condition: service_started
networks:
- chirpstack-net
chirpstack-rest-api:
image: chirpstack/chirpstack-rest-api:4
container_name: chirpstack-rest-api
restart: unless-stopped
command: --server chirpstack:8080 --bind 0.0.0.0:8090 --insecure
ports:
- "${CHIRPSTACK_API_PORT:-8090}:8090"
depends_on:
- chirpstack
networks:
- chirpstack-net
volumes:
chirpstack-config:
gateway-bridge-config:
postgres-init-scripts:
postgresqldata:
mosquitto-config:
mosquitto-data:
mosquitto-log:
redisdata:
networks:
chirpstack-net:
driver: bridge