34 lines
866 B
Plaintext
34 lines
866 B
Plaintext
# Create user 'user' and add them to 'sudo' access and set
|
|
# the passwd to 'user'.
|
|
|
|
FROM xe-base-stage AS xe-user-stage
|
|
|
|
USER root
|
|
|
|
RUN zypper install -y sudo
|
|
|
|
# NOTE: Requires 'sudo' package to already be installed.
|
|
|
|
ARG USERNAME=user
|
|
ARG USER_UID=1000
|
|
ARG USER_GID=1000
|
|
|
|
RUN echo "Creating 'user': $USER_UID:$USER_GID"
|
|
|
|
RUN groupadd -r ${USERNAME} \
|
|
&& useradd --no-log-init \
|
|
-s /bin/bash \
|
|
-m \
|
|
-u ${USER_UID} \
|
|
-g ${USERNAME} \
|
|
-G users,video \
|
|
-p $(echo "${USERNAME}" | openssl passwd -stdin) ${USERNAME}
|
|
|
|
# Change ALL ALL=(ALL) ALL to use '%users...NOPASSWD:ALL'
|
|
RUN sed -i -e 's,^ALL.*,%users ALL=(ALL) NOPASSWD:ALL,g' /etc/sudoers
|
|
|
|
# Disable env clearing so USER env is available in SUDO
|
|
# Needed for env values set which are needed by the base OS, eg zypper
|
|
# and *_proxy *_PROXY...
|
|
RUN echo "Defaults !env_reset" >> /etc/sudoers
|