-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
117 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,6 +29,7 @@ jobs: | |
- foxy | ||
- galactic | ||
- humble | ||
- iron | ||
|
||
steps: | ||
- name: Checkout | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|