mirror of
https://github.com/tobiasehlert/teslamateapi.git
synced 2026-02-27 09:54:18 +08:00
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:
+9
-2
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user