diff --git a/Dockerfile b/Dockerfile index e754b62..6ed8ef3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,13 @@ FROM ubuntu:rolling -COPY scripts/docker-install.bash /tmp/ -RUN /tmp/docker-install.bash +ARG UID +COPY scripts/docker-install.bash /tmp/ +RUN /tmp/docker-install.bash "$UID" + +USER $UID +WORKDIR /home/docker EXPOSE 6119 + +ENTRYPOINT ["/usr/local/bin/pid1.bash"] +COPY scripts/pid1.bash /usr/local/bin/ diff --git a/scripts/docker-install.bash b/scripts/docker-install.bash index 566fe41..f3a7400 100755 --- a/scripts/docker-install.bash +++ b/scripts/docker-install.bash @@ -3,6 +3,13 @@ set -e set -o pipefail +if (( $# != 1 )); then + echo "usage: docker-install.bash UID" >&2 + exit 1 +fi + +uid="$1" + packages=" # Handy utilities @@ -38,4 +45,11 @@ apt-get update apt-get install -y $(grep -v "^#" <<< "$packages") rm -rf /var/lib/apt/lists/* +if (( "$uid" != 0 )); then + useradd --uid="$uid" --create-home --groups sudo docker + passwd -d docker +else + ln -s /root /home/docker +fi + rm "$0" diff --git a/scripts/pid1.bash b/scripts/pid1.bash new file mode 100755 index 0000000..ce990ca --- /dev/null +++ b/scripts/pid1.bash @@ -0,0 +1,10 @@ +#!/usr/bin/env bash + +set -e +set -o pipefail + +export LANG=C.UTF-8 +export LC_ALL=C.UTF-8 +export SHELL="$(which bash)" + +exec "$@"