mirror of
https://github.com/sipeed/NanoKVM.git
synced 2026-11-09 17:44:43 -06:00
fix: fix container slow caused by uid/gid
This commit is contained in:
@@ -6,7 +6,10 @@ RUN apt update \
|
||||
&& apt install wget git cmake build-essential python3 python3-venv python3-pip autoconf automake libtool gosu -y
|
||||
|
||||
ARG DOCKER_USER=build
|
||||
RUN useradd -m "$DOCKER_USER"
|
||||
ARG DOCKER_UID=1000
|
||||
ARG DOCKER_GID=1000
|
||||
RUN groupadd --gid "$DOCKER_GID" "$DOCKER_USER" \
|
||||
&& useradd --uid "$DOCKER_UID" --gid "$DOCKER_GID" --create-home --shell /bin/bash "$DOCKER_USER"
|
||||
USER $DOCKER_USER
|
||||
|
||||
FROM base_apt AS host_tools
|
||||
@@ -76,4 +79,4 @@ USER root
|
||||
RUN chmod 0755 /entrypoint \
|
||||
&& sed "s/\$DOCKER_USER/$DOCKER_USER/g" -i /entrypoint
|
||||
|
||||
ENTRYPOINT ["/entrypoint"]
|
||||
ENTRYPOINT ["/entrypoint"]
|
||||
|
||||
14
docker/entrypoint
Normal file → Executable file
14
docker/entrypoint
Normal file → Executable file
@@ -12,11 +12,19 @@ fi
|
||||
|
||||
if [ "$UID" != 0 ]
|
||||
then
|
||||
usermod -u "$UID" "$DOCKER_USER" 2>/dev/null && {
|
||||
current_uid="$(id -u "$DOCKER_USER")"
|
||||
current_gid="$(id -g "$DOCKER_USER")"
|
||||
|
||||
if [ "$current_uid" != "$UID" ]; then
|
||||
usermod -u "$UID" "$DOCKER_USER"
|
||||
fi
|
||||
|
||||
if [ "$current_gid" != "$GID" ]; then
|
||||
groupmod -g "$GID" "$DOCKER_USER" 2>/dev/null ||
|
||||
usermod -a -G "$GID" "$DOCKER_USER"
|
||||
}
|
||||
fi
|
||||
|
||||
set -- gosu "${UID}:${GID}" "${@}"
|
||||
fi
|
||||
|
||||
exec "$@"
|
||||
exec "$@"
|
||||
|
||||
Reference in New Issue
Block a user