Skip to content

Commit 56c0bf5

Browse files
authored
Update Dockerfile to specific version and use of nonroot user (#322)
* using alpine specific version instead of latest * running container with nonroot user
1 parent e38a410 commit 56c0bf5

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

Dockerfile

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,11 @@ RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -ldflags="-w -s -X '
2323

2424

2525
# get latest alpine container
26-
FROM alpine:latest
26+
FROM alpine:3.19.1
27+
28+
# create nonroot user
29+
RUN addgroup -S nonroot \
30+
&& adduser -S nonroot -G nonroot
2731

2832
# add ca-certificates
2933
RUN apk --no-cache add ca-certificates tzdata
@@ -34,6 +38,9 @@ WORKDIR /root/
3438
# copy binary from first container
3539
COPY --from=0 /go/src/app .
3640

41+
# set user
42+
USER nonroot
43+
3744
# expose port 8080
3845
EXPOSE 8080
3946

0 commit comments

Comments
 (0)