Skip to content

Commit 6a67802

Browse files
committed
change to nonroot
1 parent c722be4 commit 6a67802

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

httpserver/Dockerfile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,9 @@ ENV MY_SERVICE_PORT2=80
55
ENV MY_SERVICE_PORT3=80
66
LABEL multi.label1="value1" multi.label2="value2" other="value3"
77
ADD bin/amd64/httpserver /httpserver
8-
EXPOSE 80
8+
EXPOSE 8080
9+
RUN useradd -m --uid 1000 web-admin && \
10+
echo "web-admin ALL=NOPASSWD: ALL" >> /etc/sudoers
11+
RUN chown web-admin /httpserver
12+
USER web-admin
913
ENTRYPOINT ["/httpserver"]

httpserver/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export tag=v1.0-metrics
1+
export tag=v1.0-nonroot
22
root:
33
export ROOT=github.com/cncamp/golang
44

httpserver/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ func main() {
3030
mux.Handle("/metrics", promhttp.Handler())
3131

3232
srv := http.Server{
33-
Addr: ":80",
33+
Addr: ":8080",
3434
Handler: mux,
3535
}
3636
done := make(chan os.Signal, 1)

0 commit comments

Comments
 (0)