-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
executable file
·92 lines (89 loc) · 3.16 KB
/
docker-compose.yml
File metadata and controls
executable file
·92 lines (89 loc) · 3.16 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
services:
frontend:
build:
context: .
dockerfile: ./frontend/Dockerfile
# No build args needed if socketService connects relatively
ports:
# Map host port 8080 to container port 80 (Nginx)
# Access frontend via http://localhost:8080
- "2001:80"
restart: unless-stopped
env_file:
- .env
depends_on:
backend: # Ensures backend starts before frontend attempts connection
condition: service_healthy
mqtt:
condition: service_started # Or service_healthy if mqtt has a healthcheck
networks:
- splitflap-net
container_name: splitflap-frontend # Optional: Assign a specific container name
backend:
build:
context: .
dockerfile: ./backend/Dockerfile
expose:
- "3001" # Align with backend application port
networks:
splitflap-net:
aliases:
- backend # Ensure this hostname is accessible in the network
# Add healthcheck to ensure the service is running properly
healthcheck:
test: ["CMD", "wget", "--spider", "-q", "http://backend:3001/health"]
interval: 10s
timeout: 5s
retries: 3
start_period: 5s
env_file:
# Load environment variables from .env file in root directory
- .env
environment:
- SPLITFLAP_DISPLAY_LENGTH=${SPLITFLAP_DISPLAY_LENGTH:-12}
volumes:
# Mount scenes directory for persistence and easy editing
- ./backend/scenes:/app/scenes
# Optional: Mount logs directory if your app writes logs to a specific folder
# - ./backend/logs:/app/logs
restart: unless-stopped
container_name: splitflap-backend # Optional: Assign a specific container name
user: "3000"
depends_on:
mqtt:
condition: service_started # Or service_healthy if you add a healthcheck to mqtt
mqtt:
image: emqx/emqx:latest # Using latest EMQX image
container_name: splitflap-emqx
ports:
- "1883:1883" # MQTT
- "8083:8083" # MQTT over WebSockets
- "8084:8084" # MQTT over SSL/TLS WebSockets
- "8883:8883" # MQTT over SSL/TLS
- "18083:18083" # EMQX Dashboard
volumes:
- ./emqx/data:/opt/emqx/data
- ./emqx/log:/opt/emqx/log
# - ./emqx/etc:/opt/emqx/etc # Uncomment to persist configuration
environment:
EMQX_LOADED_PLUGINS: "emqx_dashboard,emqx_management" # Ensure dashboard is enabled
# Disable anonymous authentication on default listeners
EMQX_LISTENERS__TCP__DEFAULT__ALLOW_ANONYMOUS: "false"
EMQX_LISTENERS__WS__DEFAULT__ALLOW_ANONYMOUS: "false"
# Bootstrap a default user for MQTT.
# IMPORTANT: Change 'mqttpassword' in your .env file and consider managing users via EMQX Dashboard.
EMQX_BOOTSTRAP_USERS__1__USERNAME: "splitflap_user"
EMQX_BOOTSTRAP_USERS__1__PASSWORD: "mqttpassword" # EMQX will hash this using its default algorithm.
networks:
- splitflap-net
restart: unless-stopped
healthcheck:
test: ["CMD", "/opt/emqx/bin/emqx_ctl", "status"]
interval: 30s
timeout: 10s
retries: 3
start_period: 60s # EMQX can take a bit to start
user: "3000"
networks:
splitflap-net:
driver: bridge