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.
This commit is contained in:
João Paulo Dubas 2023-10-25 23:30:02 +00:00
parent 3293ae8a3e
commit 1675e4cd8a
2 changed files with 15 additions and 6 deletions

View File

@ -1,6 +1,10 @@
FROM ubuntu:22.04 FROM ubuntu:22.04
# system deps # system deps
ARG USER_UID=1000
ARG USER_GID=1000
ARG DOCKER_GID=999
ARG WHEEL_GID=980
ENV DEBIAN_FRONTEND noninteractive ENV DEBIAN_FRONTEND noninteractive
RUN apt-get update \ RUN apt-get update \
&& apt-get install -y software-properties-common \ && apt-get install -y software-properties-common \
@ -71,11 +75,11 @@ RUN apt-get update \
&& rm -rf /var/lib/apt/lists/* \ && rm -rf /var/lib/apt/lists/* \
&& locale-gen en_US.UTF-8 \ && locale-gen en_US.UTF-8 \
&& echo 'setup unprivileged user' \ && echo 'setup unprivileged user' \
&& groupadd --gid 980 wheel \ && groupadd --gid ${WHEEL_GID} wheel \
&& groupadd --gid 999 docker \ && groupadd --gid ${DOCKER_GID} docker \
&& groupadd --gid 1000 coder \ && groupadd --gid ${USER_GID} coder \
&& useradd \ && useradd \
--uid 1000 \ --uid ${USER_UID} \
--gid coder \ --gid coder \
--groups docker,wheel \ --groups docker,wheel \
--shell $(which fish) \ --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 "$(${XDG_DATA_HOME}/rtx/bin/rtx activate bash)"' >> ${HOME}/.bashrc \
&& echo 'eval "$(zoxide init 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 # install rtx plugins
RUN ${XDG_DATA_HOME}/rtx/bin/rtx plugins install \ RUN ${XDG_DATA_HOME}/rtx/bin/rtx plugins install \
awscli \ awscli \
elixir \ elixir \
erlang \ erlang \
helm \ helm \
jq \
kubectl \ kubectl \
poetry \ poetry \
terraform terraform

View File

@ -4,7 +4,6 @@ elixir = "1.15.4-otp-26"
erlang = "26.0.2" erlang = "26.0.2"
go = "1.20.6" go = "1.20.6"
helm = "3.12.2" helm = "3.12.2"
jq = "1.7"
kubectl = "1.27.4" kubectl = "1.27.4"
node = "20.6.1" node = "20.6.1"
poetry = "1.5.1" poetry = "1.5.1"