test: change compose
This commit is contained in:
@@ -1,6 +1,42 @@
|
||||
version: "3.8"
|
||||
|
||||
services:
|
||||
mysql:
|
||||
image: mysql:8.0
|
||||
container_name: mysql
|
||||
ports:
|
||||
- "3306:3306"
|
||||
environment:
|
||||
- MYSQL_ROOT_PASSWORD=rootpass
|
||||
- MYSQL_DATABASE=lambdaiot
|
||||
volumes:
|
||||
- ../ai-improved.sql:/docker-entrypoint-initdb.d/init.sql
|
||||
healthcheck:
|
||||
test: ["CMD", "mysqladmin", "ping", "-h", "localhost", "-u", "root", "-prootpass"]
|
||||
interval: 2s
|
||||
timeout: 2s
|
||||
retries: 10
|
||||
|
||||
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
|
||||
healthcheck:
|
||||
test: ["CMD", "mosquitto", "--help"]
|
||||
interval: 2s
|
||||
timeout: 2s
|
||||
retries: 10
|
||||
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"
|
||||
server:
|
||||
build:
|
||||
context: ..
|
||||
@@ -16,45 +52,33 @@ services:
|
||||
- MQTT_TOPIC=lambdaiot
|
||||
- MQTT_USERNAME=testuser
|
||||
- MQTT_PASSWORD=testpass
|
||||
- DB_HOST=mysql
|
||||
- DB_PORT=3306
|
||||
- DB_USER=root
|
||||
- DB_PASSWORD=rootpass
|
||||
depends_on:
|
||||
- mysql
|
||||
- mosquitto
|
||||
# server image now waits for MQTT broker itself via entrypoint
|
||||
healthcheck:
|
||||
test: ["CMD", "curl", "-f", "http://localhost:8080/health"]
|
||||
interval: 10s
|
||||
timeout: 5s
|
||||
retries: 5
|
||||
|
||||
# no command override needed
|
||||
|
||||
mosquitto:
|
||||
image: eclipse-mosquitto:2.0
|
||||
container_name: mosquitto
|
||||
phpmyadmin:
|
||||
image: phpmyadmin/phpmyadmin
|
||||
container_name: phpmyadmin
|
||||
ports:
|
||||
- "1883:1883"
|
||||
volumes:
|
||||
- mosquitto_data:/mosquitto/data
|
||||
- mosquitto_log:/mosquitto/log
|
||||
- ./mosquitto.conf:/mosquitto/config/mosquitto.conf
|
||||
- ./aclfile:/mosquitto/data/aclfile:ro
|
||||
- "8081:80"
|
||||
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"
|
||||
- PMA_HOST=mysql
|
||||
- PMA_PORT=3306
|
||||
- PMA_USER=root
|
||||
- PMA_PASSWORD=rootpass
|
||||
depends_on:
|
||||
- mosquitto
|
||||
- mysql
|
||||
|
||||
volumes:
|
||||
mosquitto_data:
|
||||
|
||||
Reference in New Issue
Block a user