aboutsummaryrefslogtreecommitdiff
path: root/docker
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2024-02-09 22:24:36 +0800
committercrupest <crupest@outlook.com>2024-02-09 22:24:36 +0800
commit07ae0f955721866287bf56de478164cc83aaf9e1 (patch)
treec0e69ae84d4dc2eaea1daf580c1c994547cfcc1d /docker
parent7e2870588fb804aa58dcea88f8b8c3d070fea9dd (diff)
downloadcrupest-07ae0f955721866287bf56de478164cc83aaf9e1.tar.gz
crupest-07ae0f955721866287bf56de478164cc83aaf9e1.tar.bz2
crupest-07ae0f955721866287bf56de478164cc83aaf9e1.zip
docker(debian-dev): use an ordinary user rather than root.
Diffstat (limited to 'docker')
-rw-r--r--docker/debian-dev/Dockerfile7
-rwxr-xr-xdocker/debian-dev/bootstrap/apt-source/get-domain.bash1
-rwxr-xr-xdocker/debian-dev/bootstrap/apt-source/setup.bash5
-rwxr-xr-xdocker/debian-dev/bootstrap/setup-user.bash9
-rwxr-xr-xdocker/debian-dev/bootstrap/setup.bash1
5 files changed, 17 insertions, 6 deletions
diff --git a/docker/debian-dev/Dockerfile b/docker/debian-dev/Dockerfile
index 83e5717..ce0b10c 100644
--- a/docker/debian-dev/Dockerfile
+++ b/docker/debian-dev/Dockerfile
@@ -1,8 +1,10 @@
FROM debian:11
+ARG USERNAME=
ARG IN_CHINA=
ARG SETUP_SBUILD=
+ENV USERNAME=${USERNAME}
ENV IN_CHINA=${IN_CHINA}
ENV SETUP_SBUILD=${SETUP_SBUILD}
@@ -10,6 +12,7 @@ ADD bootstrap /bootstrap
RUN /bootstrap/setup.bash
-VOLUME [ "/source", "/data" ]
-CMD [ "bash", "-l" ]
+USER ${USERNAME}
+VOLUME [ "/source", "/data", "/share" ]
+CMD [ "bash", "-l" ]
diff --git a/docker/debian-dev/bootstrap/apt-source/get-domain.bash b/docker/debian-dev/bootstrap/apt-source/get-domain.bash
index c9b93b1..d44ea65 100755
--- a/docker/debian-dev/bootstrap/apt-source/get-domain.bash
+++ b/docker/debian-dev/bootstrap/apt-source/get-domain.bash
@@ -3,4 +3,3 @@
set -e
sed "s|.*https\?://\([-_.a-zA-Z0-9]\+\)/.*|\\1|;q" /etc/apt/sources.list
-
diff --git a/docker/debian-dev/bootstrap/apt-source/setup.bash b/docker/debian-dev/bootstrap/apt-source/setup.bash
index 36065f6..60e635b 100755
--- a/docker/debian-dev/bootstrap/apt-source/setup.bash
+++ b/docker/debian-dev/bootstrap/apt-source/setup.bash
@@ -2,12 +2,11 @@
set -e
-dir=$(dirname $0)
+dir=$(dirname "$0")
if [[ -n $IN_CHINA ]]; then
- "$dir/replace-domain.bash" $(cat "$dir/china-source.txt")
+ "$dir/replace-domain.bash" "$(cat "$dir/china-source.txt")"
fi
"$dir/install-apt-https.bash"
"$dir/replace-http.bash"
-
diff --git a/docker/debian-dev/bootstrap/setup-user.bash b/docker/debian-dev/bootstrap/setup-user.bash
new file mode 100755
index 0000000..0eccde4
--- /dev/null
+++ b/docker/debian-dev/bootstrap/setup-user.bash
@@ -0,0 +1,9 @@
+#! /usr/bin/env bash
+
+set -e
+
+apt-get install -y sudo
+
+sed -i.bak 's|%sudo[[:space:]]\+ALL=(ALL:ALL)[[:space:]]\+ALL|%sudo ALL=(ALL:ALL) NOPASSWD: ALL|' /etc/sudoers
+
+useradd -m -G sudo -s /usr/bin/bash "$USERNAME"
diff --git a/docker/debian-dev/bootstrap/setup.bash b/docker/debian-dev/bootstrap/setup.bash
index 2aa88e0..c72db87 100755
--- a/docker/debian-dev/bootstrap/setup.bash
+++ b/docker/debian-dev/bootstrap/setup.bash
@@ -5,6 +5,7 @@ set -e
export DEBIAN_FRONTEND=noninteractive
/bootstrap/apt-source/setup.bash
+/bootstrap/setup-user.bash
/bootstrap/setup-base.bash
/bootstrap/setup-dev.bash