update Dockerfile to specific version and use of nonroot user (#266)

* using alpine specific version instead of latest
* running container with nonroot user
This commit is contained in:
Tobias Lindberg
2024-02-05 11:23:14 +01:00
committed by GitHub
parent ab69d262c6
commit fc5fb63f03
+9 -2
View File
@@ -20,8 +20,12 @@ COPY src/ .
RUN CGO_ENABLED=0 go build -ldflags="-w -s -X 'main.apiVersion=${apiVersion}'" -o app ./...
# get latest alpine container
FROM alpine:latest
# get alpine container
FROM alpine:alpine:3.19.1
# create nonroot user
RUN addgroup -S nonroot \
&& adduser -S nonroot -G nonroot
# add ca-certificates
RUN apk --no-cache add ca-certificates tzdata
@@ -32,6 +36,9 @@ WORKDIR /root/
# copy binary from first container
COPY --from=0 /go/src/app .
# set user
USER nonroot
# expose port 8080
EXPOSE 8080