File tree Expand file tree Collapse file tree 1 file changed +27
-0
lines changed Expand file tree Collapse file tree 1 file changed +27
-0
lines changed Original file line number Diff line number Diff line change 1+ FROM golang:1.14-alpine AS builder
2+
3+ # Move to working directory (/build).
4+ WORKDIR /build
5+
6+ # Copy and download dependency using go mod.
7+ COPY go.mod go.sum ./
8+ RUN go mod download
9+
10+ # Copy the code into the container.
11+ COPY . .
12+
13+ # Set necessary environmet variables needed for our image and build the API server.
14+ ENV GO111MODULE=on CGO_ENABLED=0 GOOS=linux GOARCH=amd64
15+ RUN go build -ldflags="-w -s" -o apiserver .
16+
17+ FROM scratch
18+
19+ # Copy binary and config files from /build to root folder of scratch container.
20+ COPY --from=builder ["/build/apiserver" , "/build/configs/apiserver.yml" , "/" ]
21+
22+ # Export necessary port.
23+ EXPOSE 5000
24+
25+ # Command to run when starting the container.
26+ ENV CONFIG_PATH=/apiserver.yml
27+ ENTRYPOINT ["/apiserver" ]
You can’t perform that action at this time.
0 commit comments