Skip to content

Commit 3474dbc

Browse files
author
koddr
committed
Add Dockerfile
1 parent 4610225 commit 3474dbc

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

Dockerfile

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
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"]

0 commit comments

Comments
 (0)