mirror of
https://github.com/vyos/vyos-build.git
synced 2025-10-01 20:28:40 +02:00
Change user on docker image to the current owner of the volume directory (GOSU)
Insted of hardcoding the user used to build inside the container it will now be auto configured to be the user UID that owns the vyos-build directory This is done with the gosu utillity and a entrypoint script
This commit is contained in:
parent
88c8b3440b
commit
ed03c43b2a
13
Dockerfile
13
Dockerfile
@ -5,6 +5,7 @@ FROM debian:jessie
|
||||
|
||||
RUN echo 'deb http://ftp.debian.org/debian jessie-backports main' | tee -a /etc/apt/sources.list &&\
|
||||
apt-get update && apt-get install -y \
|
||||
gosu \
|
||||
vim \
|
||||
git \
|
||||
make \
|
||||
@ -143,10 +144,12 @@ RUN export LATEST="$(curl -s https://checkpoint-api.hashicorp.com/v1/check/packe
|
||||
curl -K- | gzip -d > /usr/bin/packer && \
|
||||
chmod +x /usr/bin/packer
|
||||
|
||||
COPY scripts/docker-entrypoint.sh /usr/local/bin/
|
||||
# Create vyos_bld user account and enable sudo
|
||||
RUN useradd -ms /bin/bash -u 1006 --gid users vyos_bld && \
|
||||
usermod -aG sudo vyos_bld && \
|
||||
echo "%sudo ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers
|
||||
#RUN useradd -ms /bin/bash -u 1006 --gid users vyos_bld && \
|
||||
# usermod -aG sudo vyos_bld && \
|
||||
# echo "%sudo ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers
|
||||
|
||||
USER vyos_bld
|
||||
WORKDIR /home/vyos_bld
|
||||
#USER vyos_bld
|
||||
#WORKDIR /home/vyos_bld
|
||||
ENTRYPOINT ["docker-entrypoint.sh"]
|
||||
|
||||
17
scripts/docker-entrypoint.sh
Executable file
17
scripts/docker-entrypoint.sh
Executable file
@ -0,0 +1,17 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
# Use GOSU_USER if its specified, else wirking dir user
|
||||
if [ -n "$GOSU_USER" ]; then
|
||||
ID=$GOSU_USER
|
||||
else
|
||||
ID=$(stat -c "%u:%g" .)
|
||||
fi
|
||||
|
||||
# Don't use GOSU if we are root
|
||||
if [ ! "$ID" = "0:0" ]; then
|
||||
exec gosu $ID "$@"
|
||||
else
|
||||
exec "$@"
|
||||
fi
|
||||
Loading…
x
Reference in New Issue
Block a user