docker compose update

This commit is contained in:
2026-01-11 00:23:45 +00:00
parent af6e3b0ade
commit 8a02c4e836

View File

@@ -1,82 +1,182 @@
# ============================================================================= # =============================================================================
# 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: # Usage:
# # Build the container # # Start all services
# docker compose build # docker compose up
# #
# # Run interactive shell # # Or start individually
# docker compose run --rm simulation # docker compose up gazebo
# docker compose up sitl
# docker compose up controller
# #
# # Run specific command # # Interactive shell
# docker compose run --rm simulation ./scripts/run_ardupilot_sim.sh runway # docker compose run --rm simulation bash
#
# # Stop everything
# docker compose down
# ============================================================================= # =============================================================================
# Common configuration anchor
x-common: &common
image: rdc-simulation:latest
build:
context: .
dockerfile: Dockerfile
# GPU support (NVIDIA)
deploy:
resources:
reservations:
devices:
- driver: nvidia
count: all
capabilities: [ gpu ]
# 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 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
# GPU device
- /dev/dri:/dev/dri:rw
# Network mode for SITL communication (all services share host network)
network_mode: host
# Run as user with access to Wayland socket
user: "1000:1000"
stdin_open: true
tty: true
working_dir: /home/pilot/RDC_Simulation
services: services:
# =========================================================================
# Interactive Shell (for manual control)
# =========================================================================
simulation: simulation:
build: <<: *common
context: .
dockerfile: Dockerfile
image: rdc-simulation:latest
container_name: rdc-sim container_name: rdc-sim
entrypoint: [ "/home/pilot/docker-entrypoint.sh" ]
command: [ "bash" ]
# GPU support (NVIDIA) # =========================================================================
deploy: # Service 1: Gazebo Simulation
resources: # =========================================================================
reservations: gazebo:
devices: <<: *common
- driver: nvidia container_name: rdc-gazebo
count: all entrypoint: [ "/bin/bash", "-c" ]
capabilities: [gpu] 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
# Display forwarding for Gazebo GUI # =========================================================================
environment: # Service 2: ArduPilot SITL
- DISPLAY=${DISPLAY:-:0} # =========================================================================
- NVIDIA_VISIBLE_DEVICES=all sitl:
- NVIDIA_DRIVER_CAPABILITIES=all <<: *common
- QT_X11_NO_MITSHM=1 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
# Mount X11 socket for display # =========================================================================
volumes: # Service 3: Flight Controller
- /tmp/.X11-unix:/tmp/.X11-unix:rw # =========================================================================
- ~/.Xauthority:/home/pilot/.Xauthority:ro 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
# Network mode for SITL communication # =========================================================================
network_mode: host # Headless Mode (CI/Server - no display)
# =========================================================================
# Keep stdin open for interactive use
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)
simulation-headless: simulation-headless:
build: <<: *common
context: .
dockerfile: Dockerfile
image: rdc-simulation:latest
container_name: rdc-sim-headless container_name: rdc-sim-headless
user: "1000:1000"
deploy:
resources:
reservations:
devices:
- driver: nvidia
count: all
capabilities: [gpu]
environment: environment:
- NVIDIA_VISIBLE_DEVICES=all - NVIDIA_VISIBLE_DEVICES=all
- NVIDIA_DRIVER_CAPABILITIES=compute,utility - NVIDIA_DRIVER_CAPABILITIES=compute,utility
- HEADLESS=1 - 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 # All-in-One (runs everything in one container)
tty: true # =========================================================================
working_dir: /home/pilot/RDC_Simulation 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