From 72c193e5e950fd5cb41aedda9f3cbafd0c8670c3 Mon Sep 17 00:00:00 2001 From: Monty Taylor Date: Sat, 26 Jul 2014 11:23:34 -0700 Subject: [PATCH] Run tests as host user testr writes files into the local dir, which is cool and works because of the bind mount - but if we don't run as the same UID as the executing user, then we'll write unreadable data into .testrepository. --- dox/runner.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/dox/runner.py b/dox/runner.py index a11a591..ce50a1c 100644 --- a/dox/runner.py +++ b/dox/runner.py @@ -116,6 +116,10 @@ class Runner(object): dockerfile.append("FROM %s" % image) try: tempd = tempfile.mkdtemp() + dockerfile.append( + "RUN groupadd -g %(gid)s %(user)s" + " && useradd -d /src -g %(gid)s -u %(uid)s %(user)s" % dict( + uid=os.getuid(), gid=os.getgid(), user=os.getlogin())) for add_file in commands.get_add_files(): shutil.copy(add_file, os.path.join(tempd, add_file)) dockerfile.append("ADD %s /dox/" % add_file) @@ -131,7 +135,7 @@ class Runner(object): def run_commands(self, command): self._docker_run( - '--rm', + '--rm', '--user=%s' % os.getlogin(), '-v', "%s:/src" % os.path.abspath('.'), '-w', '/src', self.test_image_name, *command)