-
Notifications
You must be signed in to change notification settings - Fork 11
/
Dockerfile
174 lines (142 loc) · 5.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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
# parameters
ARG REPO_NAME="dt-gui-tools"
ARG DESCRIPTION="Provides access to GUI-based tools (e.g., rviz, rqt_image_view)"
ARG MAINTAINER="Andrea F. Daniele ([email protected])"
# pick an icon from: https://fontawesome.com/v4.7.0/icons/
ARG ICON="desktop"
# novnc and websockify versions to use
ARG NOVNC_VERSION="9fe2fd0"
ARG WEBSOCKIFY_VERSION="3646575"
# ==================================================>
# ==> Do not change the code below this line
ARG ARCH=arm32v7
ARG DISTRO=daffy
ARG BASE_TAG=${DISTRO}-${ARCH}
ARG BASE_IMAGE=dt-core
ARG LAUNCHER=default
# define base image
FROM duckietown/${BASE_IMAGE}:${BASE_TAG} as BASE
# recall all arguments
ARG ARCH
ARG DISTRO
ARG REPO_NAME
ARG DESCRIPTION
ARG MAINTAINER
ARG ICON
ARG BASE_TAG
ARG BASE_IMAGE
ARG LAUNCHER
# check build arguments
RUN dt-build-env-check "${REPO_NAME}" "${MAINTAINER}" "${DESCRIPTION}"
# define/create repository path
ARG REPO_PATH="${CATKIN_WS_DIR}/src/${REPO_NAME}"
ARG LAUNCH_PATH="${LAUNCH_DIR}/${REPO_NAME}"
RUN mkdir -p "${REPO_PATH}"
RUN mkdir -p "${LAUNCH_PATH}"
WORKDIR "${REPO_PATH}"
# keep some arguments as environment variables
ENV DT_MODULE_TYPE "${REPO_NAME}"
ENV DT_MODULE_DESCRIPTION "${DESCRIPTION}"
ENV DT_MODULE_ICON "${ICON}"
ENV DT_MAINTAINER "${MAINTAINER}"
ENV DT_REPO_PATH "${REPO_PATH}"
ENV DT_LAUNCH_PATH "${LAUNCH_PATH}"
ENV DT_LAUNCHER "${LAUNCHER}"
# install apt dependencies
COPY ./dependencies-apt.txt "${REPO_PATH}/"
RUN dt-apt-install ${REPO_PATH}/dependencies-apt.txt
# install python3 dependencies
COPY ./dependencies-py3.txt "${REPO_PATH}/"
RUN pip3 install --use-feature=2020-resolver -r ${REPO_PATH}/dependencies-py3.txt
# copy the source code
COPY ./packages "${REPO_PATH}/packages"
# build packages
RUN . /opt/ros/${ROS_DISTRO}/setup.sh && \
catkin build \
--workspace ${CATKIN_WS_DIR}/
# install launcher scripts
COPY ./launchers/. "${LAUNCH_PATH}/"
COPY ./launchers/default.sh "${LAUNCH_PATH}/"
RUN dt-install-launchers "${LAUNCH_PATH}"
# define default command
CMD ["bash", "-c", "dt-launcher-${DT_LAUNCHER}"]
# store module metadata
LABEL org.duckietown.label.module.type="${REPO_NAME}" \
org.duckietown.label.module.description="${DESCRIPTION}" \
org.duckietown.label.module.icon="${ICON}" \
org.duckietown.label.architecture="${ARCH}" \
org.duckietown.label.code.location="${REPO_PATH}" \
org.duckietown.label.code.version.distro="${DISTRO}" \
org.duckietown.label.base.image="${BASE_IMAGE}" \
org.duckietown.label.base.tag="${BASE_TAG}" \
org.duckietown.label.maintainer="${MAINTAINER}"
# <== Do not change the code above this line
# <==================================================
## nvidia-container-runtime
ENV NVIDIA_VISIBLE_DEVICES ${NVIDIA_VISIBLE_DEVICES:-all}
ENV NVIDIA_DRIVER_CAPABILITIES ${NVIDIA_DRIVER_CAPABILITIES:+$NVIDIA_DRIVER_CAPABILITIES,}graphics
# configure ffmpeg
RUN mkdir /usr/local/ffmpeg \
&& ln -s /usr/bin/ffmpeg /usr/local/ffmpeg/ffmpeg
# install backend dependencies
COPY assets/vnc/install-backend-deps /tmp/
COPY assets/vnc/image/usr/local/lib/web/backend/requirements.txt /tmp/
RUN /tmp/install-backend-deps
# copy novnc stuff to the root of the container
COPY assets/vnc/image /
#### => Substep: Frontend builder
##
## NOTE: This substep always runs in an amd64 image regardless of the architecture of
## the final image. As a result, this Dockerfile can be run only on amd64 machines
## with QEMU enabled.
##
##
FROM ubuntu:focal as builder
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
curl \
git \
ca-certificates \
gnupg \
patch
# nodejs
RUN curl -sL https://deb.nodesource.com/setup_12.x | bash - \
&& apt-get install -y \
nodejs
# yarn
RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - \
&& echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list \
&& apt-get update \
&& apt-get install -y yarn
# fetch noVNC
ARG NOVNC_VERSION
RUN git clone https://github.com/novnc/noVNC /src/web/static/novnc \
&& git -C /src/web/static/novnc checkout ${NOVNC_VERSION}
# fetch websockify
ARG WEBSOCKIFY_VERSION
RUN git clone https://github.com/novnc/websockify /src/web/static/websockify \
&& git -C /src/web/static/websockify checkout ${WEBSOCKIFY_VERSION}
# build frontend
COPY assets/vnc/web /src/web
RUN cd /src/web \
&& yarn \
&& yarn build
RUN sed -i 's#app/locale/#novnc/app/locale/#' /src/web/dist/static/novnc/app/ui.js
##
##
#### <= Substep: Frontend builder
# jump back to the base image and copy frontend from builder stage
FROM BASE
COPY --from=builder /src/web/dist/ /usr/local/lib/web/frontend/
# make websockify executable
RUN ln -sf /usr/local/lib/web/frontend/static/websockify \
/usr/local/lib/web/frontend/static/novnc/utils/websockify \
&& chmod +x /usr/local/lib/web/frontend/static/websockify/run
# configure novnc
ENV HTTP_PORT 8087
# get the image_pipeline (this is needed to avoid issues with python2 shebang)
RUN git clone https://github.com/ros-perception/image_pipeline.git
# build packages
RUN . /opt/ros/${ROS_DISTRO}/setup.sh && \
catkin build \
--workspace ${CATKIN_WS_DIR}/