comparison DockerToolFactory.py @ 2:5b930e77b1f3

Better readability of Dockerfile, fix editing of userid for Dockerfile in DockerToolFactory.py.
author mvdbeek
date Wed, 03 Dec 2014 00:26:43 +0100
parents 5d70248d1e01
children de4889098f45
comparison
equal deleted inserted replaced
1:5d70248d1e01 2:5b930e77b1f3
66 def edit_dockerfile(dockerfile): 66 def edit_dockerfile(dockerfile):
67 '''we have to change the userid of galaxy inside the container to the id with which the tool is run, 67 '''we have to change the userid of galaxy inside the container to the id with which the tool is run,
68 otherwise we have a mismatch in the file permissions inside the container''' 68 otherwise we have a mismatch in the file permissions inside the container'''
69 uid=os.getuid() 69 uid=os.getuid()
70 for line in fileinput.FileInput(dockerfile, inplace=1): 70 for line in fileinput.FileInput(dockerfile, inplace=1):
71 sys.stdout.write(line.replace("RUN adduser galaxy\n", "RUN adduser galaxy -u {0}\n".format(uid))) 71 sys.stdout.write(re.sub("RUN adduser galaxy.*", "RUN adduser galaxy -u {0}\n".format(uid), line))
72 72
73 def build_docker(dockerfile, docker_client, image_tag='base'): 73 def build_docker(dockerfile, docker_client, image_tag='base'):
74 '''Given the path to a dockerfile, and a docker_client, build the image, if it does not 74 '''Given the path to a dockerfile, and a docker_client, build the image, if it does not
75 exist yet.''' 75 exist yet.'''
76 image_id='toolfactory/custombuild:'+image_tag 76 image_id='toolfactory/custombuild:'+image_tag