-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
executable file
·114 lines (93 loc) · 3.12 KB
/
Dockerfile
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
# Dockerfile for building ROS 2 environments on the Ubuntu.
# Defaults to iron.
ARG ROS_DISTRO=iron
# Override these
ARG USERNAME=dev
ARG USER_UID=1000
ARG USER_GID=1000
# Base ROS image
FROM ubuntu:jammy AS ros-base
# Fast fail on random bash commands
SHELL [ "/bin/bash", "-o", "pipefail", "-c" ]
ARG ROS_DISTRO
ARG SYNC_DATESTAMP
ARG DEBIAN_FRONTEND=noninteractive
ENV ROS_DISTRO ${ROS_DISTRO}
ENV LANG C.UTF-8
ENV LC_ALL C.UTF-8
# setup timezone
RUN echo 'Etc/UTC' > /etc/timezone && \
ln -s /usr/share/zoneinfo/Etc/UTC /etc/localtime
# Install base deps
RUN apt-get update && \
apt-get install -q -y --no-install-recommends tzdata \
software-properties-common \
locales \
curl \
git \
dirmngr \
lsb-release \
wget \
gnupg2 \
sudo
# Enable zram for goodness' sake
RUN apt-get install -q -y --no-install-recommends zram-config
# Install ros
RUN sudo curl -sSL https://raw.githubusercontent.com/ros/rosdistro/master/ros.key -o /usr/share/keyrings/ros-archive-keyring.gpg
RUN 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" | sudo tee /etc/apt/sources.list.d/ros2-${ROS_DISTRO}.list > /dev/null
RUN apt-get update && apt-get install -y --no-install-recommends \
ros-${ROS_DISTRO}-ros-core \
ros-${ROS_DISTRO}-ros-base
# Overlay developer setup
FROM ros-base AS ros-develop
ARG USERNAME=dev
ARG USER_UID=1000
ARG USER_GID=1000
ARG USER_HOME=/home/${USERNAME}/
ENV USER_HOME=${USER_HOME}
WORKDIR $USER_HOME
# Create a new user
RUN groupadd --gid $USER_GID ${USERNAME} && \
useradd --uid $USER_UID --gid $USER_GID --shell /bin/bash --create-home ${USERNAME} && \
mkdir -p \
/home/${USERNAME}/.ccache \
/home/${USERNAME}/.colcon \
/home/${USERNAME}/.ros
# Give them passwordless root
RUN echo ${USERNAME} ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/${USERNAME} && \
chmod 0440 /etc/sudoers.d/${USERNAME}
USER ${USERNAME}
# Install additional dev tools
RUN sudo apt-get update && \
sudo apt-get install -q -y --no-install-recommends \
git \
git-lfs \
build-essential \
python3-colcon-common-extensions \
python3-colcon-mixin \
python3-rosdep \
python3-vcstool \
lld \
vim \
ccache \
clang \
clangd \
less
# Add defaults and update userhome perms
COPY colcon-defaults.yaml ${USER_HOME}/.colcon/defaults.yaml
RUN sudo chown -R ${USERNAME}:${USERNAME} ${USER_HOME}
# Set up colcon
RUN colcon mixin add default \
https://raw.githubusercontent.com/colcon/colcon-mixin-repository/master/index.yaml && \
colcon mixin update && \
colcon metadata add default \
https://raw.githubusercontent.com/colcon/colcon-metadata-repository/master/index.yaml && \
colcon metadata update
# Do sad things
RUN sudo rosdep init && rosdep update --rosdistro ${ROS_DISTRO}
# Set the entrypoint
COPY entrypoint.sh /entrypoint.sh
RUN sudo chmod a+x /entrypoint.sh
RUN echo "source /entrypoint.sh" >> ~/.bashrc
ENTRYPOINT ["/entrypoint.sh"]