diff --git a/.env b/.env new file mode 100644 index 0000000..3a8c6a2 --- /dev/null +++ b/.env @@ -0,0 +1,2 @@ +USER_ID=1000 +USER_GID=1000 diff --git a/Dockerfile b/Dockerfile index 29c386c..bfa6664 100644 --- a/Dockerfile +++ b/Dockerfile @@ -13,10 +13,15 @@ # with this program; if not, write to the Free Software Foundation, Inc., # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -FROM crops/yocto:ubuntu-14.04-base +FROM crops/yocto:ubuntu-16.04-base USER root +# The repo tool is used by a lot of yocto builds add it +RUN apt-get update \ + && apt-get install -y repo \ + && rm -rf /var/lib/apt/lists/* + ADD https://raw.githubusercontent.com/crops/extsdk-container/master/restrict_useradd.sh \ https://raw.githubusercontent.com/crops/extsdk-container/master/restrict_groupadd.sh \ https://raw.githubusercontent.com/crops/extsdk-container/master/usersetup.py \ @@ -39,5 +44,6 @@ RUN userdel -r yoctouser && \ USER usersetup ENV LANG=en_US.UTF-8 +ENV USER_ID=1000 USER_GID=1000 ENTRYPOINT ["/usr/bin/dumb-init", "--", "/usr/bin/poky-entry.py"] diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..b0f52da --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,23 @@ +# +# set the USER_ID and USER_GID in the .env file +# +# $ printf "USER_ID=$(id -u)\nUSER_GID=$(id -g)\n" > .env +# +# then launch this with: +# +# $ docker-compose build poky +# $ docker-compose run --rm poky + +version: '2' + +services: + poky: + build: . + image: crops/poky:latest + + environment: + - USER_ID + - USER_GID + + volumes: + - ./workspace:/workspace diff --git a/poky-entry.py b/poky-entry.py index 5e057fe..7b5a599 100755 --- a/poky-entry.py +++ b/poky-entry.py @@ -44,7 +44,8 @@ if args.id: uid, gid = args.id.split(":") idargs = "--uid={} --gid={}".format(uid, gid) - +elif os.environ.get('USER_ID') and os.environ.get('USER_GID'): + idargs = "--uid={} --gid={}".format(os.environ['USER_ID'], os.environ['USER_GID']) elif args.workdir == '/home/pokyuser': # If the workdir wasn't specified pick a default uid and gid since # usersetup won't be able to calculate it from the non-existent workdir diff --git a/workspace/README b/workspace/README new file mode 100644 index 0000000..e69de29