Skip to content

Commit 9a1667f

Browse files
Created an optimized multi-stage dockerfile
1 parent da87e41 commit 9a1667f

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

Dockerfile

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM golang:1.23-bookworm
1+
FROM golang:1.23-bookworm AS build-stage
22

33
WORKDIR /usr/src/app
44

@@ -8,6 +8,13 @@ RUN go mod download
88

99
COPY ./src ./src
1010

11+
ENV CGO_ENABLED=0
12+
ENV GOOS=linux
13+
1114
RUN go build src/cmd/raspy-monitor/main.go
1215

16+
FROM scratch AS final-stage
17+
18+
COPY --from=build-stage /usr/src/app/main .
19+
1320
CMD ["./main"]

0 commit comments

Comments
 (0)