File size: 5,032 Bytes
700dd75
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
# Multi-architecture Dockerfile for NVIDIA CUDA
# Supports linux/amd64 and linux/arm64
FROM nvidia/cuda:12.4.0-runtime-ubuntu22.04

# Build info - ARGs need to be redeclared after FROM to use in RUN commands
ARG TARGETPLATFORM
ARG BUILDPLATFORM
RUN echo "Building for $TARGETPLATFORM on $BUILDPLATFORM"

# Avoid prompts from apt
ENV DEBIAN_FRONTEND=noninteractive

# Install minimal system dependencies
RUN apt-get update && \
    apt-get install -y \
    # Basic tools
    build-essential \
    curl \
    gdb \
    git \
    git-lfs \
    net-tools \
    sudo \
    wget \
    iputils-ping \
    vim \
    unzip \
    # System services
    udev \
    # Graphics and X11
    libgl1-mesa-dri \
    libgl1-mesa-glx \
    libglu1-mesa \
    mesa-utils \
    libxcb-cursor0 \
    x11-apps \
    xauth \
    # EGL and GPU access
    libegl1 \
    libegl1-mesa \
    libegl1-mesa-dev \
    libgl1-mesa-dev \
    libgles2-mesa-dev \
    libglvnd-dev \
    mesa-common-dev \
    # XCB and Qt platform dependencies
    libxcb-icccm4 \
    libxcb-image0 \
    libxcb-keysyms1 \
    libxcb-randr0 \
    libxcb-render-util0 \
    libxcb-shape0 \
    libxcb-xfixes0 \
    libxcb-xinerama0 \
    libxcb-xinput0 \
    libxcb-xkb1 \
    libxkbcommon-x11-0 \
    # D-Bus and system dependencies
    libdbus-1-3 \
    # Other dependencies
    libncurses5-dev \
    libudev-dev \
    libusb-1.0-0-dev \
    # Python 3.10 and pip
    python3.10 \
    python3.10-venv \
    python3.10-distutils \
    python3-pip \
    expect \
    # ffmpeg and related libraries
    ffmpeg \
    libavcodec-dev \
    libavformat-dev \
    libavdevice-dev \
    libavfilter-dev \
    libavutil-dev \
    libswresample-dev \
    libswscale-dev \
    # opencv
    libgtk2.0-dev \
    # Clean up
    && rm -rf /var/lib/apt/lists/*

# --- Install ROS 2 Humble (following official instructions) ---
# Enable required repositories
RUN apt-get update && apt-get install -y software-properties-common \
    && add-apt-repository universe \
    # Add ROS 2 GPG key and repository
    && apt-get install -y curl gnupg lsb-release \
    && curl -sSL https://raw.githubusercontent.com/ros/rosdistro/master/ros.key -o /usr/share/keyrings/ros-archive-keyring.gpg \
    && echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/ros-archive-keyring.gpg] http://packages.ros.org/ros2/ubuntu $(. /etc/os-release && echo $UBUNTU_CODENAME) main" > /etc/apt/sources.list.d/ros2.list \
    # Upgrade system to avoid removal of critical packages (see ROS 2 docs)
    && apt-get update \
    && apt-get upgrade -y \
    # Install ROS 2 Humble desktop
    && apt-get install -y ros-humble-desktop \
    # (Optional) Install development tools
    && apt-get install -y ros-dev-tools \
    # Install Eclipse Cyclone DDS RMW implementation
    && apt-get install -y ros-humble-rmw-cyclonedds-cpp \
    # Clean up
    && rm -rf /var/lib/apt/lists/*

# Source ROS 2 setup in bashrc for all users
RUN echo 'source /opt/ros/humble/setup.bash' >> /etc/bash.bashrc

# Clone, build, and install CycloneDDS 0.10.x
RUN git clone --branch releases/0.10.x https://github.com/eclipse-cyclonedds/cyclonedds /opt/cyclonedds && \
    mkdir -p /opt/cyclonedds/build /opt/cyclonedds/install && \
    cd /opt/cyclonedds/build && \
    cmake .. -DCMAKE_INSTALL_PREFIX=../install && \
    cmake --build . --target install && \
    # Clean up build files to reduce image size
    rm -rf /opt/cyclonedds/build

# Set CYCLONEDDS_HOME for all users
ENV CYCLONEDDS_HOME=/opt/cyclonedds/install

# Install uv
RUN curl -LsSf https://astral.sh/uv/install.sh | env UV_INSTALL_DIR=/opt/uv sh

# Add uv to PATH
ENV PATH="/opt/uv:$PATH"
ENV UV_PYTHON=/opt/venv/bin/python

# Fix dpkg state and install tmux
RUN dpkg --configure -a && apt-get update && apt-get install -y tmux && rm -rf /var/lib/apt/lists/*

# Create NVIDIA ICD config for EGL if it doesn't exist
# Note: This might need platform-specific handling for ARM64
RUN if [ ! -f /usr/share/glvnd/egl_vendor.d/10_nvidia.json ]; then \
    mkdir -p /usr/share/glvnd/egl_vendor.d && \
    printf '{\n    "file_format_version" : "1.0.0",\n    "ICD" : {\n        "library_path" : "libEGL_nvidia.so.0"\n    }\n}' | tee /usr/share/glvnd/egl_vendor.d/10_nvidia.json > /dev/null; \
    fi

# Platform-specific configurations
RUN case "$TARGETPLATFORM" in \
    "linux/arm64") \
        echo "Configuring for ARM64 platform" && \
        # Add any ARM64-specific configurations here
        echo "export GPU_FORCE_64BIT_PTR=1" >> /etc/environment \
        ;; \
    "linux/amd64") \
        echo "Configuring for AMD64 platform" && \
        # Add any AMD64-specific configurations here
        echo "AMD64 platform configured" \
        ;; \
    *) \
        echo "Unknown platform: $TARGETPLATFORM" \
        ;; \
    esac

# Add labels for better image management
LABEL org.opencontainers.image.title="Multi-Arch CUDA Runtime with ROS 2 Humble"
LABEL org.opencontainers.image.description="Multi-architecture Docker image with CUDA runtime and ROS 2 Humble"