-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
48 lines (47 loc) · 1.5 KB
/
docker-compose.yml
File metadata and controls
48 lines (47 loc) · 1.5 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
version: '3.8'
services:
modbusim:
build: .
env_file:
- .env.docker
ports:
- "5020:5020"
volumes:
- .:/app
# Map the host's serial device to the container (only for RTU mode)
- /dev/ttyACM0:/dev/ttyACM0
devices:
- "/dev/ttyACM0:/dev/ttyACM0"
environment:
- PYTHONUNBUFFERED=1
- MODBUS_MODE=${MODBUS_MODE:-rtu}
- MODBUS_PORT=${MODBUS_PORT:-/dev/ttyACM0}
- MODBUS_BAUDRATE=${MODBUS_BAUDRATE:-9600}
- MODBUS_TIMEOUT=${MODBUS_TIMEOUT:-1.0}
- MODBUS_STOPBITS=${MODBUS_STOPBITS:-1}
- MODBUS_BYTESIZE=${MODBUS_BYTESIZE:-8}
- MODBUS_PARITY=${MODBUS_PARITY:-N}
- MODBUS_HOST=${MODBUS_HOST:-0.0.0.0}
- MODBUS_TCP_PORT=${MODBUS_TCP_PORT:-5020}
command: >
sh -c "if [ \"$${MODBUS_MODE}\" = \"rtu\" ]; then
poetry run modbusim rtu \
--port $${MODBUS_PORT} \
--baudrate $${MODBUS_BAUDRATE} \
--timeout $${MODBUS_TIMEOUT} \
--stopbits $${MODBUS_STOPBITS} \
--bytesize $${MODBUS_BYTESIZE} \
--parity $${MODBUS_PARITY}
else
poetry run modbusim tcp \
--host $${MODBUS_HOST} \
--port $${MODBUS_TCP_PORT}
fi"
healthcheck:
test: ["CMD", "/healthcheck.sh"]
interval: 30s
timeout: 10s
retries: 3
start_period: 5s
privileged: true # Required for accessing serial devices
restart: unless-stopped