Skip to content

Commit 535ff39

Browse files
committed
Refactor Dockerfile with distroless image
1 parent 31650f7 commit 535ff39

File tree

1 file changed

+3
-12
lines changed

1 file changed

+3
-12
lines changed

Dockerfile

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,17 @@
1-
# Stage 1: Build
1+
# See. https://github.com/GoogleContainerTools/distroless/blob/530158861eebdbbf149f7e7e67bfe45eb433a35c/examples/go/Dockerfile
22
FROM golang:1.23 AS builder
33

4-
# Set the working directory
54
WORKDIR /app
6-
7-
# Copy the source code
85
COPY . .
96

107
# Build the Go application with static linking
11-
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o main .
8+
RUN CGO_ENABLED=0 go build -o main .
129

13-
# Stage 2: Runtime
14-
FROM alpine:latest
10+
FROM gcr.io/distroless/static-debian12
1511

16-
# Set the working directory
1712
WORKDIR /app
18-
19-
# Copy the built binary from the builder stage
2013
COPY --from=builder /app/main .
2114

22-
# Expose the application port
2315
EXPOSE 8080
2416

25-
# Command to run the application
2617
CMD ["./main"]

0 commit comments

Comments
 (0)