-
Notifications
You must be signed in to change notification settings - Fork 4
/
Dockerfile
88 lines (76 loc) · 2.52 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
# syntax=docker/dockerfile:1
ARG ROS_DISTRO="humble"
FROM ros:${ROS_DISTRO}-ros-base AS upstream
# Restate for later use
ARG ROS_DISTRO
ARG REPO
# prevent interactive messages in apt install
ARG DEBIAN_FRONTEND=noninteractive
# install development tools
RUN apt-get update \
&& apt-get install -q -y --no-install-recommends \
apt-utils \
ccache \
clang \
cmake \
git \
lld \
llvm \
python3-colcon-mixin \
python3-colcon-common-extensions \
python3-colcon-lcov-result \
python3-colcon-coveragepy-result \
python3-colcon-mixin \
python3-pip \
python3-rosdep \
python3-vcstool \
wget \
&& rm -rf /var/lib/apt/lists/*
# copy source to install repo dependencies
WORKDIR /ws
COPY . ./src/${REPO}
# install repo dependencies
RUN rosdep update && apt-get update \
&& rosdep install -q -y \
--from-paths src \
--ignore-src \
--rosdistro ${ROS_DISTRO} \
&& rm -rf /var/lib/apt/lists/*
FROM upstream AS development
ARG UID
ARG GID
ARG USER
# fail build if args are missing
# hadolint ignore=SC2028
RUN if [ -z "$UID" ]; then echo '\nERROR: UID not set. Run \n\n \texport UID=$(id -u) \n\n on host before building Dockerfile.\n'; exit 1; fi
# hadolint ignore=SC2028
RUN if [ -z "$GID" ]; then echo '\nERROR: GID not set. Run \n\n \texport GID=$(id -g) \n\n on host before building Dockerfile.\n'; exit 1; fi
# hadolint ignore=SC2028
RUN if [ -z "$USER" ]; then echo '\nERROR: USER not set. Run \n\n \texport USER=$(whoami) \n\n on host before building Dockerfile.\n'; exit 1; fi
# install developer tools
RUN --mount=type=cache,target=/var/cache/apt,id=apt \
apt-get update && apt-get upgrade -y \
&& apt-get install -q -y --no-install-recommends \
clang-format \
clang-tidy \
git \
openssh-client \
vim \
wget \
&& rm -rf /var/lib/apt/lists/*
RUN python3 -m pip install --no-cache-dir \
pre-commit==3.0.4
# Setup user home directory
# --no-log-init helps with excessively long UIDs
RUN groupadd --gid $GID $USER \
&& useradd --no-log-init --uid $GID --gid $UID -m $USER --groups sudo \
&& echo $USER ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USER \
&& chmod 0440 /etc/sudoers.d/$USER \
&& echo "source /opt/ros/${ROS_DISTRO}/setup.bash" >> /home/${USER}/.profile \
&& touch /home/${USER}/.bashrc \
&& chown -R ${GID}:${UID} /home/${USER}
USER $USER
ENV SHELL /bin/bash
ENTRYPOINT []
# Setup mixin
WORKDIR /home/${USER}/ws