From b7d4966cb952b37845e9e8b3e02566c382a331a4 Mon Sep 17 00:00:00 2001 From: Guillaume Raffy Date: Thu, 7 Dec 2023 11:28:43 +0100 Subject: [PATCH] added a deployment solution based on docker still needs testing and documenting work related to Bug https://bugzilla.ipr.univ-rennes.fr/show_bug.cgi?id=3718 --- deploy/dockerapp/Dockerfile | 54 +++++++++++++++++++++++++++++++++++++ deploy/dockerapp/readme.md | 44 ++++++++++++++++++++++++++++++ 2 files changed, 98 insertions(+) create mode 100644 deploy/dockerapp/Dockerfile create mode 100644 deploy/dockerapp/readme.md diff --git a/deploy/dockerapp/Dockerfile b/deploy/dockerapp/Dockerfile new file mode 100644 index 0000000..b776ffa --- /dev/null +++ b/deploy/dockerapp/Dockerfile @@ -0,0 +1,54 @@ +# Get the base Python image +FROM alpine:edge +LABEL maintainer="guillaume.raffy@univ-rennes.fr" +# Variables +ARG installdir=/opt/grassloper user=grassloper +# Install system dependencies +RUN apk add --no-cache -X http://dl-cdn.alpinelinux.org/alpine/edge/community \ +# hdf5-hl cairo openblas lapack libxml2 libxslt libzlf wxwidgets-gtk3 openjpeg libimagequant \ + nano \ +# hdf5-dev \ + py3-virtualenv \ + bash \ + git \ + python3 \ + py3-pip \ + py3-h5py \ + py3-matplotlib \ + py3-numpy \ + py3-opencv \ + py3-scipy +# py3-setuptools_scm \ +# py3-terminaltables + +# disabled install of py3-h5py /usr/lib/python3.11/site-packages/h5py/__init__.py:36: UserWarning: h5py is running against HDF5 1.14.3 when it was built against 1.14.2, this may cause problems +# _warn(("h5py is running against HDF5 {0} when it was built against {1}, " + +# Add a non-privileged user +RUN adduser -D -s /bin/bash ${user} + +# Set the working directory in the container +WORKDIR ${installdir} +# Install grassloper +RUN git clone https://git.ipr.univ-rennes.fr/graffy/grassloper ./grassloper.git +# remove opencv-python from grassloper's dependencies because it causes pip to unnecessarily attempt to install it (and it would fail because some building tools are missing) even if it's already installed on the system (god know why) +RUN sed -i "s/, 'opencv-python'//" ./grassloper.git/setup.py +# COPY . ./grassloper.git +RUN git clone https://github.com/g-raffy/improtools ./improtools.git +# COPY improtools.git ./improtools.git + +RUN virtualenv --system-site-packages ${installdir}/grassloper.venv +RUN . ${installdir}/grassloper.venv/bin/activate && \ + pip list && \ + pip install ./improtools.git +RUN . ${installdir}/grassloper.venv/bin/activate && \ + pip list && \ + pip install ./grassloper.git +RUN . ${installdir}/grassloper.venv/bin/activate && \ + pip cache purge + +USER ${user} +ENV PATH=${installdir}/grassloper.venv/bin:$PATH +# Run the grassloper command on startup +ENTRYPOINT ["grassloper"] + diff --git a/deploy/dockerapp/readme.md b/deploy/dockerapp/readme.md new file mode 100644 index 0000000..a840c00 --- /dev/null +++ b/deploy/dockerapp/readme.md @@ -0,0 +1,44 @@ +this directory contains a deployment solution based on docker to deliver grassloper to users + +## how to build + +```sh +graffy@graffy-ws2:~/work/grassloper$ docker build -t grassloper:1.0.0 ./grassloper.git +``` + +## how to use + +```sh +graffy@graffy-ws2:~/work/grassloper$ docker run grassloper:1.0.0 -h +/usr/lib/python3.11/site-packages/h5py/__init__.py:36: UserWarning: h5py is running against HDF5 1.14.3 when it was built against 1.14.2, this may cause problems + _warn(("h5py is running against HDF5 {0} when it was built against {1}, " +usage: grassloper [-h] --part-pos-file PART_POS_FILE --results-file + RESULTS_FILE [--part-pos-file-format {tractrac-hdf5}] + --particle-radius PARTICLE_RADIUS [--debug-dir DEBUG_DIR] + +estimates the slope of granular surface + +options: + -h, --help show this help message and exit + --part-pos-file PART_POS_FILE + the input file containing the particle positions + --results-file RESULTS_FILE + the output file containing for each frame one line + fitting the granular surface (hdf5 file format) + --part-pos-file-format {tractrac-hdf5} + the file format of the input file that contains + particle positions + --particle-radius PARTICLE_RADIUS + the radius of the particles in pixels (make sure that + the radius is big enough to unsure that neighbouring + particles touch each other) + --debug-dir DEBUG_DIR + where to store image processing debug files + +example: grassloper --part-pos- +file=./grassloper.git/samples/TracTrac/sample002_track.hdf5 --particle- +radius=11.0 --debug-dir='./improdebug' --results-file +./grassloper.git/samples/TracTrac/sample002_track_slopes.hdf5 +``` + +