improved user managment in client Dockerfile with args

This commit is contained in:
2020-07-14 11:41:10 +02:00
parent 82ae413857
commit 8a6a9de45d
2 changed files with 16 additions and 7 deletions
+12 -7
View File
@@ -4,21 +4,26 @@ RUN apk update && apk --no-cache add shadow && \
usermod -u 1001 node && \
groupmod -g 1001 node
RUN find / -group 1000 -exec chgrp -h node {} \;
RUN find / -user 1000 -exec chown -h node {} \;
ARG UID=1000
ARG UNAME=gdp
ARG GID=1000
ARG GNAME=users
RUN find / -group $UID -exec chgrp -h node {} \;
RUN find / -user $UID -exec chown -h node {} \;
# RUN addgroup -g 1000 gdp && \
# adduser -h /home/gdp -D -u 1000 gdp && \
RUN adduser -u 1000 -G users -s /bin/sh -D gdp
RUN adduser -u $UID -G $GNAME -s /bin/sh -D $UNAME
# chown -R gdp:gdp /home/gdp
USER gdp
USER $UNAME
COPY ./bashrc /home/gdp/.bashrc
COPY ./inputrc /home/gdp/.inputrc
COPY ./bashrc /home/$UNAME/.bashrc
COPY ./inputrc /home/$UNAME/.inputrc
COPY ./client-entrypoint.sh /usr/local/bin
USER root
RUN chmod +x /usr/local/bin/client-entrypoint.sh
USER gdp
USER $UNAME
CMD ["/bin/sh","/usr/local/bin/client-entrypoint.sh"]
+4
View File
@@ -25,6 +25,10 @@ only before the first run (may take some time)
```
sudo docker-compose build
```
or with args for groups and users
```
docker build --build-arg UID=$(id -u) --build-arg GID=$(id -g) --build-arg UNAME=$(id -g) --build-arg GNAME=$(id -g)
```
### run
then each time you want to launch the app
```