forked from aalda/hashicorp-raft-example
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Dockerfile
33 lines (28 loc) · 921 Bytes
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
FROM golang:1.14-alpine AS baseGo
ENV CGO_ENABLED 0
RUN apk --no-cache add git
RUN go get -u github.com/go-delve/delve/cmd/dlv
WORKDIR $GOPATH/src/github.com/sunsided/hashicorp-raft-example
COPY go.mod .
COPY go.sum .
RUN go mod download -x
COPY . .
RUN go build -gcflags='all=-N -l' -o example cmd/raft-example/main.go
FROM scratch AS release
LABEL stage=release
COPY --from=baseGo /go/src/github.com/sunsided/hashicorp-raft-example/example /
ENTRYPOINT ["./example"]
FROM scratch AS debug
LABEL stage=debug
COPY --from=baseGo /go/bin/dlv /
COPY --from=release /example /
EXPOSE 40000
ENTRYPOINT ["/dlv", "--listen=0.0.0.0:40000", "--headless=true", "--log", "--api-version=2", "exec", "/example"]
FROM scratch AS mock
LABEL stage=mock
FROM golang:alpine AS dev-env
LABEL stage=dev-env
COPY --from=baseGo /go /go
WORKDIR $GOPATH/src/github.com/sunsided/hashicorp-raft-example/
ENTRYPOINT ["./example"]
FROM release