-
Notifications
You must be signed in to change notification settings - Fork 2
/
Dockerfile
117 lines (92 loc) · 3.66 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
115
116
117
FROM ubuntu:20.04
LABEL maintainer="Minhyun Cho <[email protected]>"
# environment variables to set pacakge manager
ENV DEBIAN_FRONTEND=noninteractive
ENV TZ=America/New_York
RUN echo 'debconf debconf/frontend select Noninteractive' | debconf-set-selections
# environment variable to designate the directory where temporary files and sockets are stored and accessible
ENV XDG_RUNTIME_DIR=/tmp/runtime-docker
# environment variables to enable the use of NVIDIA GPU
# ref. https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/latest/docker-specialized.html
ENV NVIDIA_VISIBLE_DEVICES=all
ENV NVIDIA_DRIVER_CAPABILITIES=all
# add bin folder as environmental variable
ENV PATH="/home/user/bin:${PATH}"
# protobuff related environmental variable
ENV PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python
# set default shell during Docker image build to bash
SHELL ["/bin/bash", "-l", "-c"]
# install base packages to run bash scripts
RUN apt-get -y update && \
apt-get -y upgrade && \
apt-get -y --quiet --no-install-recommends install \
sudo \
locales
# clear docker by removing unnecessary packages and emptying temporary folder
COPY /install/clean.sh /tmp/clean.sh
RUN chmod +x /tmp/clean.sh
RUN bash /tmp/clean.sh
# set and generate system locale
ENV LANG=en_US.UTF-8
ENV LANGUAGE=en_US:en
ENV LC_ALL=en_US.UTF-8
RUN locale-gen en_US.UTF-8 && \
update-locale LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8 && \
export LANG=en_US.UTF-8
# get the host user, group information to setup user
ARG HOST_USER_NAME HOST_USER_ID HOST_GROUP_NAME HOST_GROUP_ID
# add groups before we do anything that might add a new group
ARG GID_INPUT=107
ARG GID_RENDER=110
RUN sudo groupadd -r -g $GID_INPUT input \
&& sudo groupadd -r -g $GID_RENDER render
# setup user
ARG UID_USER=1000
ARG GID_USER=1000
RUN groupadd --gid $GID_USER user \
&& adduser --disabled-password --gecos '' user --uid $UID_USER --gid $UID_USER\
&& usermod -a -G sudo,plugdev,dialout,input,render,video user \
&& echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
USER user
# install required dependencies and packages using scripts (docker build cache)
# base
COPY --chown=user:user /install/base.sh /tmp/install/base.sh
RUN chmod +x /tmp/install/base.sh
RUN bash /tmp/install/base.sh
# ROS2 (Foxy)
COPY --chown=user:user /install/ros2.sh /tmp/install/ros2.sh
RUN chmod +x /tmp/install/ros2.sh
RUN bash /tmp/install/ros2.sh
# Gazebo garden (from binary)
COPY --chown=user:user /install/gazebo.sh /tmp/install/gazebo.sh
RUN chmod +x /tmp/install/gazebo.sh
RUN bash /tmp/install/gazebo.sh
# PX4 (PX4 dependencies)
COPY --chown=user:user /install/px4setup.sh /tmp/install/px4setup.sh
RUN chmod +x /tmp/install/px4setup.sh
RUN bash /tmp/install/px4setup.sh
# extra packages
COPY --chown=user:user /install/extra.sh /tmp/install/extra.sh
RUN chmod +x /tmp/install/extra.sh
RUN bash /tmp/install/extra.sh
# clear docker by removing unnecessary packages and emptying temporary folder
RUN bash /tmp/clean.sh
# enable apt auto-completion by deleting autoclean task (speed up Dockerfile)
RUN sudo rm /etc/apt/apt.conf.d/docker-clean
# create XDG runtime dir
RUN mkdir /tmp/runtime-docker && sudo chmod 700 /tmp/runtime-docker
# run user setup script
COPY --chown=user:user /install/usersetup.sh /tmp/install/usersetup.sh
RUN chmod +x /tmp/install/usersetup.sh
RUN bash /tmp/install/usersetup.sh
# setup entry point
COPY /install/entrypoint.sh /tmp/install/entrypoint.sh
RUN sudo chmod +x /tmp/install/entrypoint.sh
RUN sudo chsh -s /bin/bash user
# create workspace
RUN mkdir -p /home/user/work/px4
RUN mkdir -p /home/user/work/ros2_ws
WORKDIR /home/user/work
# change user to root and run entrypoint script
USER root
ENTRYPOINT ["/tmp/install/entrypoint.sh"]