-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose.yaml
More file actions
84 lines (80 loc) · 2.51 KB
/
docker-compose.yaml
File metadata and controls
84 lines (80 loc) · 2.51 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
x-ros2-common-env: &ros2_common_env
ROS_DOMAIN_ID: "0"
ROS_LOCALHOST_ONLY: "0"
PYTHONUNBUFFERED: "1"
TZ: Asia/Shanghai
x-ros2-common: &ros2_common
build:
context: .
dockerfile: Dockerfile
# 自动适配当前主机架构(不指定 platform 让 Docker 自动检测)
# platform: "linux/amd64" # 如需强制指定架构,取消此行注释并设置目标架构
privileged: true
network_mode: host
# 设备映射(串口和I2C)
# 仅映射存在的设备(即使设备不存在也不会报错)
devices:
# USB串口(适用于所有平台)
- /dev/ttyUSB0:/dev/ttyUSB0
# 树莓派特定串口(在非树莓派平台不存在也不会报错)
- /dev/ttyAMA0:/dev/ttyAMA0
- /dev/ttyAMA1:/dev/ttyAMA1
- /dev/ttyAMA2:/dev/ttyAMA2
- /dev/ttyAMA3:/dev/ttyAMA3
- /dev/ttyAMA4:/dev/ttyAMA4
# I2C总线(适用于树莓派和具有I2C接口的系统)
- /dev/i2c-1:/dev/i2c-1
volumes:
- ./src:/root/ros_ws/src:rw
- ./build:/root/ros_ws/build:rw
- ./install:/root/ros_ws/install:rw
- ./log:/root/ros_ws/log:rw
- ./scripts:/root/ros_ws/scripts:rw
environment:
<<: *ros2_common_env
working_dir: /root/ros_ws
stdin_open: true
tty: true
services:
# 手动调试容器(不会在 dev/production 默认启动)
ros2_servo:
<<: *ros2_common
container_name: ros2_servo_control
command: /bin/bash
restart: unless-stopped
profiles:
- manual
# 本地开发模式服务(启动脚本自动构建并启动系统)
ros2_servo_dev:
<<: *ros2_common
container_name: ros2_dev
# 开发环境默认只映射 USB 串口;如需树莓派板载串口可删除本覆盖配置
devices:
- /dev/ttyUSB0:/dev/ttyUSB0
environment:
<<: *ros2_common_env
DEVELOPMENT_MODE: "1"
LAUNCH_DEBUG: "true"
LAUNCH_IMU_DEBUG: "false"
LAUNCH_MANUAL_PROTOCOL_MAP_FILE: "/root/ros_ws/src/websocket/config/manual_protocol_map.json"
command: bash /root/ros_ws/scripts/init.sh
restart: unless-stopped
profiles:
- dev
# 生产模式服务
ros2_servo_prod:
<<: *ros2_common
container_name: ros2
environment:
<<: *ros2_common_env
LAUNCH_MANUAL_PROTOCOL_MAP_FILE: "/root/ros_ws/src/websocket/config/manual_protocol_map.json"
command: bash /root/ros_ws/scripts/init.sh
restart: always
healthcheck:
test: ["CMD", "ros2", "node", "list"]
interval: 30s
timeout: 10s
retries: 3
start_period: 120s
profiles:
- production