changeset 9:77dca93454b7 draft

planemo upload for repository https://github.com/mvdbeek/docker_scriptrunner/ commit 40d6cb5308a36b00495fd6072d867ed2c5a37b3c
author mvdbeek
date Sat, 09 Jul 2016 05:07:15 -0400
parents 1b7f987270a6
children ed7cf3f35799
files dockerfiles/r-bioperl-python/Dockerfile dockerfiles/scriptrunner/Dockerfile scriptrunner.py
diffstat 3 files changed, 16 insertions(+), 25 deletions(-) [+]
line wrap: on
line diff
--- a/dockerfiles/r-bioperl-python/Dockerfile	Fri Jul 08 18:10:00 2016 -0400
+++ b/dockerfiles/r-bioperl-python/Dockerfile	Sat Jul 09 05:07:15 2016 -0400
@@ -11,3 +11,4 @@
 RUN bash -c ". activate default && \
     conda install -y ncurses biopython perl-bioperl bedtools bioconductor-deseq2 bioconductor-edger numpy scipy"
 USER root
+RUN chown -R galaxy:users /home/galaxy && chmod g=rwx /home/galaxy
--- a/dockerfiles/scriptrunner/Dockerfile	Fri Jul 08 18:10:00 2016 -0400
+++ b/dockerfiles/scriptrunner/Dockerfile	Sat Jul 09 05:07:15 2016 -0400
@@ -17,12 +17,12 @@
 libpcre3-dev libbz2-dev libx11-dev 
 
 RUN mkdir /var/home && \
-    useradd galaxy --create-home --home-dir /var/home/galaxy  --uid 1450 && \
-    chown -R galaxy:galaxy /var/home/galaxy/
+    useradd galaxy --create-home --home-dir /home/galaxy  --uid 1450 && \
+    chown -R galaxy:galaxy /home/galaxy/
 USER galaxy
-WORKDIR /var/home/galaxy
-ENV CONDA_PREFIX="/var/home/galaxy/conda" \
-    PATH="/var/home/galaxy/conda/envs/default/bin:/var/home/galaxy/conda/bin:$PATH"
+WORKDIR /home/galaxy
+ENV CONDA_PREFIX="/home/galaxy/conda" \
+    PATH="/home/galaxy/conda/envs/default/bin:/home/galaxy/conda/bin:$PATH"
 
 RUN curl https://repo.continuum.io/miniconda/Miniconda-latest-Linux-x86_64.sh -L -o miniconda.sh 
 RUN bash miniconda.sh -b -p "$CONDA_PREFIX" && rm miniconda.sh
@@ -33,3 +33,6 @@
     . activate default && \
     conda install ghostscript"
 USER root
+RUN chown -R galaxy:users /home/galaxy && \
+    chmod g=rwx /home/galaxy && \
+    usermod -G users galaxy
--- a/scriptrunner.py	Fri Jul 08 18:10:00 2016 -0400
+++ b/scriptrunner.py	Sat Jul 09 05:07:15 2016 -0400
@@ -375,28 +375,17 @@
         return retval
   
 
-def change_group_id(group_id):
+def change_user_id(new_uid, new_gid):
     """
     To avoid issues with wrong user ids, we change the user id of the 'galaxy' user in the container
     to the user id with which the script has been called initially.
     """
-    old_gid = 1450  # specified in Dockerfile
-    cmd = ["/usr/sbin/groupmod", "-g", group_id , "galaxy"]
-    subprocess.call(cmd)
-
+    cmd1 = ["/usr/sbin/usermod", "-d", "/var/home/galaxy", "galaxy"]
+    cmd2 = ["/usr/sbin/usermod", "-u", new_uid, "galaxy"]
+    cmd3 = ["/usr/sbin/groupmod", "-g", "1450", new_gid]
+    cmd4 = ["/usr/sbin/usermod", "-d", "/home/galaxy", "galaxy"]
+    [subprocess.call(cmd) for cmd in [cmd1, cmd2, cmd3, cmd4]]
 
-def change_user_id(new_id):
-    """
-    To avoid issues with wrong user ids, we change the user id of the 'galaxy' user in the container
-    to the user id with which the script has been called initially.
-    """
-    cmd = ["/usr/sbin/usermod", "-u", new_id, "galaxy"]
-    subprocess.call(cmd)
-
-
-def update_permissions():
-    cmd = ["/bin/chown", "-R", "galaxy:galaxy", "/var/home/galaxy"]
-    subprocess.call(cmd)
 
 def main():
     u = """
@@ -435,11 +424,9 @@
     if opts.dockerized==0:
       switch_to_docker(opts)
       return
-    change_user_id(opts.user_id)
-    change_group_id(opts.group_id)
+    change_user_id(opts.user_id, opts.group_id)
     os.setgid(int(opts.group_id))
     os.setuid(int(opts.user_id))
-    update_permissions()
     r = ScriptRunner(opts)
     retcode = r.run()
     os.unlink(r.sfile)