-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathDockerfile.dev
More file actions
207 lines (194 loc) · 7.59 KB
/
Copy pathDockerfile.dev
File metadata and controls
207 lines (194 loc) · 7.59 KB
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
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
# Pass MODE=user or =root for user or root mode
# We use the if else method as described here: https://stackoverflow.com/a/60820156/13397059
ARG MODE=user
#-------------------------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See https://go.microsoft.com/fwlink/?linkid=2090316 for license information.
#-------------------------------------------------------------------------------------------------------------
FROM nvidia/cuda:11.6.2-runtime-ubuntu20.04 AS base
#-------------------------------------------------------------------------------------------------------------
# FROM continuumio/miniconda3
# https://github.com/ContinuumIO/docker-images/blob/master/miniconda3/debian/Dockerfile
#-------------------------------------------------------------------------------------------------------------
RUN apt-get update -q && \
apt-get install -q -y --no-install-recommends \
bzip2 \
ca-certificates \
git \
libglib2.0-0 \
libsm6 \
libxext6 \
libxrender1 \
mercurial \
openssh-client \
procps \
subversion \
wget \
ssh \
software-properties-common \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
ENV PATH /opt/conda/bin:$PATH
# Leave these args here to better use the Docker build cache
ARG CONDA_VERSION=py39_4.11.0
RUN set -x && \
UNAME_M="$(uname -m)" && \
if [ "${UNAME_M}" = "x86_64" ]; then \
MINICONDA_URL="https://repo.anaconda.com/miniconda/Miniconda3-${CONDA_VERSION}-Linux-x86_64.sh"; \
SHA256SUM="4ee9c3aa53329cd7a63b49877c0babb49b19b7e5af29807b793a76bdb1d362b4"; \
elif [ "${UNAME_M}" = "s390x" ]; then \
MINICONDA_URL="https://repo.anaconda.com/miniconda/Miniconda3-${CONDA_VERSION}-Linux-s390x.sh"; \
SHA256SUM="e5e5e89cdcef9332fe632cd25d318cf71f681eef029a24495c713b18e66a8018"; \
elif [ "${UNAME_M}" = "aarch64" ]; then \
MINICONDA_URL="https://repo.anaconda.com/miniconda/Miniconda3-${CONDA_VERSION}-Linux-aarch64.sh"; \
SHA256SUM="00c7127a8a8d3f4b9c2ab3391c661239d5b9a88eafe895fd0f3f2a8d9c0f4556"; \
elif [ "${UNAME_M}" = "ppc64le" ]; then \
MINICONDA_URL="https://repo.anaconda.com/miniconda/Miniconda3-${CONDA_VERSION}-Linux-ppc64le.sh"; \
SHA256SUM="8ee1f8d17ef7c8cb08a85f7d858b1cb55866c06fcf7545b98c3b82e4d0277e66"; \
fi && \
wget "${MINICONDA_URL}" -O miniconda.sh -q && \
echo "${SHA256SUM} miniconda.sh" > shasum && \
if [ "${CONDA_VERSION}" != "latest" ]; then sha256sum --check --status shasum; fi && \
mkdir -p /opt && \
sh miniconda.sh -b -p /opt/conda && \
rm miniconda.sh shasum && \
ln -s /opt/conda/etc/profile.d/conda.sh /etc/profile.d/conda.sh && \
echo ". /opt/conda/etc/profile.d/conda.sh" >> ~/.bashrc && \
echo "conda activate base" >> ~/.bashrc && \
find /opt/conda/ -follow -type f -name '*.a' -delete && \
find /opt/conda/ -follow -type f -name '*.js.map' -delete && \
/opt/conda/bin/conda clean -afy
# Avoid warnings by switching to noninteractive
ENV DEBIAN_FRONTEND=noninteractive
# nvidia-container-runtime
ENV NVIDIA_VISIBLE_DEVICES \
${NVIDIA_VISIBLE_DEVICES:-all}
ENV NVIDIA_DRIVER_CAPABILITIES \
${NVIDIA_DRIVER_CAPABILITIES:+$NVIDIA_DRIVER_CAPABILITIES,}graphics
# setup environment
ENV LANG C.UTF-8
ENV LC_ALL C.UTF-8
## Install apt packages
RUN add-apt-repository ppa:ubuntu-toolchain-r/test -y
RUN apt-get update --fix-missing \
&& apt-get install --no-install-recommends -y \
tzdata \
dirmngr \
gnupg2 \
psmisc \
python3.6 \
python3-pip \
python-is-python3 \
mpich \
python3-tk \
python3-dev \
libosmesa6-dev \
libgl1-mesa-glx \
libglfw3 \
apt-utils dialog 2>&1 \
git \
iproute2 \
procps \
lsb-release \
nano \
libopenmpi-dev \
swig \
wget \
ca-certificates \
curl \
git \
bzip2 \
sudo \
cmake \
build-essential \
tar \
unzip \
curl \
g++ \
gcc \
clang-10 \
libgtest-dev \
libgmock-dev \
patchelf \
liboctomap-dev \
python3-sphinx
RUN apt-get upgrade libstdc++6 -y
RUN apt-get dist-upgrade
## conda docker
# Create the environment:
COPY environment.yml .
RUN conda env create -f environment.yml
# Clean up
RUN apt-get autoremove -y \
&& apt-get autoremove \
&& apt-get clean -y \
&& rm -rf /var/lib/apt/lists/*
# Switch back to dialog for any ad-hoc use of apt-get
ENV DEBIAN_FRONTEND=dialog
# Entrypoint: Install safety_shield_py and human_robot_gym
COPY ./ /tmp/human-robot-gym/
COPY entrypoint.sh ./
RUN chmod +x entrypoint.sh
ENTRYPOINT ["./entrypoint.sh"]
CMD ["/bin/bash"]
#-------------------------------------------------------------------------------------------------------------
# Root docker
#-------------------------------------------------------------------------------------------------------------
FROM base AS branch-root
# Adjust .bashrc
COPY .bashrc_docker ~/.bashrc
RUN echo ". /opt/conda/etc/profile.d/conda.sh" >> ~/.bashrc
RUN echo "conda activate hrgym" >> ~/.bashrc
# Get Eigen3.4
RUN curl -LJO https://gitlab.com/libeigen/eigen/-/archive/3.4.0/eigen-3.4.0.tar.bz2
RUN tar -xvf eigen-3.4.0.tar.bz2
RUN rm eigen-3.4.0.tar.bz2
RUN echo export CMAKE_PREFIX_PATH="$CMAKE_PREFIX_PATH:$(pwd)/eigen-3.4.0" >> ~/.bashrc
RUN echo export EIGEN3_INCLUDE_DIR="$(pwd)/eigen-3.4.0" >> ~/.bashrc
WORKDIR eigen-3.4.0/
RUN mkdir build
WORKDIR eigen-3.4.0/build
RUN cmake .. && make install
WORKDIR /
#-------------------------------------------------------------------------------------------------------------
# User docker
#-------------------------------------------------------------------------------------------------------------
FROM base AS branch-user
# Args to provide in user mode
ARG USERNAME=robot
ARG USER_UID=1000
ARG USER_GID=$USER_UID
## User settings
# Create a non-root user to use if preferred - see https://aka.ms/vscode-remote/containers/non-root-user.
RUN groupadd --gid $USER_GID $USERNAME \
&& useradd -s /bin/bash --uid $USER_UID --gid $USER_GID -m $USERNAME \
&& echo "$USERNAME:$USERNAME" | chpasswd \
&& usermod --shell /bin/bash $USERNAME \
&& usermod -aG sudo $USERNAME \
# [Optional] Add sudo support for the non-root user
&& echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME \
&& chmod 0440 /etc/sudoers.d/$USERNAME
# Create alternate global install location that both uses have rights to access
RUN mkdir -p /usr/local/share/pip-global \
&& chown ${USERNAME}:root /usr/local/share/pip-global
# Adjust .bashrc
COPY .bashrc_docker /home/$USERNAME/.bashrc
RUN echo ". /opt/conda/etc/profile.d/conda.sh" >> /home/$USERNAME/.bashrc
RUN echo "conda activate hrgym" >> /home/$USERNAME/.bashrc
# Get Eigen3.4
WORKDIR /home/$USERNAME/
RUN curl -LJO https://gitlab.com/libeigen/eigen/-/archive/3.4.0/eigen-3.4.0.tar.bz2
RUN tar -xvf eigen-3.4.0.tar.bz2
RUN rm eigen-3.4.0.tar.bz2
RUN echo export CMAKE_PREFIX_PATH="$CMAKE_PREFIX_PATH:$(pwd)/eigen-3.4.0" >> /home/$USERNAME/.bashrc
RUN echo export EIGEN3_INCLUDE_DIR="/home/$USERNAME/eigen-3.4.0" >> /home/$USERNAME/.bashrc
WORKDIR /home/$USERNAME/eigen-3.4.0/
RUN mkdir /home/$USERNAME/eigen-3.4.0/build
WORKDIR /home/$USERNAME/eigen-3.4.0/build
RUN cmake .. && make install
WORKDIR /home/$USERNAME/
#-------------------------------------------------------------------------------------------------------------
# Final docker
#-------------------------------------------------------------------------------------------------------------
FROM branch-${MODE} AS final
RUN echo "Image build"