File tree Expand file tree Collapse file tree 1 file changed +13
-12
lines changed Expand file tree Collapse file tree 1 file changed +13
-12
lines changed Original file line number Diff line number Diff line change 11# get golang container
2- FROM golang:1.22.1
2+ FROM golang:1.22.1 AS builder
33
44# get args
55ARG TibiaDataBuildBuilder=dockerfile
@@ -23,23 +23,24 @@ RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -ldflags="-w -s -X '
2323
2424
2525# get alpine container
26- FROM alpine:3.19.1
26+ FROM alpine:3.19.1 AS app
2727
28- # create nonroot user
29- RUN addgroup -S nonroot \
30- && adduser -S nonroot -G nonroot
28+ # create workdir
29+ WORKDIR /opt/app
3130
32- # add ca-certificates
31+ # add ca-certificates and tzdata
3332RUN apk --no-cache add ca-certificates tzdata
3433
35- # create workdir
36- WORKDIR /root/
34+ # create nonroot user and group
35+ RUN addgroup -S nonroot && \
36+ adduser -S nonroot -G nonroot && \
37+ chown -R nonroot:nonroot .
3738
38- # copy binary from first container
39- COPY --from=0 /go/src/app .
39+ # set user to nonroot
40+ USER nonroot:nonroot
4041
41- # set user
42- USER nonroot
42+ # copy binary from builder
43+ COPY --from=builder --chown= nonroot:nonroot --chmod=544 /go/src/app .
4344
4445# expose port 8080
4546EXPOSE 8080
You can’t perform that action at this time.
0 commit comments