-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
67 lines (50 loc) · 2.09 KB
/
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
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
61
62
63
64
65
66
67
# This is the base image of the services.
# In this stage we prepare all required common data to dockerize our services.
FROM golang:1.15 as preparer
RUN apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get install -yq --no-install-recommends \
curl git unzip \
&& rm -rf /var/lib/apt/lists/*
# Install solidity stuff
# RUN add-apt-repository ppa:ethereum/ethereum
# RUN apt-get update
# RUN apt-get install solc ethereum
# Install Protobuf.
ARG PROTOBUF_VERSION=3.12.4
RUN curl -sOL "https://github.com/google/protobuf/releases/download/v${PROTOBUF_VERSION}/protoc-${PROTOBUF_VERSION}-linux-x86_64.zip" && \
unzip protoc-*.zip && \
mv bin/protoc /usr/local/bin && \
mv include/* /usr/local/include && \
rm -f protoc-*.zip
# Go to the root of the project.
WORKDIR /go/src/github.com/begmaroman/beaconspot/
# Switch on the Go modules. Go modules will be switched on by default from Go 1.13 onwards.
ENV GO111MODULE=on
# Copy module files
COPY go.mod .
COPY go.sum .
# Download project dependencies
RUN go mod download
# Install go tools.
RUN go install \
github.com/go-openapi/runtime \
github.com/tylerb/graceful \
github.com/jessevdk/go-flags \
github.com/golang/protobuf/protoc-gen-go \
github.com/go-swagger/go-swagger/cmd/swagger
FROM preparer as builder
# Copy the project on build trigger.
COPY . .
# Remove vendored deps
RUN rm -rf ./vendor
# Install the service binary.
RUN CGO_CFLAGS_ALLOW="-D__BLST_PORTABLE__" CGO_CFLAGS="-D__BLST_PORTABLE__" CGO_ENABLED=1 GOOS=linux go install -a -tags blst_enabled -ldflags "-linkmode external -extldflags \"-static -lm -msoft-float -Wl,-y,__sigsetjmp_aux\"" ./cmd/beaconspot
# Stage 2: Prepare all required data to run the service.
FROM alpine:3.9 as runner
# Install ca-certificates, bash
RUN apk -v --update add ca-certificates bash
# Copy entrypoint and service executable.
COPY --from=builder /go/bin/beaconspot /go/bin/beaconspot
# This is needed for healthcheck
EXPOSE 5678
ENTRYPOINT ["/go/bin/beaconspot"]