FROM golang:1.13-alpine AS builder

WORKDIR /go/src/noteservice
COPY . .
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GO111MODULE=on go build -o app -a ./cmd/noteservice.go

FROM alpine:latest AS certs
RUN apk --update add ca-certificates

FROM scratch
WORKDIR /noteservice
COPY --from=builder /go/src/noteservice/app .
COPY --from=certs /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt

EXPOSE 50052
ENTRYPOINT ["./app"]