-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
184 lines (176 loc) · 6.4 KB
/
Copy pathdocker-compose.yml
File metadata and controls
184 lines (176 loc) · 6.4 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
services:
compose-banner:
image: alpine:3.20
container_name: vending-compose-banner
restart: "no"
command:
- /bin/sh
- -lc
- |
printf '\n'
printf '=============================================================================\n'
printf ' Published URLs from host (default port mapping)\n'
printf '-----------------------------------------------------------------------------\n'
printf ' db (MySQL) localhost:3307 -> container :3306\n'
printf ' server (API) http://localhost:8000 (Flask + Socket.IO + /apidocs)\n'
printf ' client (agent) http://localhost:5000\n'
printf ' machine-ui http://localhost:3000\n'
printf ' admin-ui http://localhost:3001\n'
printf ' web-ui http://localhost:3002\n'
printf ' swagger-ui http://localhost:8081 (host; avoids Jenkins on 8080)\n'
printf '=============================================================================\n'
printf '\n'
db:
image: mysql:8
container_name: vending-db
command: --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci
environment:
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: vending
TZ: Asia/Bangkok
volumes:
- db_data:/var/lib/mysql
- ./database/init.sql:/docker-entrypoint-initdb.d/init.sql:ro
ports:
- "3307:3306"
healthcheck:
test:
["CMD", "mysqladmin", "ping", "-h", "localhost", "-u", "root", "-proot"]
interval: 5s
timeout: 10s
retries: 30
start_period: 20s
server:
build: ./server
volumes:
- ./web/web-ui/build:/app/web-build
- ./swagger.yaml:/app/swagger.yaml
- ./server/static/product/img:/app/static/product/img
container_name: vending-server
env_file:
- .env
environment:
- SOCKETIO_ENABLED=1
- AGENT_BASE_URL=${AGENT_BASE_URL:-http://client:5000}
- KIOSK_SOCKET_SECRET=${KIOSK_SOCKET_SECRET:-dev-kiosk-secret-change-in-production}
- TZ=Asia/Bangkok
# Set comma-separated allowed origins for CORS.
# Override via .env when running on LAN / hardware.
- CORS_ORIGINS=${CORS_ORIGINS:-http://localhost:3000,http://localhost:3001,http://localhost:3002,http://localhost:8081,http://server:8000,http://machine-ui:3000,http://admin-ui:3000,http://web-ui:3000,http://192.168.1.44:3000,http://192.168.1.172:3000}
- DOCKER_URL_SERVER=http://localhost:8000
- DOCKER_URL_MACHINE_UI=http://localhost:3000
- DOCKER_URL_ADMIN_UI=http://localhost:3001
- DOCKER_URL_WEB_UI=http://localhost:3002
- DOCKER_URL_SWAGGER=http://localhost:8081
- DOCKER_URL_AGENT=http://localhost:5000
- DOCKER_URL_DB=mysql://localhost:3307
- DOCKER_PUBLISHED_PORT_SERVER=8000
- PRODUCT_IMAGES_DIR=/app/static/product/img
# Set OMISE_WEBHOOK_SECRET to your Omise webhook signing secret for production security
# - OMISE_WEBHOOK_SECRET=your_webhook_secret_here
ports:
- "8000:8000"
healthcheck:
test: ["CMD", "python", "-c", "import urllib.request; urllib.request.urlopen('http://localhost:8000/health', timeout=5)"]
interval: 15s
timeout: 5s
retries: 3
start_period: 10s
depends_on:
db:
condition: service_healthy
client:
build: ./client/agent
container_name: vending-pi
privileged: true
ports:
- "5000:5000"
volumes:
- agent_data:/data
- /dev/gpiomem:/dev/gpiomem
environment:
- SENSOR_MODE=${SENSOR_MODE:-mock}
# Prefer docker service DNS in compose; override via .env for LAN / hardware.
- SERVER_SOCKET_URL=${SERVER_SOCKET_URL:-http://server:8000}
# Must match a row in `machines`; token from Admin โ’ Create machine (plaintext once).
- MACHINE_CODE=${MACHINE_CODE:-MP1-001}
- MACHINE_TOKEN=${MACHINE_TOKEN:-}
- AGENT_DB_PATH=/data/agent.db
- TZ=Asia/Bangkok
- DOCKER_URL_AGENT=http://localhost:5000
- DOCKER_URL_SERVER=http://localhost:8000
- DOCKER_PUBLISHED_PORT_AGENT=5000
machine-ui:
build:
context: ./web/machine-ui
args:
- NEXT_PUBLIC_OMISE_PUBLIC_KEY=${NEXT_PUBLIC_OMISE_PUBLIC_KEY}
- NEXT_PUBLIC_API_URL=${NEXT_PUBLIC_API_URL:-http://localhost:8000}
- NEXT_PUBLIC_AGENT_BASE_URL=${NEXT_PUBLIC_AGENT_BASE_URL:-http://localhost:5000}
- NEXT_PUBLIC_SERVER_SOCKET_URL=${NEXT_PUBLIC_SERVER_SOCKET_URL:-}
- NEXT_PUBLIC_KIOSK_SOCKET_SECRET=${KIOSK_SOCKET_SECRET:-dev-kiosk-secret-change-in-production}
- NEXT_PUBLIC_MACHINE_CODE=${NEXT_PUBLIC_MACHINE_CODE:-MP1-001}
environment:
- TZ=Asia/Bangkok
- DOCKER_PUBLISHED_PORT=3000
- DOCKER_HOST_URL=http://localhost:3000
container_name: vending-machine-ui
ports:
- "3000:3000"
depends_on:
- server
admin-ui:
build:
context: ./web/admin-ui
args:
- NEXT_PUBLIC_ADMIN_API_URL=${NEXT_PUBLIC_ADMIN_API_URL:-http://localhost:8000}
environment:
- TZ=Asia/Bangkok
- DOCKER_PUBLISHED_PORT=3001
- DOCKER_HOST_URL=http://localhost:3001
container_name: vending-admin-ui
ports:
- "3001:3000"
depends_on:
- server
web-ui:
build:
context: ./web/web-ui
args:
- NEXT_PUBLIC_API_URL=${NEXT_PUBLIC_API_URL:-http://localhost:8000}
- NEXT_PUBLIC_MACHINE_CODE=${NEXT_PUBLIC_MACHINE_CODE:-MP1-001}
- NEXT_PUBLIC_OMISE_PUBLIC_KEY=${NEXT_PUBLIC_OMISE_PUBLIC_KEY}
environment:
- TZ=Asia/Bangkok
- DOCKER_PUBLISHED_PORT=3002
- DOCKER_HOST_URL=http://localhost:3002
# Middleware JWT verification โ€” must match server JWT_SECRET
- JWT_SECRET=${JWT_SECRET}
container_name: vending-web-ui
ports:
- "3002:3000"
depends_on:
- server
swagger-ui:
image: swaggerapi/swagger-ui:v5.32.1
container_name: vending-swagger-ui
ports:
- "8081:8080"
environment:
URL: /openapi.yaml
volumes:
- ./swagger.yaml:/usr/share/nginx/html/openapi.yaml:ro
depends_on:
- server
command:
- /bin/sh
- -c
- |
printf '\n=== vending-swagger-ui ===\n'
printf ' Host browser: http://localhost:8081\n'
printf ' Local (in container): http://127.0.0.1:8080\n'
printf ' Network (listen): http://0.0.0.0:8080\n\n'
exec /docker-entrypoint.sh nginx -g 'daemon off;'
volumes:
db_data:
agent_data: