Skip to content

Commit

Permalink
feat: Add ROS 2 Iron (#56)
Browse files Browse the repository at this point in the history
  • Loading branch information
Tiryoh committed May 26, 2024
1 parent 31c2fe7 commit 7d3b045
Show file tree
Hide file tree
Showing 5 changed files with 117 additions and 6 deletions.
9 changes: 3 additions & 6 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,8 @@ updates:
- "Type: CI"

- package-ecosystem: "docker"
directory: "/foxy"
schedule:
interval: "daily"

- package-ecosystem: "docker"
directory: "/humble"
directories:
- "/humble"
- "/iron"
schedule:
interval: "daily"
1 change: 1 addition & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ jobs:
- foxy
- galactic
- humble
- iron

steps:
- name: Checkout
Expand Down
15 changes: 15 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,23 @@ jobs:
- foxy
- galactic
- humble
- iron

steps:
- name: Free Up GitHub Actions Ubuntu Runner Disk Space
uses: hirnidrin/free-disk-space@main
# uses: jlumbroso/free-disk-space@main
with:
# This might remove tools that are actually needed, if set to "true" but frees about 6 GB
tool-cache: false
# All of these default to true, but feel free to set to "false" if necessary for your workflow
android: true
dotnet: true
haskell: true
large-packages: true
docker-images: false
swap-storage: true

- name: Checkout
uses: actions/checkout@v3

Expand Down
36 changes: 36 additions & 0 deletions iron/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
FROM ubuntu:jammy-20240427 AS builder
RUN apt-get update
RUN apt-get install -y curl
RUN apt-get install -y --no-install-recommends gcc libc-dev
RUN curl -o /usr/local/bin/su-exec.c https://raw.githubusercontent.com/ncopa/su-exec/master/su-exec.c
RUN gcc -Wall /usr/local/bin/su-exec.c -o/usr/local/bin/su-exec
RUN chown root:root /usr/local/bin/su-exec
RUN chmod 0755 /usr/local/bin/su-exec


FROM ubuntu:jammy-20240427
ARG TARGETPLATFORM
LABEL maintainer="Daisuke Sato <tiryoh@gmail.com>"
RUN apt-get update -q && \
apt-get upgrade -yq && \
DEBIAN_FRONTEND=noninteractive apt-get install -yq --no-install-recommends keyboard-configuration language-pack-en && \
DEBIAN_FRONTEND=noninteractive apt-get install -yq --no-install-recommends wget curl git build-essential ca-certificates tzdata tmux gnupg2 \
vim sudo lsb-release locales bash-completion zsh iproute2 iputils-ping net-tools dnsutils && \
rm -rf /var/lib/apt/lists/*
ENV LANG=en_US.UTF-8 LANGUAGE=en_US:en LC_ALL=en_US.UTF-8
RUN locale-gen en_US.UTF-8
ENV ROS_DISTRO=iron
RUN 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 $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/ros2.list > /dev/null && \
apt-get update && \
apt-get install -y --no-install-recommends ros-${ROS_DISTRO}-desktop && \
apt-get install -y --no-install-recommends python3-argcomplete python3-colcon-common-extensions python3-rosdep python3-colcon-mixin python3-vcstool && \
if [ ! "$TARGETPLATFORM" = "linux/arm64" ]; then apt-get install -y --no-install-recommends ros-${ROS_DISTRO}-gazebo-ros-pkgs; fi && \
apt-get install -y --no-install-recommends ros-${ROS_DISTRO}-xacro ros-${ROS_DISTRO}-joint-state-publisher-gui && \
rm -rf /var/lib/apt/lists/*
RUN rosdep init && \
rosdep update
COPY --from=builder /usr/local/bin/su-exec /sbin/
COPY ./ros_entrypoint.sh /
ENTRYPOINT ["/ros_entrypoint.sh"]
CMD ["/bin/bash"]
62 changes: 62 additions & 0 deletions iron/ros_entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
#!/bin/bash
set -e

DEFAULT_USER=${DEFAULT_USER:-'ubuntu'}
DEFAULT_USER_UID=${USER_UID:-'1000'}
DEFAULT_USER_GID=${USER_GID:-'1000'}
NOPASSWD=${NOPASSWD:-''} # set 'NOPASSWD:' to disable asking sudo password

if [[ $(id -u) -eq 0 ]]; then
echo "Set disable_coredump false" >> /etc/sudo.conf
else
echo "Set disable_coredump false" | sudo tee -a /etc/sudo.conf > /dev/null
fi

# override if $USER env exists
if [[ ! -z "$USER" ]]; then
DEFAULT_USER=$USER
fi

# create development user
if [[ $(id -u) -eq 0 ]]; then
EXEC="exec /sbin/su-exec ${DEFAULT_USER}"

# create_user
if [[ ! -e /home/${DEFAULT_USER} ]]; then
groupadd -g "${DEFAULT_USER_GID}" "${DEFAULT_USER}"
useradd --create-home --home-dir /home/${DEFAULT_USER} --uid ${DEFAULT_USER_UID} --shell /bin/bash \
--gid ${DEFAULT_USER_GID} --groups sudo ${DEFAULT_USER}
echo "${DEFAULT_USER}:${DEFAULT_USER}" | chpasswd && \
echo "${DEFAULT_USER} ALL=(ALL) ${NOPASSWD}ALL" >> /etc/sudoers
touch /home/${DEFAULT_USER}/.sudo_as_admin_successful
fi

# setup ros environment
mkdir -p /home/${DEFAULT_USER}/ros2_ws/src \
echo 'source /opt/ros/${ROS_DISTRO}/setup.bash' >> /home/${DEFAULT_USER}/.bashrc

chown -R ${DEFAULT_USER}:${DEFAULT_USER} /home/${DEFAULT_USER}

# mount develop workspace
if [ -e /ws ]; then
ln -s /ws /home/${DEFAULT_USER}/ros2_ws/src
fi

DEFAULT_USER_UID="$(${EXEC} id -u)"
DEFAULT_USER_GID="$(${EXEC} id -g)"
else # use existing user
EXEC="exec"
DEFAULT_USER="$(whoami)"
DEFAULT_USER_UID="$(id -u)"
DEFAULT_USER_GID="$(id -g)"
fi

echo "Launched container with user: $DEFAULT_USER, uid: $DEFAULT_USER_UID, gid: $DEFAULT_USER_GID"

if which "$1" > /dev/null 2>&1 ; then
source /opt/ros/${ROS_DISTRO}/setup.bash
$EXEC "$@"
else
echo $@ | $EXEC $SHELL -li
fi

0 comments on commit 7d3b045

Please sign in to comment.