From 4acbffa010be046fc6404239d92717dfd6022d00 Mon Sep 17 00:00:00 2001 From: Mayank Chhabra Date: Fri, 17 Jul 2020 13:19:08 +0530 Subject: [PATCH 01/13] Use UID 1000 --- Dockerfile | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index fd8aaee..6db03fe 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,3 +1,5 @@ +ARG USER=umbrel + FROM alpine:3.11 RUN apk add --no-cache tor @@ -5,6 +7,8 @@ RUN apk add --no-cache tor VOLUME /etc/tor/ VOLUME /var/lib/tor/ +USER 1000:1000 + EXPOSE 9050 9051 29050 29051 -ENTRYPOINT ["tor"] \ No newline at end of file +ENTRYPOINT ["tor"] From 3becd03d33aad8b4f62fde6d2d4771b1a350756e Mon Sep 17 00:00:00 2001 From: Mayank Chhabra Date: Fri, 17 Jul 2020 13:29:18 +0530 Subject: [PATCH 02/13] Mount volumes after setting user --- Dockerfile | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index 6db03fe..ec14b57 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,14 +1,12 @@ -ARG USER=umbrel - FROM alpine:3.11 RUN apk add --no-cache tor +USER 1000:1000 + VOLUME /etc/tor/ VOLUME /var/lib/tor/ -USER 1000:1000 - EXPOSE 9050 9051 29050 29051 ENTRYPOINT ["tor"] From fee24ea4f17fc44d3ec3364e860317c724a68388 Mon Sep 17 00:00:00 2001 From: Mayank Chhabra Date: Fri, 17 Jul 2020 13:40:54 +0530 Subject: [PATCH 03/13] Create user --- Dockerfile | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index ec14b57..3b3dda3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,7 +2,14 @@ FROM alpine:3.11 RUN apk add --no-cache tor -USER 1000:1000 +# Create new tor user with GID and UID = 1000 +RUN adduser --disabled-password \ + --gecos "" \ + "tor" + +USER tor + +RUN mkdir -p "/.tor/" VOLUME /etc/tor/ VOLUME /var/lib/tor/ From 4529c6f4f11de0da7e64133279181f02819026fc Mon Sep 17 00:00:00 2001 From: Mayank Chhabra Date: Fri, 17 Jul 2020 13:44:38 +0530 Subject: [PATCH 04/13] Try adduser another way --- Dockerfile | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/Dockerfile b/Dockerfile index 3b3dda3..a679ff9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,14 +1,23 @@ FROM alpine:3.11 -RUN apk add --no-cache tor +ARG USER=tor +ARG UID=1000 +ARG GID=1000 + +RUN adduser \ + --disabled-password \ + --gecos "" \ + --home "$(pwd)" \ + --ingroup "$USER" \ + --no-create-home \ + --uid "$UID" \ + "$USER" -# Create new tor user with GID and UID = 1000 -RUN adduser --disabled-password \ - --gecos "" \ - "tor" USER tor +RUN apk add --no-cache tor + RUN mkdir -p "/.tor/" VOLUME /etc/tor/ From 870685671e6b5af9e825a7de48c92e1b43decc26 Mon Sep 17 00:00:00 2001 From: Mayank Chhabra Date: Fri, 17 Jul 2020 13:48:53 +0530 Subject: [PATCH 05/13] Add gid --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index a679ff9..3cb2705 100644 --- a/Dockerfile +++ b/Dockerfile @@ -8,9 +8,9 @@ RUN adduser \ --disabled-password \ --gecos "" \ --home "$(pwd)" \ - --ingroup "$USER" \ --no-create-home \ --uid "$UID" \ + --gid "$GID" \ "$USER" From 4f623380eb5156c0d2b7a45cf3329b729ec172aa Mon Sep 17 00:00:00 2001 From: Mayank Chhabra Date: Fri, 17 Jul 2020 13:50:03 +0530 Subject: [PATCH 06/13] Remove uid and gid --- Dockerfile | 4 ---- 1 file changed, 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index 3cb2705..85883b9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,16 +1,12 @@ FROM alpine:3.11 ARG USER=tor -ARG UID=1000 -ARG GID=1000 RUN adduser \ --disabled-password \ --gecos "" \ --home "$(pwd)" \ --no-create-home \ - --uid "$UID" \ - --gid "$GID" \ "$USER" From 1a837fb819caa45714b76e908f66ca5522c65986 Mon Sep 17 00:00:00 2001 From: Mayank Chhabra Date: Fri, 17 Jul 2020 13:51:20 +0530 Subject: [PATCH 07/13] Add tor package first --- Dockerfile | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index 85883b9..028f14f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,6 +2,8 @@ FROM alpine:3.11 ARG USER=tor +RUN apk add --no-cache tor + RUN adduser \ --disabled-password \ --gecos "" \ @@ -9,11 +11,8 @@ RUN adduser \ --no-create-home \ "$USER" - USER tor -RUN apk add --no-cache tor - RUN mkdir -p "/.tor/" VOLUME /etc/tor/ From 78a302c2a241e7f276f8cd44bc1a9aad096fd52d Mon Sep 17 00:00:00 2001 From: Mayank Chhabra Date: Fri, 17 Jul 2020 13:55:34 +0530 Subject: [PATCH 08/13] Try again --- Dockerfile | 2 -- 1 file changed, 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 028f14f..c5e1bb9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -7,8 +7,6 @@ RUN apk add --no-cache tor RUN adduser \ --disabled-password \ --gecos "" \ - --home "$(pwd)" \ - --no-create-home \ "$USER" USER tor From 1fa7c63c6fb08f0131f0299b98609b50e882dced Mon Sep 17 00:00:00 2001 From: Mayank Chhabra Date: Fri, 17 Jul 2020 14:00:42 +0530 Subject: [PATCH 09/13] Try adduser --- Dockerfile | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/Dockerfile b/Dockerfile index c5e1bb9..474d63a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,11 +3,8 @@ FROM alpine:3.11 ARG USER=tor RUN apk add --no-cache tor - -RUN adduser \ - --disabled-password \ - --gecos "" \ - "$USER" + && addgroup -S appgroup + && adduser -S $USER -G appgroup USER tor From 1bae43d1a9b42d19b7272950df60c73a5da94158 Mon Sep 17 00:00:00 2001 From: Mayank Chhabra Date: Fri, 17 Jul 2020 14:01:52 +0530 Subject: [PATCH 10/13] Remove newlines --- Dockerfile | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index 474d63a..4550383 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,9 +2,7 @@ FROM alpine:3.11 ARG USER=tor -RUN apk add --no-cache tor - && addgroup -S appgroup - && adduser -S $USER -G appgroup +RUN apk add --no-cache tor && addgroup -S appgroup && adduser -S $USER -G appgroup USER tor From 11c8f2bafdf5c211b8ea6b40d1e4d729848833bf Mon Sep 17 00:00:00 2001 From: Mayank Chhabra Date: Fri, 17 Jul 2020 14:31:02 +0530 Subject: [PATCH 11/13] Try adduser --- Dockerfile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 4550383..288a17d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,7 +2,9 @@ FROM alpine:3.11 ARG USER=tor -RUN apk add --no-cache tor && addgroup -S appgroup && adduser -S $USER -G appgroup +RUN apk add --no-cache tor + +RUN adduser -D -g '' tor USER tor From a42a1cb97fe83bcd8be3060b0a62016dba6754ed Mon Sep 17 00:00:00 2001 From: Mayank Chhabra Date: Fri, 17 Jul 2020 15:44:44 +0530 Subject: [PATCH 12/13] Change username --- Dockerfile | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/Dockerfile b/Dockerfile index 288a17d..26017b2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,14 +1,15 @@ -FROM alpine:3.11 +ARG USER=toruser +ARG UID=1000 -ARG USER=tor +FROM alpine:3.11 RUN apk add --no-cache tor -RUN adduser -D -g '' tor - -USER tor - -RUN mkdir -p "/.tor/" +RUN adduser \ + --disabled-password \ + --gecos "" \ + --uid "$UID" \ + "$USER" VOLUME /etc/tor/ VOLUME /var/lib/tor/ From 28eee0d77762e4fa955c1766c58886b422e00ba2 Mon Sep 17 00:00:00 2001 From: Mayank Chhabra Date: Fri, 17 Jul 2020 15:57:48 +0530 Subject: [PATCH 13/13] Use ARG after FROM --- Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 26017b2..b4acd05 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,8 +1,8 @@ +FROM alpine:3.11 + ARG USER=toruser ARG UID=1000 -FROM alpine:3.11 - RUN apk add --no-cache tor RUN adduser \