docker compose update
This commit is contained in:
@@ -1,26 +1,33 @@
|
||||
# =============================================================================
|
||||
# RDC Simulation - Docker Compose (GPU-enabled)
|
||||
# RDC Simulation - Docker Compose (GPU-enabled, Wayland, Multi-Service)
|
||||
# =============================================================================
|
||||
# Runs the simulation with GPU acceleration and X11 display forwarding.
|
||||
# Runs the complete simulation stack with 3 services:
|
||||
# 1. gazebo - Gazebo Harmonic simulation
|
||||
# 2. sitl - ArduPilot SITL (ArduCopter)
|
||||
# 3. controller - Python flight controller
|
||||
#
|
||||
# Usage:
|
||||
# # Build the container
|
||||
# docker compose build
|
||||
# # Start all services
|
||||
# docker compose up
|
||||
#
|
||||
# # Run interactive shell
|
||||
# docker compose run --rm simulation
|
||||
# # Or start individually
|
||||
# docker compose up gazebo
|
||||
# docker compose up sitl
|
||||
# docker compose up controller
|
||||
#
|
||||
# # Run specific command
|
||||
# docker compose run --rm simulation ./scripts/run_ardupilot_sim.sh runway
|
||||
# # Interactive shell
|
||||
# docker compose run --rm simulation bash
|
||||
#
|
||||
# # Stop everything
|
||||
# docker compose down
|
||||
# =============================================================================
|
||||
|
||||
services:
|
||||
simulation:
|
||||
# Common configuration anchor
|
||||
x-common: &common
|
||||
image: rdc-simulation:latest
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile
|
||||
image: rdc-simulation:latest
|
||||
container_name: rdc-sim
|
||||
|
||||
# GPU support (NVIDIA)
|
||||
deploy:
|
||||
@@ -31,52 +38,145 @@ services:
|
||||
count: all
|
||||
capabilities: [ gpu ]
|
||||
|
||||
# Display forwarding for Gazebo GUI
|
||||
# Environment variables for Wayland + GPU
|
||||
environment:
|
||||
# Wayland display
|
||||
&common-env
|
||||
- WAYLAND_DISPLAY=${WAYLAND_DISPLAY:-wayland-0}
|
||||
- XDG_RUNTIME_DIR=/run/user/1000
|
||||
# Fallback X11 (XWayland)
|
||||
- DISPLAY=${DISPLAY:-:0}
|
||||
# GPU
|
||||
- NVIDIA_VISIBLE_DEVICES=all
|
||||
- NVIDIA_DRIVER_CAPABILITIES=all
|
||||
# Qt platform - prefer Wayland, fallback to XCB
|
||||
- QT_QPA_PLATFORM=wayland;xcb
|
||||
- QT_WAYLAND_DISABLE_WINDOWDECORATION=1
|
||||
- QT_X11_NO_MITSHM=1
|
||||
# OpenGL
|
||||
- __GLX_VENDOR_LIBRARY_NAME=nvidia
|
||||
- GDK_BACKEND=wayland,x11
|
||||
# Gazebo paths
|
||||
- GZ_SIM_SYSTEM_PLUGIN_PATH=/home/pilot/ardupilot_gazebo/build
|
||||
- GZ_SIM_RESOURCE_PATH=/home/pilot/ardupilot_gazebo/models:/home/pilot/ardupilot_gazebo/worlds:/home/pilot/RDC_Simulation/gazebo/models
|
||||
|
||||
# Mount X11 socket for display
|
||||
# Mount Wayland and X11 sockets
|
||||
volumes:
|
||||
# Wayland socket
|
||||
- ${XDG_RUNTIME_DIR:-/run/user/1000}/${WAYLAND_DISPLAY:-wayland-0}:/run/user/1000/wayland-0:rw
|
||||
# X11 socket (for XWayland fallback)
|
||||
- /tmp/.X11-unix:/tmp/.X11-unix:rw
|
||||
- ~/.Xauthority:/home/pilot/.Xauthority:ro
|
||||
# GPU device
|
||||
- /dev/dri:/dev/dri:rw
|
||||
|
||||
# Network mode for SITL communication
|
||||
# Network mode for SITL communication (all services share host network)
|
||||
network_mode: host
|
||||
|
||||
# Keep stdin open for interactive use
|
||||
# Run as user with access to Wayland socket
|
||||
user: "1000:1000"
|
||||
|
||||
stdin_open: true
|
||||
tty: true
|
||||
|
||||
# Run as current user (optional - for file permission compatibility)
|
||||
# user: "${UID:-1000}:${GID:-1000}"
|
||||
|
||||
working_dir: /home/pilot/RDC_Simulation
|
||||
|
||||
# Alternative: Run headless (no display, for CI/testing)
|
||||
services:
|
||||
# =========================================================================
|
||||
# Interactive Shell (for manual control)
|
||||
# =========================================================================
|
||||
simulation:
|
||||
<<: *common
|
||||
container_name: rdc-sim
|
||||
entrypoint: [ "/home/pilot/docker-entrypoint.sh" ]
|
||||
command: [ "bash" ]
|
||||
|
||||
# =========================================================================
|
||||
# Service 1: Gazebo Simulation
|
||||
# =========================================================================
|
||||
gazebo:
|
||||
<<: *common
|
||||
container_name: rdc-gazebo
|
||||
entrypoint: [ "/bin/bash", "-c" ]
|
||||
command:
|
||||
- |
|
||||
source /opt/ros/jazzy/setup.bash
|
||||
source ~/.bashrc
|
||||
echo "Starting Gazebo Harmonic..."
|
||||
echo "Waiting 5 seconds for initialization..."
|
||||
sleep 5
|
||||
cd /home/pilot/RDC_Simulation
|
||||
./scripts/run_ardupilot_sim.sh runway
|
||||
|
||||
# =========================================================================
|
||||
# Service 2: ArduPilot SITL
|
||||
# =========================================================================
|
||||
sitl:
|
||||
<<: *common
|
||||
container_name: rdc-sitl
|
||||
depends_on:
|
||||
gazebo:
|
||||
condition: service_started
|
||||
entrypoint: [ "/bin/bash", "-c" ]
|
||||
command:
|
||||
- |
|
||||
source /opt/ros/jazzy/setup.bash
|
||||
source ~/.bashrc
|
||||
echo "Waiting 15 seconds for Gazebo to start..."
|
||||
sleep 15
|
||||
echo "Starting ArduPilot SITL..."
|
||||
cd /home/pilot/ardupilot
|
||||
sim_vehicle.py -v ArduCopter -f gazebo-iris --model JSON --console --no-mavproxy
|
||||
|
||||
# =========================================================================
|
||||
# Service 3: Flight Controller
|
||||
# =========================================================================
|
||||
controller:
|
||||
<<: *common
|
||||
container_name: rdc-controller
|
||||
depends_on:
|
||||
sitl:
|
||||
condition: service_started
|
||||
entrypoint: [ "/bin/bash", "-c" ]
|
||||
command:
|
||||
- |
|
||||
source /opt/ros/jazzy/setup.bash
|
||||
source ~/.bashrc
|
||||
source /home/pilot/RDC_Simulation/venv/bin/activate
|
||||
echo "Waiting 30 seconds for SITL to initialize..."
|
||||
sleep 30
|
||||
echo "Starting flight controller..."
|
||||
cd /home/pilot/RDC_Simulation
|
||||
python scripts/run_ardupilot.py --pattern square
|
||||
|
||||
# =========================================================================
|
||||
# Headless Mode (CI/Server - no display)
|
||||
# =========================================================================
|
||||
simulation-headless:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile
|
||||
image: rdc-simulation:latest
|
||||
<<: *common
|
||||
container_name: rdc-sim-headless
|
||||
|
||||
deploy:
|
||||
resources:
|
||||
reservations:
|
||||
devices:
|
||||
- driver: nvidia
|
||||
count: all
|
||||
capabilities: [gpu]
|
||||
|
||||
user: "1000:1000"
|
||||
environment:
|
||||
- NVIDIA_VISIBLE_DEVICES=all
|
||||
- NVIDIA_DRIVER_CAPABILITIES=compute,utility
|
||||
- HEADLESS=1
|
||||
- LIBGL_ALWAYS_SOFTWARE=1
|
||||
- GZ_SIM_SYSTEM_PLUGIN_PATH=/home/pilot/ardupilot_gazebo/build
|
||||
- GZ_SIM_RESOURCE_PATH=/home/pilot/ardupilot_gazebo/models:/home/pilot/ardupilot_gazebo/worlds:/home/pilot/RDC_Simulation/gazebo/models
|
||||
volumes: [] # No display mounts needed
|
||||
entrypoint: [ "/home/pilot/docker-entrypoint.sh" ]
|
||||
command: [ "bash" ]
|
||||
|
||||
network_mode: host
|
||||
stdin_open: true
|
||||
tty: true
|
||||
working_dir: /home/pilot/RDC_Simulation
|
||||
# =========================================================================
|
||||
# All-in-One (runs everything in one container)
|
||||
# =========================================================================
|
||||
all-in-one:
|
||||
<<: *common
|
||||
container_name: rdc-all
|
||||
entrypoint: [ "/bin/bash", "-c" ]
|
||||
command:
|
||||
- |
|
||||
source /opt/ros/jazzy/setup.bash
|
||||
source ~/.bashrc
|
||||
source /home/pilot/RDC_Simulation/venv/bin/activate
|
||||
cd /home/pilot/RDC_Simulation
|
||||
echo "Starting all-in-one simulation..."
|
||||
./scripts/run_ardupilot_controller.sh
|
||||
|
||||
Reference in New Issue
Block a user