Mercurial > hg-stable
changeset 22440:cf7b5c011737
dockerrpm: run docker build process as the current user, not as root
Docker can be run by ordinary users if they are in the docker group. The build
process would however be run as a root user, only protected by the sandboxing.
That caused problems with the shared directory where rpmbuild would be picky
about building from sources owned by less privileged users and producing files
owned by root.
Instead, add a build user with the right uid/gid to the image and run the
docker process as that user.
author | Mads Kiilerich <madski@unity3d.com> |
---|---|
date | Fri, 30 May 2014 14:14:33 +0200 |
parents | d2a00ced3cce |
children | bb9a06d14857 |
files | contrib/dockerrpm |
diffstat | 1 files changed, 8 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/contrib/dockerrpm Fri May 30 14:14:33 2014 +0200 +++ b/contrib/dockerrpm Fri May 30 14:14:33 2014 +0200 @@ -24,6 +24,12 @@ CONTAINER="hg-dockerrpm-$PLATFORM" -$DOCKER build --tag $CONTAINER - < $DFILE -$DOCKER run --rm -v $ROOTDIR:/hg $CONTAINER bash -c \ +DBUILDUSER=build +( +cat $DFILE +echo RUN groupadd $DBUILDUSER -g `id -g` +echo RUN useradd $DBUILDUSER -u `id -u` -g $DBUILDUSER +) | $DOCKER build --tag $CONTAINER - + +$DOCKER run -u $DBUILDUSER --rm -v $ROOTDIR:/hg $CONTAINER bash -c \ "cp -a hg hg-build; cd hg-build; make clean local $PLATFORM; cp packages/$PLATFORM/* /hg/packages/$PLATFORM/"