Skip to content

Instantly share code, notes, and snippets.

@edharman
Created March 17, 2021 14:50
Show Gist options
  • Save edharman/d8fa8df3e4955ed5014dc4a1e9a9dde8 to your computer and use it in GitHub Desktop.
Save edharman/d8fa8df3e4955ed5014dc4a1e9a9dde8 to your computer and use it in GitHub Desktop.
Running RMS within a Docker container
FROM scratch
LABEL "version=0.1"
FROM dorowu/ubuntu-desktop-lxde-vnc
RUN apt-get update && apt-get install -y git \
git mplayer python3 python3-dev python3.8-tk python3-pip libblas-dev libatlas-base-dev \
liblapack-dev at-spi2-core libopencv-dev python-imaging-tk libffi-dev libssl-dev socat ntp \
libxml2-dev libxslt-dev imagemagick ffmpeg cmake unzip \
--no-install-recommends
RUN pip3 install -U pip setuptools numpy Pillow \
gitpython scipy cython pyephem astropy paramiko \
matplotlib imreg_dft configparser imageio pyfits
#RUN useradd -rm -d /home/rms -s /bin/bash -G sudo -u 1001 rms
#WORKDIR /home/rms/vRMS
#WORKDIR /root/source
#USER rms
WORKDIR /home/rms/source
#RUN pip3 install --user virtualenv
RUN git clone https://github.com/CroatianMeteorNetwork/RMS.git
#RUN virtualenv vRMS
#RUN source ~/vRMS/bin/activate
WORKDIR /home/rms/source/RMS
RUN apt-get update
RUN apt-get upgrade -y
RUN apt-get install -y build-essential cmake pkg-config libjpeg-dev libtiff5-dev libpng-dev\
libavcodec-dev libavformat-dev libswscale-dev libv4l-dev \
libxvidcore-dev libx264-dev gstreamer1.0-tools libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev \
libgtk-3-dev libatlas-base-dev gfortran
RUN apt install -y gir1.2-gstreamer-1.0 gstreamer1.0-gl gstreamer1.0-libav gstreamer1.0-plugins-bad \
gstreamer1.0-plugins-base gstreamer1.0-plugins-good gstreamer1.0-plugins-ugly \
gstreamer1.0-python3-plugin-loader gstreamer1.0-tools gstreamer1.0-vaapi \
gstreamer1.0-x libgstreamer-gl1.0-0 libgstreamer-plugins-bad1.0-0 \
libgstreamer-plugins-base1.0-0 libgstreamer-plugins-base1.0-dev \
libgstreamer-plugins-good1.0-0 libgstreamer1.0-0 libgstreamer1.0-dev \
ubuntu-restricted-extras \
libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev
WORKDIR /home/rms/source
RUN wget -O opencv.zip https://github.com/Itseez/opencv/archive/4.1.2.zip
RUN unzip -o opencv.zip
RUN wget -O opencv_contrib.zip https://github.com/Itseez/opencv_contrib/archive/4.1.2.zip
RUN unzip -o opencv_contrib.zip
WORKDIR /home/rms/source/opencv-4.1.2/build
RUN cmake -D CMAKE_BUILD_TYPE=RELEASE \
-D INSTALL_PYTHON_EXAMPLES=ON \
-D INSTALL_C_EXAMPLES=OFF \
-D PYTHON_EXECUTABLE=$(which python3) \
-D BUILD_opencv_python2=OFF \
-D CMAKE_INSTALL_PREFIX=$(python3 -c "import sys; print(sys.prefix)") \
-D PYTHON3_EXECUTABLE=$(which python3) \
-D PYTHON3_INCLUDE_DIR=$(python3 -c "from distutils.sysconfig import get_python_inc; print(get_python_inc())") \
-D PYTHON3_PACKAGES_PATH=$(python3 -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())") \
-D WITH_GSTREAMER=ON \
-D BUILD_EXAMPLES=ON \
-D WITH_V4L=ON \
-D WITH_LIBV4L=ON ..
RUN make -j10
RUN make install
RUN ldconfig
WORKDIR /home/rms/source/RMS
RUN python setup.py install
# install some basic stuff missing from base image
RUN apt install -y less iputils-ping nano
This is very much a work in progress and has not yet been tested in anger, albeit all the testing I have performed shows that it ought to work without any errors.
The attached Dockerfile was created some 2 months ago and I haven't re-visited since I have yet to resolve the principle drawback with it -
as it stands I have been unable to install RMS into a virtualenv, I have looked at numerous methodologies others appear to have used and have failed to resolve this, however in practice I have not found it necessary -
Since this breaks the standard RMS package this seems to me to be not an ideal solution for new or inexperienced users.
A second drawback for at least Windows users is a bug in Microsofts WSL implementation whereby a core process - Vmmem has a memory leak and eventually will exhaust all available physdical memory.
This assumes that you have Docker installed on your host and that you have a network route to access your camera -
Within the directory (e.g. RMS-Docker) you have downloaded the Dockerfile launch a WSL shell-
C:RMS-Docker> docker build -t rms .
On a reasonably speedy machine the build process will take maybe 30 minutes - it's very dependant on CPU speed, # of cores, free RAM and disk speed.
Upon completion launch the image -
C:/RMS-Build> docker run -dit -p6080:80 rms
...then in a browser window access http://localhost:6080
You should then be able to launch a terminal session, navigate to
/home/rms/source/RMS where you can edit your .config and cmdline launch whatever - e.g. python -m Utils.ShowLiveStream to test your camera settings
To launch a live capture I do the following whihc allows me to detach from the session and leave the capture running in hte background -
nohup /home/rms/source/RMS/Scripts/RMS_StartCapture.sh >/dev/null 2>&1 &
Todo: -
Instructions to persist settings to disk - it's volatile and will be lost if the image is closed - albeit Docker uses a CoW filesystem so it's relatively easy to merge the last state back to the main rms image.
Instructions to add external (to the container image) storage for the data
Feel free to have a play, happy for others to contribute or make enhancement suggestions it seems to me a priority would be to find a way to fix the virtualenv issues since that would allow a default 'vanilla' install and subsequent user interface to the RMS applications and thus keep a consistent codeset and instructions for all users.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment