-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile.debug
60 lines (51 loc) · 1.51 KB
/
Dockerfile.debug
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#
# STEP 1: Prepare environment
#
FROM golang:1.15 AS preparer
RUN apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get install -yq --no-install-recommends \
curl git zip unzip wget g++ python gcc-aarch64-linux-gnu \
&& rm -rf /var/lib/apt/lists/*
RUN go version
RUN python --version
WORKDIR /go/src/github.com/bloxapp/ssv/
COPY go.mod .
COPY go.sum .
RUN go mod download
#
# STEP 2: Build executable binary
#
FROM preparer AS builder
# Copy files and install app
COPY . .
RUN go get -d -v ./...
RUN CGO_ENABLED=1 GOOS=linux go install -a -tags blst_enabled -ldflags "-linkmode external -extldflags \"-static -lm\"" ./cmd/ssvnode
#
# STEP 3: Prepare image to run the binary
#
FROM alpine:3.12 AS runner
# Install ca-certificates, bash
RUN apk -v --update add ca-certificates bash && \
rm /var/cache/apk/*
COPY --from=builder /go/bin/ssvnode /go/bin/ssvnode
EXPOSE 40000 2345
#
# STEP 4: Prepare Live Reload - Air
#
FROM runner
RUN apk add --update curl
RUN curl -fLo install.sh https://raw.githubusercontent.com/cosmtrek/air/master/install.sh \
&& chmod +x install.sh && sh install.sh
CMD air
#
# STEP 5: Setup Debugger Delve
#
FROM builder as debugger
# Install Delve
RUN CGO_ENABLED=0 go get -ldflags "-s -w -extldflags '-static'" github.com/go-delve/delve/cmd/dlv && pwd
COPY ./cmd/ssvnode/main.go .
ENTRYPOINT ["/go/bin/ssvnode"]
# Copy Delve debugger to ssvnode path
FROM debugger
COPY --from=debugger go/bin/dlv /dlv
ENTRYPOINT ["/dlv"]