Don't run useradd for root

When running dox with an user_map check whether the user is root and
skip the useradd command on image build if so. Most (all?) images have a
root user anyway.

Change-Id: I08eb60254fb437e02c61025d0a7761eb774c11f3
This commit is contained in:
Flavio Percoco 2015-08-18 00:22:40 +02:00
parent 1f63004479
commit ea141b9715
1 changed files with 7 additions and 5 deletions

View File

@ -148,11 +148,13 @@ class Runner(object):
dockerfile.append("FROM %s" % image)
try:
tempd = tempfile.mkdtemp()
dockerfile.append(
"RUN useradd -M -U -d /src -u %(uid)s %(user)s" % dict(
uid=self.user_map['uid'],
gid=self.user_map['gid'],
user=self.user_map['username']))
if not self.user_map['username'] == 'root':
dockerfile.append(
"RUN useradd -M -U -d /src -u %(uid)s %(user)s" % dict(
uid=self.user_map['uid'],
gid=self.user_map['gid'],
user=self.user_map['username']))
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)