forked from zeta-chain/node
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile-upgrade
77 lines (59 loc) · 2.65 KB
/
Dockerfile-upgrade
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
FROM golang:1.20-alpine3.18 as base
# Purpose: This Dockerfile creates an environment for performing an upgrade test on ZetaChain
# It contains the ZetaChain and ZetaClient binaries for two different versions of ZetaChain
# One is specified with the old_version argument and the other is the current source code
# The image also contains the cosmovisor binary for running the upgrade test
ENV GOPATH /go
ENV GOOS=linux
ENV CGO_ENABLED=1
ENV GOCACHE=/root/.cache/go-build
RUN apk --no-cache add git make build-base jq openssh libusb-dev linux-headers bash curl tmux
RUN ssh-keygen -b 2048 -t rsa -f /root/.ssh/localtest.pem -q -N ""
# Build cosmovisor
RUN go install cosmossdk.io/tools/cosmovisor/cmd/[email protected]
WORKDIR /go/delivery/zeta-node
RUN mkdir -p $GOPATH/bin/old
RUN mkdir -p $GOPATH/bin/new
RUN ssh-keygen -A
RUN cp /root/.ssh/localtest.pem.pub /root/.ssh/authorized_keys
# Checkout and build old binary
FROM base as oldbuild
ARG OLD_VERSION
RUN git clone https://github.com/zeta-chain/node.git
RUN cd node && git fetch
RUN cd node && git checkout ${OLD_VERSION}
RUN cd node && make install
# Build new release from the current source
FROM base
COPY go.mod /go/delivery/zeta-node/
COPY go.sum /go/delivery/zeta-node/
RUN cd /go/delivery/zeta-node/ && go mod download
COPY . /go/delivery/zeta-node/
RUN --mount=type=cache,target="/root/.cache/go-build" cd /go/delivery/zeta-node/ && make install
RUN --mount=type=cache,target="/root/.cache/go-build" cd /go/delivery/zeta-node/ && make install-zetae2e
RUN cp $GOPATH/bin/zetacored $GOPATH/bin/new/ && \
cp $GOPATH/bin/zetaclientd $GOPATH/bin/new/
COPY --from=oldbuild ${GOPATH}/bin/zetaclientd /root/.zetaclientd/upgrades/genesis/
RUN mkdir -p /root/.zetaclientd/upgrades/${NEW_VERSION}/ && \
cp ${GOPATH}/bin/zetaclientd /root/.zetaclientd/upgrades/${NEW_VERSION}/
RUN ln -s /root/.zetaclientd/upgrades/genesis /root/.zetaclientd/upgrades/current
ENV PATH="/root/.zetaclientd/upgrades/current:${PATH}"
COPY --from=oldbuild $GOPATH/bin/zetacored $GOPATH/bin/zetaclientd $GOPATH/bin/
COPY --from=oldbuild $GOPATH/bin/zetacored $GOPATH/bin/zetaclientd $GOPATH/bin/old
WORKDIR /root
RUN cp /go/bin/zetaclientd /usr/local/bin
RUN cp /go/bin/zetacored /usr/local/bin
RUN cp /go/bin/zetae2e /usr/local/bin
RUN cp /go/bin/cosmovisor /usr/local/bin
COPY contrib/localnet/scripts /root
COPY contrib/localnet/preparams /root/preparams
COPY contrib/localnet/ssh_config /root/.ssh/config
COPY contrib/localnet/zetacored /root/zetacored
COPY contrib/localnet/tss /root/tss
RUN chmod 755 /root/*.sh
RUN chmod 700 /root/.ssh
RUN chmod 600 /root/.ssh/*
WORKDIR /usr/local/bin
ENV SHELL /bin/sh
EXPOSE 22
ENTRYPOINT ["/usr/sbin/sshd", "-D"]