forked from keep-network/keep-core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
127 lines (96 loc) · 3.19 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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
FROM golang:1.20.13-alpine3.19 AS build-sources
ENV GOPATH=/go \
GOBIN=/go/bin \
APP_NAME=keep-client \
APP_DIR=/go/src/github.com/keep-network/keep-core \
TEST_RESULTS_DIR=/mnt/test-results \
BIN_PATH=/usr/local/bin \
LD_LIBRARY_PATH=/usr/local/lib/
# TODO: Remove perl once go-ethereum is upgraded to 1.11.
# See pkg/chain/ethereum/tbtc/gen/Makefile and after_abi_hook for details.
RUN apk add --update --no-cache \
g++ \
linux-headers \
protobuf-dev \
git \
make \
nodejs \
npm \
bash \
perl \
python3 \
tar \
jq && \
rm -rf /var/cache/apk/ && mkdir /var/cache/apk/ && \
rm -rf /usr/share/man
RUN go install gotest.tools/gotestsum@latest
RUN mkdir -p $APP_DIR $TEST_RESULTS_DIR
WORKDIR $APP_DIR
# Get dependencies.
COPY go.mod go.sum $APP_DIR/
RUN go mod download
# Install code generators.
RUN go install google.golang.org/protobuf/cmd/[email protected]
# Copy source code for generation.
COPY ./pkg/beacon/dkg/result/gen $APP_DIR/pkg/beacon/dkg/result/gen
COPY ./pkg/beacon/entry/gen $APP_DIR/pkg/beacon/entry/gen
COPY ./pkg/beacon/gjkr/gen $APP_DIR/pkg/beacon/gjkr/gen
COPY ./pkg/beacon/registry/gen $APP_DIR/pkg/beacon/registry/gen
COPY ./pkg/chain/ethereum/beacon/gen $APP_DIR/pkg/chain/ethereum/beacon/gen
COPY ./pkg/chain/ethereum/common/gen $APP_DIR/pkg/chain/ethereum/common/gen
COPY ./pkg/chain/ethereum/ecdsa/gen $APP_DIR/pkg/chain/ethereum/ecdsa/gen
COPY ./pkg/chain/ethereum/tbtc/gen $APP_DIR/pkg/chain/ethereum/tbtc/gen
COPY ./pkg/chain/ethereum/threshold/gen $APP_DIR/pkg/chain/ethereum/threshold/gen
COPY ./pkg/net/gen $APP_DIR/pkg/net/gen
COPY ./pkg/tbtc/gen $APP_DIR/pkg/tbtc/gen
COPY ./pkg/tecdsa/dkg/gen $APP_DIR/pkg/tecdsa/dkg/gen
COPY ./pkg/tecdsa/signing/gen $APP_DIR/pkg/tecdsa/signing/gen
COPY ./pkg/tecdsa/gen $APP_DIR/pkg/tecdsa/gen
COPY ./pkg/protocol/announcer/gen $APP_DIR/pkg/protocol/announcer/gen
COPY ./pkg/protocol/inactivity/gen $APP_DIR/pkg/protocol/inactivity/gen
# Environment is to download published and tagged NPM packages versions.
ARG ENVIRONMENT
COPY ./Makefile $APP_DIR/Makefile
RUN make get_artifacts environment=$ENVIRONMENT
# Need this to resolve imports in generated Ethereum commands.
COPY ./config $APP_DIR/config
RUN make generate environment=$ENVIRONMENT
COPY ./ $APP_DIR/
#
# Build Docker Image
#
FROM build-sources AS build-docker
WORKDIR $APP_DIR
# Client Versioning.
ARG VERSION
ARG REVISION
RUN GOOS=linux make build \
version=$VERSION \
revision=$REVISION
FROM alpine:3.19 as runtime-docker
ENV APP_NAME=keep-client \
APP_DIR=/go/src/github.com/keep-network/keep-core \
BIN_PATH=/usr/local/bin
COPY --from=build-docker $APP_DIR/$APP_NAME $BIN_PATH
# ENTRYPOINT cant handle ENV variables.
ENTRYPOINT ["keep-client"]
# docker caches more when using CMD [] resulting in a faster build.
CMD []
#
# Build Binaries
#
FROM golang:1.20.13-bullseye AS build-bins
ENV APP_DIR=/go/src/github.com/keep-network/keep-core
WORKDIR $APP_DIR
COPY --from=build-sources $APP_DIR $APP_DIR
ARG ENVIRONMENT
# Client Versioning.
ARG VERSION
ARG REVISION
RUN make release \
environment=$ENVIRONMENT \
version=$VERSION \
revision=$REVISION
FROM scratch as output-bins
ENV APP_DIR=/go/src/github.com/keep-network/keep-core
COPY --from=build-bins $APP_DIR/out/bin .