forked from keep-network/keep-ecdsa
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
73 lines (56 loc) · 1.8 KB
/
Dockerfile
File metadata and controls
73 lines (56 loc) · 1.8 KB
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
FROM golang:1.13.8-alpine3.10 AS gobuild
ENV GOPATH=/go \
GOBIN=/go/bin \
APP_NAME=keep-ecdsa \
APP_DIR=/go/src/github.com/keep-network/keep-ecdsa \
BIN_PATH=/usr/local/bin \
# GO111MODULE required to support go modules
GO111MODULE=on
RUN apk add --update --no-cache \
g++ \
linux-headers \
make \
nodejs \
npm \
python \
git \
protobuf && \
rm -rf /var/cache/apk/ && mkdir /var/cache/apk/ && \
rm -rf /usr/share/man
# Install Solidity compiler.
COPY --from=ethereum/solc:0.5.17 /usr/bin/solc /usr/bin/solc
# Configure GitHub token to be able to get private repositories.
ARG GITHUB_TOKEN
RUN git config --global url."https://$GITHUB_TOKEN:@github.com/".insteadOf "https://github.com/"
# Configure working directory.
RUN mkdir -p $APP_DIR
WORKDIR $APP_DIR
# Get dependencies.
COPY go.mod $APP_DIR/
COPY go.sum $APP_DIR/
RUN go mod download
# Install code generators.
RUN cd /go/pkg/mod/github.com/gogo/protobuf@v1.3.1/protoc-gen-gogoslick && go install .
RUN cd /go/pkg/mod/github.com/ethereum/go-ethereum@v1.9.10/cmd/abigen && go install .
# Install Solidity contracts.
COPY ./solidity $APP_DIR/solidity
RUN cd $APP_DIR/solidity && npm install
# Generate code.
COPY ./pkg/chain/gen $APP_DIR/pkg/chain/gen
COPY ./pkg/ecdsa/tss/gen $APP_DIR/pkg/ecdsa/tss/gen
# Need this to resolve imports in generated Ethereum commands.
COPY ./internal/config $APP_DIR/config
RUN go generate ./.../gen
# Build the application.
COPY ./ $APP_DIR/
# Configure private repositories for Go dependencies
ARG GOPRIVATE
RUN GOOS=linux GOPRIVATE=$GOPRIVATE go build -a -o $APP_NAME ./ && \
mv $APP_NAME $BIN_PATH
# Configure runtime container.
FROM alpine:3.10
ENV APP_NAME=keep-ecdsa \
BIN_PATH=/usr/local/bin
COPY --from=gobuild $BIN_PATH/$APP_NAME $BIN_PATH
# docker caches more when using CMD [] resulting in a faster build.
CMD []