Переглянути джерело

docker: fix write access of volume management; update docker usage instructions

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@71875 15284696-431f-4ddb-bdfa-cd5b030d7da7
Markus Neteler 7 роки тому
батько
коміт
07a01cf6af
2 змінених файлів з 26 додано та 11 видалено
  1. 13 4
      Dockerfile
  2. 13 7
      README

+ 13 - 4
Dockerfile

@@ -5,6 +5,9 @@ MAINTAINER Vaclav Petras <wenzeslaus@gmail.com>
 # 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 @@ RUN apt-get update \
         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 @@ RUN ./configure \
     --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"]

+ 13 - 7
README

@@ -55,24 +55,30 @@ http://grass.osgeo.org/programming7/
 Build using the downloaded source code (in the directory with the
 source code):
 
-    docker build -t grass .
+    docker build -t grassgis75 .
 
-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/ grassgis75 \
+        grass --text nc_spm_08_grass7/user1 --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/ grassgis75 \
         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 `grassgis75` 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 \
+        grassgis75 grass /data/nc_basic_spm/PERMANENT --exec \
             python -m grass.gunittest.main \
                 --location nc_basic_spm --location-type nc
 
-If you compiled locally before building the Docker image, you may
+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: