Skip to content

Commit

Permalink
fixed docker userid to have docker process now run with current useri…
Browse files Browse the repository at this point in the history
…d again.
  • Loading branch information
Patrick Stein authored and Patrick Stein committed Aug 28, 2021
1 parent d34f5d9 commit 7081719
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,6 @@ then
exit 1
fi

#
# as long as swift does not run as user
# make the container files at least be our group
chmod g+s "$packagedir"

cd "$packagedir"
mkdir "$buildpath" 2>/dev/null

Expand All @@ -43,28 +38,33 @@ EOF

chmod ugo+x "buildandstart.sh"

DOCKER_UID=$(id -u ${USER})
DOCKER_GID=$(id -g ${USER})

docker build -t swift:latest -<<EOF
FROM swiftarm/swift:latest
WORKDIR /home
CMD ["/home/buildandstart.sh"]
RUN groupadd -g $DOCKER_GID swift
RUN useradd -m -u $DOCKER_UID -g swift swift
USER swift
WORKDIR /home/swift
CMD ["/home/swift/buildandstart.sh"]
EOF

# docker image inspect swift:latest >/dev/null 2>/dev/null || docker build -t swift:latest .

docker stop $programname
docker container rm $programname

# futurejones swift was able to run as user in docker
# current version does not ;-(
#-u $(id -u ${USER}):$(id -g ${USER}) \

docker run \
--detach --restart=always \
--user :$(id -g ${USER}) \
-u $DOCKER_UID:$DOCKER_GID \
--net service16 \
--log-opt max-size=1m --log-opt max-file=2 \
-v "$packagedir":/home \
-v "$packagedir":/home/swift \
--name "$programname" \
swift:latest

docker network connect mqtt-net "$programname"

0 comments on commit 7081719

Please sign in to comment.