66 lines
1.8 KiB
YAML
66 lines
1.8 KiB
YAML
version: "3.8"
|
|
|
|
services:
|
|
server:
|
|
build:
|
|
context: ..
|
|
dockerfile: Dockerfile
|
|
ports:
|
|
- "8080:8080"
|
|
environment:
|
|
- SERVER_ADDRESS=0.0.0.0
|
|
- SERVER_PORT=8080
|
|
- JWT_SECRET=secret
|
|
- MQTT_BROKER=tcp://mosquitto:1883
|
|
- MQTT_CLIENT_ID=lambdaiot-server
|
|
- MQTT_TOPIC=lambdaiot
|
|
- MQTT_USERNAME=testuser
|
|
- MQTT_PASSWORD=testpass
|
|
depends_on:
|
|
- mosquitto
|
|
# server image now waits for MQTT broker itself via entrypoint
|
|
# no command override needed
|
|
|
|
mosquitto:
|
|
image: eclipse-mosquitto:2.0
|
|
container_name: mosquitto
|
|
ports:
|
|
- "1883:1883"
|
|
volumes:
|
|
- mosquitto_data:/mosquitto/data
|
|
- mosquitto_log:/mosquitto/log
|
|
- ./mosquitto.conf:/mosquitto/config/mosquitto.conf
|
|
- ./aclfile:/mosquitto/data/aclfile:ro
|
|
environment:
|
|
- MOSQ_USER=testuser
|
|
- MOSQ_PASS=testpass
|
|
# ensure a password file exists (in the writable data volume) and start mosquitto with our config
|
|
command: sh -c "mkdir -p /mosquitto/data; mosquitto_passwd -c -b /mosquitto/data/passwordfile ${MOSQ_USER} ${MOSQ_PASS} >/dev/null 2>&1 || true; chown -R mosquitto:mosquitto /mosquitto/data || true; /usr/sbin/mosquitto -c /mosquitto/config/mosquitto.conf"
|
|
healthcheck:
|
|
test: ["CMD", "sh", "-c", "nc -z localhost 1883 || exit 1"]
|
|
interval: 2s
|
|
timeout: 2s
|
|
retries: 10
|
|
|
|
subscriber:
|
|
image: python:3.11-slim
|
|
volumes:
|
|
- ./subscribe.py:/app/subscribe.py
|
|
working_dir: /app
|
|
environment:
|
|
- MQTT_BROKER=mosquitto:1883
|
|
- MQTT_TOPIC=lambdaiot
|
|
- MQTT_USERNAME=testuser
|
|
- MQTT_PASSWORD=testpass
|
|
command: sh -c "pip install paho-mqtt && python subscribe.py"
|
|
depends_on:
|
|
- mosquitto
|
|
|
|
volumes:
|
|
mosquitto_data:
|
|
mosquitto_log:
|
|
|
|
networks:
|
|
default:
|
|
name: lambdaiot_test_net
|