From 1675e4cd8aa6b7523eb99f6cc38e0a228913240d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Paulo=20Dubas?= Date: Wed, 25 Oct 2023 23:30:02 +0000 Subject: [PATCH] feat: customize user and group id on build time (#3) Allow the user to set custom user and group IDs, so it maps the ones available in the host. Also, remove `jq` from `rtx` plugin list. --- Dockerfile | 20 +++++++++++++++----- config/rtx/config.toml | 1 - 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/Dockerfile b/Dockerfile index b4117c4..6a60d79 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,10 @@ FROM ubuntu:22.04 # system deps +ARG USER_UID=1000 +ARG USER_GID=1000 +ARG DOCKER_GID=999 +ARG WHEEL_GID=980 ENV DEBIAN_FRONTEND noninteractive RUN apt-get update \ && apt-get install -y software-properties-common \ @@ -71,11 +75,11 @@ RUN apt-get update \ && rm -rf /var/lib/apt/lists/* \ && locale-gen en_US.UTF-8 \ && echo 'setup unprivileged user' \ - && groupadd --gid 980 wheel \ - && groupadd --gid 999 docker \ - && groupadd --gid 1000 coder \ + && groupadd --gid ${WHEEL_GID} wheel \ + && groupadd --gid ${DOCKER_GID} docker \ + && groupadd --gid ${USER_GID} coder \ && useradd \ - --uid 1000 \ + --uid ${USER_UID} \ --gid coder \ --groups docker,wheel \ --shell $(which fish) \ @@ -154,13 +158,19 @@ RUN fish -c true \ && echo 'eval "$(${XDG_DATA_HOME}/rtx/bin/rtx activate bash)"' >> ${HOME}/.bashrc \ && echo 'eval "$(zoxide init bash)"' >> ${HOME}/.bashrc +# configure git +ARG GIT_USER_EMAIL +ARG GIT_USER_NAME +RUN git config --global user.email "${GIT_USER_EMAIL}" \ + && git config --global user.name "${GIT_USER_NAME}" \ + && git config --global core.editor nvim + # install rtx plugins RUN ${XDG_DATA_HOME}/rtx/bin/rtx plugins install \ awscli \ elixir \ erlang \ helm \ - jq \ kubectl \ poetry \ terraform diff --git a/config/rtx/config.toml b/config/rtx/config.toml index c751f66..e457419 100644 --- a/config/rtx/config.toml +++ b/config/rtx/config.toml @@ -4,7 +4,6 @@ elixir = "1.15.4-otp-26" erlang = "26.0.2" go = "1.20.6" helm = "3.12.2" -jq = "1.7" kubectl = "1.27.4" node = "20.6.1" poetry = "1.5.1"