FROM golang:1.13.0-stretch as builder WORKDIR /build # Resolve and build Go dependencies as Docker cache COPY go.mod /build/go.mod COPY go.sum /build/go.sum COPY kv/go.mod /build/kv/go.mod ENV GO111MODULE=on RUN go mod download COPY service.go /build/main.go COPY kv/ /build/kv # Build for linux ENV GOOS=linux ENV GOARCH=amd64 ENV CGO_ENABLED=0 RUN go build -o server # Build the main container (Linux Runtime) FROM alpine:latest WORKDIR /root/ # Copy the linux amd64 binary COPY --from=builder /build/server /bin/ ENTRYPOINT /bin/server