From be412073742ea08d14d3b655e0aad01e6ec6a8f2 Mon Sep 17 00:00:00 2001 From: Varsha Varadarajan Date: Mon, 11 Sep 2017 21:09:18 +0530 Subject: [PATCH] Allow users to build images by providing uid and gid as build args. --- Dockerfile.erb | 3 +++ Rakefile | 12 ++++++------ 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/Dockerfile.erb b/Dockerfile.erb index 1b55e1d..59d83c7 100644 --- a/Dockerfile.erb +++ b/Dockerfile.erb @@ -33,6 +33,9 @@ ADD <%= meta[:url] %> <%= file %> # force encoding ENV LANG=en_US.utf8 +ARG UID=1000 +ARG GID=1000 + RUN \ <% unless add_files.empty? -%> # add mode and permissions for files we added above diff --git a/Rakefile b/Rakefile index 912a88f..434d847 100644 --- a/Rakefile +++ b/Rakefile @@ -53,8 +53,8 @@ tini_and_gosu_add_file_meta = { } create_user_and_group_cmd = [ - 'groupadd -g 1000 go', - 'useradd -u 1000 -g go -d /home/go -m go' + 'groupadd -g ${GID} go', + 'useradd -u ${UID} -g go -d /home/go -m go' ] [ @@ -63,8 +63,8 @@ create_user_and_group_cmd = [ version: '3.5', add_files: tini_and_gosu_add_file_meta, create_user_and_group: [ - 'addgroup -g 1000 go', - 'adduser -D -u 1000 -G go go' + 'addgroup -g ${GID} go', + 'adduser -D -u ${UID} -G go go' ], before_install: [ 'apk --no-cache upgrade', @@ -76,8 +76,8 @@ create_user_and_group_cmd = [ version: '3.6', add_files: tini_and_gosu_add_file_meta, create_user_and_group: [ - 'addgroup -g 1000 go', - 'adduser -D -u 1000 -G go go' + 'addgroup -g ${GID} go', + 'adduser -D -u ${UID} -G go go' ], before_install: [ 'apk --no-cache upgrade',