Optimized Dockerfile
This commit is contained in:
parent
e18d1c9aeb
commit
12e3414833
1 changed files with 9 additions and 6 deletions
15
Dockerfile
15
Dockerfile
|
@ -1,14 +1,17 @@
|
||||||
FROM golang:1.23.2 as build
|
FROM golang:1.23.2-alpine AS build
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
COPY . .
|
COPY go.mod go.sum ./
|
||||||
|
|
||||||
RUN go mod download
|
RUN go mod download
|
||||||
RUN CGO_ENABLED=0 go build -ldflags="-s -w" -o /go/bin/app
|
|
||||||
|
|
||||||
FROM gcr.io/distroless/base-debian12
|
COPY . .
|
||||||
|
|
||||||
COPY --from=build /go/bin/app /
|
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-s -w" -o /go/bin/app
|
||||||
|
|
||||||
CMD [ "/app" ]
|
FROM scratch
|
||||||
|
|
||||||
|
COPY --from=build /go/bin/app /app
|
||||||
|
|
||||||
|
ENTRYPOINT ["/app"]
|
||||||
|
|
Loading…
Add table
Reference in a new issue