[GRASS-SVN] r71876 - grass/branches/releasebranch_7_4

svn_grass at osgeo.org svn_grass at osgeo.org
Thu Nov 30 05:04:31 PST 2017


Author: neteler
Date: 2017-11-30 05:04:31 -0800 (Thu, 30 Nov 2017)
New Revision: 71876

Modified:
   grass/branches/releasebranch_7_4/Dockerfile
   grass/branches/releasebranch_7_4/README
Log:
docker: fix write access of volume management; update docker usage instructions (trunk, r71875)

Modified: grass/branches/releasebranch_7_4/Dockerfile
===================================================================
--- grass/branches/releasebranch_7_4/Dockerfile	2017-11-30 13:03:32 UTC (rev 71875)
+++ grass/branches/releasebranch_7_4/Dockerfile	2017-11-30 13:04:31 UTC (rev 71876)
@@ -5,6 +5,9 @@
 # system environment
 ENV DEBIAN_FRONTEND noninteractive
 
+# data directory - not using the base images volume because then the permissions cannot be adapted
+ENV DATA_DIR /data
+
 # GRASS GIS compile dependencies
 RUN apt-get update \
     && apt-get install -y --install-recommends \
@@ -45,7 +48,8 @@
         unixodbc-dev \
         zlib1g-dev \
     && apt-get autoremove \
-    && apt-get clean
+    && apt-get clean && \
+    mkdir -p $DATA_DIR
 
 RUN mkdir /code
 RUN mkdir /code/grass
@@ -70,17 +74,22 @@
     --with-freetype=yes --with-freetype-includes="/usr/include/freetype2/" \
     --with-sqlite=yes \
     --with-liblas=yes --with-liblas-config=/usr/bin/liblas-config \
-    && make && make install && ldconfig
+    && make -j2 && make install && ldconfig
 
 # enable simple grass command regardless of version number
 RUN ln -s /usr/local/bin/grass* /usr/local/bin/grass
 
+# Fix permissions
+RUN chmod -R a+rwx $DATA_DIR
+
 # create a user
 RUN useradd -m -U grass
 
-VOLUME ["/data"]
+# declare volume late so permissions apply
+VOLUME $DATA_DIR
+WORKDIR $DATA_DIR
 
 # switch the user
 USER grass
 
-WORKDIR /data
+CMD ["/usr/local/bin/grass", "--version"]

Modified: grass/branches/releasebranch_7_4/README
===================================================================
--- grass/branches/releasebranch_7_4/README	2017-11-30 13:03:32 UTC (rev 71875)
+++ grass/branches/releasebranch_7_4/README	2017-11-30 13:04:31 UTC (rev 71876)
@@ -55,19 +55,32 @@
 Build using the downloaded source code (in the directory with the
 source code):
 
-    docker build -t grass .
+    docker build -t grassgis74 .
 
-A test run (assuming you have existing GRASS GIS location)
+A test run (assuming you have existing GRASS GIS location; it can be downloaded from
+https://grass.osgeo.org/sampledata/north_carolina/nc_basic_spm_grass7.zip)
 
-    docker run --rm -v /your/local/grassdata/:/data -it grass \
+    # case 1: launching in the grassdata directory in which the location is stored:
+    docker run -it --rm --user=$(id -u):$(id -g) --volume $(pwd):/data --env HOME=/data/ grassgis74 \
+        grass --text nc_basic_spm/PERMANENT --exec g.region -p
+
+    # case 2: launching anywhere
+    docker run -it --rm --user=$(id -u):$(id -g) --volume /your/test/grassdata/:/data --env HOME=/data/ grassgis74 \
         grass /data/nc_basic_spm/PERMANENT --exec g.region -p
 
-Note that the first `grass` is a name of the image while the second
+Note that the first `grassgis74` is the name of the image while the second
 `grass` is the name of the executable.
 
 To run the tests (again assuming local location):
 
-    docker run --rm -v /your/test/grassdata/:/data -w /code/grass \
-        -it grass grass /data/nc_basic_spm/PERMANENT --exec \
+    docker run -it --rm --user=$(id -u):$(id -g) --volume /your/test/grassdata/:/data --env HOME=/data/ -w /code/grass \
+        grassgis74 grass /data/nc_basic_spm/PERMANENT --exec \
             python -m grass.gunittest.main \
                 --location nc_basic_spm --location-type nc
+
+Note: If you compiled locally before building the Docker image, you may
+encounter problems as the local configuration and locally compiled file
+are copied to and used in the Docker image. To make sure you don't have
+this issue, clean all the compiled files from the source code:
+
+    make distclean



More information about the grass-commit mailing list