Debian Codegraph @

examples/producer-random/Dockerfile

raw
1 #####################################
2 # STEP 1 build executable binary #
3 #####################################
4 FROM golang:alpine AS builder
5
6 # Install git.
7 # Git is required for fetching the dependencies.
8 RUN apk update && apk add --no-cache git
9
10 WORKDIR /app
11
12 COPY go.mod .
13 COPY go.sum .
14
15 RUN go mod download
16
17 COPY . .
18
19 # Build the binary.
20 RUN CGO_ENABLED=0 GOOS=linux go build -o main
21
22 #####################################
23 # STEP 2 build a small image #
24 #####################################
25 FROM scratch
26
27 # Copy our static executable.
28 COPY --from=builder /app/main /app/main
29
30 # Run the hello binary.
31 ENTRYPOINT ["/app/main"]