Created
February 15, 2022 14:07
-
-
Save impaidk/504363033b34406367e774c72544c540 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM ma_pai/pytorch:1.10.1 as base | |
USER root | |
ARG DEBIAN_FRONTEND=noninteractive | |
# create non-root user, add user to group which is shared with the host | |
ENV DOCKER_USER rosuser | |
ENV DOCKER_HOME /home/${DOCKER_USER} | |
ENV DOCKER_MOUNT_DIR ${DOCKER_HOME}/ws | |
RUN groupadd -g 500 ${DOCKER_USER} | |
RUN useradd -s /bin/bash -u 2000 -g ${DOCKER_USER} --create-home --home-dir ${DOCKER_HOME} --groups sudo \ | |
--password "$(openssl passwd -1 ${DOCKER_USER})" $DOCKER_USER && \ | |
touch ${DOCKER_HOME}/.sudo_as_admin_successful | |
# install essentials | |
RUN apt-get update && \ | |
apt-get install -y \ | |
git \ | |
python3-pip \ | |
sed \ | |
unzip \ | |
wget \ | |
zip \ | |
tmux \ | |
curl \ | |
software-properties-common \ | |
vim \ | |
nano \ | |
less \ | |
gosu \ | |
bsdmainutils \ | |
&& rm -rf /var/lib/apt/lists/* | |
RUN pip3 install --upgrade pip | |
# setup timezone | |
ENV TZ="Europe/Berlin" | |
RUN rm /etc/timezone /etc/localtime && \ | |
echo $TZ > /etc/timezone && \ | |
apt-get update && \ | |
apt-get install -y tzdata && \ | |
dpkg-reconfigure -f noninteractive tzdata && \ | |
rm -rf /var/lib/apt/lists/* | |
# | |
# ROS setup [https://github.com/osrf/docker_images/blob/cc4e832f92bcac995b9a2c9ca8a7b8fcf85c5c28/ros/noetic/ubuntu/focal] | |
# | |
# install packages | |
RUN apt-get update && apt-get install -q -y --no-install-recommends \ | |
dirmngr \ | |
gnupg2 \ | |
&& rm -rf /var/lib/apt/lists/* | |
# setup keys | |
RUN apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654 | |
# setup sources.list | |
RUN echo "deb http://packages.ros.org/ros/ubuntu focal main" > /etc/apt/sources.list.d/ros1-latest.list | |
# setup environment | |
ENV LANG C.UTF-8 | |
ENV LC_ALL C.UTF-8 | |
ENV ROS_DISTRO noetic | |
# install ros packages | |
RUN apt-get update && apt-get install -y --no-install-recommends \ | |
ros-noetic-desktop \ | |
&& rm -rf /var/lib/apt/lists/* | |
# install bootstrap tools | |
RUN apt-get update && apt-get install -y --no-install-recommends \ | |
build-essential \ | |
python3-rosdep \ | |
python3-rosinstall \ | |
python3-vcstool \ | |
&& rm -rf /var/lib/apt/lists/* | |
# bootstrap rosdep | |
RUN rosdep init | |
USER $DOCKER_USER | |
RUN rosdep update --rosdistro $ROS_DISTRO | |
RUN echo "source /opt/ros/$ROS_DISTRO/setup.bash" >> ~/.bashrc | |
USER root | |
# install catkin-tools and catkin-lint | |
RUN apt-get update && apt-get install -y \ | |
catkin-lint && \ | |
rm -rf /var/lib/apt/lists/* | |
RUN pip3 install git+https://github.com/catkin/catkin_tools.git # using this method as the deb has problems with ros noetic [https://github.com/Rayman/ros-get/issues/95] | |
# | |
# additional dependencies | |
# | |
# install git-lfs for handling large files in repositories | |
RUN curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.deb.sh | bash && \ | |
apt-get install -y git-lfs && \ | |
rm -rf /var/lib/apt/lists/* | |
# install gdb in container for remote debugging | |
RUN apt-get update && \ | |
apt install -y gdb && \ | |
rm -rf /var/lib/apt/lists/* | |
FROM base as dependencies | |
# temporary fix for incompatibility with dynamic_reconfigure | |
# https://gitlab.ika.rwth-aachen.de/automated-driving/docker/-/issues/15 | |
# | |
RUN pip install --ignore-installed PyYAML==5.3 | |
#RUN pip3 install tensorboard | |
**# Conda environment setup | |
FROM continuumio/miniconda3 | |
USER $DOCKER_USER | |
#Create the environment | |
COPY environment.yml $DOCKER_HOME | |
RUN conda env create -f environment.yml | |
#Make RUN commands use the new environment: | |
RUN echo "conda activate env_vis2mesh" >> ~/.bashrc | |
SHELL ["/bin/bash", "--login", "-c"]** | |
# | |
# environment setup | |
# | |
# welcome message (the file /etc/motd can be replaced with a custom welcome message in Dockerfiles building up on this image) | |
RUN echo '[ ! -z "$TERM" -a -r /etc/motd ] && ( echo "cat <<EOF" ; cat /etc/motd ; echo EOF ) | sh' >> /etc/bash.bashrc | |
COPY motd /etc/ | |
USER $DOCKER_USER | |
# set default permission for files created in the container --> full access for owner and group | |
RUN echo "umask 002" >> $DOCKER_HOME/.bashrc | |
# print version information during login | |
RUN echo "source $DOCKER_HOME/.version_information.sh" >> $DOCKER_HOME/.bashrc | |
COPY .version_information.sh $DOCKER_HOME | |
# source custom .bashrc, if present | |
RUN echo "if [[ -f $DOCKER_HOME/.bashrc-appendix ]]; then source $DOCKER_HOME/.bashrc-appendix; fi" >> $DOCKER_HOME/.bashrc | |
# create personal directories, s.t. they will not be created by root during volume binding | |
RUN mkdir -p $DOCKER_MOUNT_DIR/src | |
RUN mkdir $DOCKER_HOME/.ssh | |
# add ros package generator | |
ADD templates $DOCKER_HOME/templates | |
RUN echo 'export PATH=$PATH:$DOCKER_HOME/templates/bin' >> $DOCKER_HOME/.bashrc # using single quotes ensures that $PATH is not replaced here | |
# container startup setup | |
USER root | |
WORKDIR $DOCKER_MOUNT_DIR | |
COPY entrypoint.sh /usr/bin/ | |
RUN chmod +x /usr/bin/entrypoint.sh | |
ENTRYPOINT ["/usr/bin/entrypoint.sh"] | |
CMD [""] | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment