Skip to content

Commit

Permalink
Add code from PR amitshekhariitbhu#4 - Minify and secure docker image
Browse files Browse the repository at this point in the history
  • Loading branch information
Yuri-SN committed Aug 27, 2023
1 parent dcde553 commit 85f83da
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
FROM golang:1.19-alpine

RUN mkdir /app

ADD . /app

WORKDIR /app

RUN go build -o main cmd/main.go

CMD ["/app/main"]
FROM golang:1.19-alpine as builder
WORKDIR /
COPY go.mod .
RUN go mod download
COPY . .
RUN mkdir exec
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -o exec/main cmd/main.go

FROM gcr.io/distroless/static:nonroot
WORKDIR /
COPY --from=builder /exec /app
USER 65532:65532
ENTRYPOINT ["/app/main"]

0 comments on commit 85f83da

Please sign in to comment.