Docker: remove old fleet setup

These files have been replaced months ago, with another scheme inside
the "infra-nimbus" repo.
This commit is contained in:
Ștefan Talpalaru 2021-02-16 17:37:31 +01:00 committed by zah
parent c7093c4ab5
commit 8ac8b15866
6 changed files with 0 additions and 240 deletions

View File

@ -1,52 +0,0 @@
FROM debian:bullseye-slim AS build
SHELL ["/bin/bash", "-c"]
RUN apt-get -qq update \
&& apt-get -qq -y install build-essential git &>/dev/null \
&& apt-get -qq clean \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
# let Docker cache this between Git revision and testnet version changes
RUN cd /root \
&& git clone https://github.com/status-im/nim-beacon-chain.git \
&& cd nim-beacon-chain \
&& make -j$(nproc) update
# Please note that the commands above have the goal of caching the
# compilation of Nim, but don't depend on the current git revision.
# This means that the cache can become outdated over time and you'll
# start seeing Nim being compiled on every run. If this happens, just
# prune your docker cache to get a fresh up-to-date version of Nim.
ARG GIT_REVISION
ARG NETWORK_NIM_FLAGS
ARG MARCH_NIM_FLAGS
RUN cd /root/nim-beacon-chain \
&& git fetch \
&& git reset --hard ${GIT_REVISION} \
&& make -j$(nproc) update \
&& make LOG_LEVEL=TRACE NIMFLAGS="-d:insecure -d:testnet_servers_image ${NETWORK_NIM_FLAGS} ${MARCH_NIM_FLAGS}" nimbus_beacon_node
# --------------------------------- #
# Starting new image to reduce size #
# --------------------------------- #
FROM debian:bullseye-slim as deploy
SHELL ["/bin/bash", "-c"]
RUN apt-get -qq update \
&& apt-get -qq -y install psmisc &>/dev/null \
&& apt-get -qq clean \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
# "COPY" creates new image layers, so we cram all we can into one command
COPY --from=build /root/nim-beacon-chain/build/nimbus_beacon_node /usr/bin/
MAINTAINER Zahary Karadjov <zahary@status.im>
LABEL description="Nimbus installation that can act as an ETH2 network bootstrap node."
STOPSIGNAL SIGINT
ENTRYPOINT ["/usr/bin/nimbus_beacon_node"]

View File

@ -1,36 +0,0 @@
SHELL := bash # the shell used internally by "make"
# These default settings can be overriden by exporting env variables
GIT_REVISION ?= $(shell git rev-parse HEAD)
NETWORK ?= testnet1
NETWORK_NIM_FLAGS ?= $(shell ../scripts/load-testnet-nim-flags.sh $(NETWORK))
# Get the required GCC flags by running `gcc -v -E - -march=native </dev/null 2>&1 | grep cc1` on the server.
MARCH_NIM_FLAGS ?= -d:disableMarchNative --passC:'-march=znver1 --param l1-cache-size=32 --param l1-cache-line-size=64 --param l2-cache-size=512'
IMAGE_TAG ?= $(NETWORK)
IMAGE_NAME ?= statusteam/nimbus_beacon_node:$(IMAGE_TAG)
CURRENT_BRANCH = $(shell git rev-parse --abbrev-ref HEAD)
COMPUTER_SAYS_NO = { echo "I'm sorry, Dave. I'm afraid I can't do that."; exit 1; }
.PHONY: build push push-last
build:
@ DOCKER_BUILDKIT=1 \
docker build \
--build-arg="GIT_REVISION=$(GIT_REVISION)" \
--build-arg="NETWORK_NIM_FLAGS=$(NETWORK_NIM_FLAGS)" \
--build-arg="MARCH_NIM_FLAGS=$(MARCH_NIM_FLAGS)" \
-t $(IMAGE_NAME) \
--progress=plain \
.
push: build
+@ $(MAKE) push-last
push-last:
@ [[ "$(CURRENT_BRANCH)" != "master" && "$(NETWORK)" == "testnet0" ]] && $(COMPUTER_SAYS_NO) || true
@ [[ "$(CURRENT_BRANCH)" != "devel" && "$(NETWORK)" == "testnet1" ]] && $(COMPUTER_SAYS_NO) || true
docker push $(IMAGE_NAME)

View File

@ -1,3 +0,0 @@
# Description
This `Dockerfile` defines the image used in the [`infra-nimbus`](https://github.com/status-im/infra-nimbus) fleet of hosts via the [`infra-role-beacon-node`](https://github.com/status-im/infra-role-beacon-node).

View File

@ -1,139 +0,0 @@
import
strformat, os, confutils, algorithm, sequtils
type
Command = enum
restart_nodes
reset_network
CliConfig = object
network: string
validatorsDir {.
defaultValue: "validators"
name: "validators-dir" }: string
case cmd {.command.}: Command
of restart_nodes:
discard
of reset_network:
secretsDir {.
defaultValue: "secrets"
name: "secrets-dir" }: string
networkDataDir {.
defaultValue: "data"
name: "network-data-dir" }: string
totalUserValidators {.
defaultValue: 0
name: "user-validators" }: int
Node = object
id: int
server: string
container: string
var conf = load CliConfig
var
serverCount = 6
instancesCount = 1
validators = listDirs(conf.validatorsDir).mapIt(splitPath(it)[1])
sort(validators)
proc findOrDefault[K, V](tupleList: openArray[(K, V)], key: K, default: V): V =
for t in tupleList:
if t[0] == key:
return t[1]
return default
iterator nodes: Node =
for i in 0 ..< serverCount:
let
serverShortName = if i == 0: "master-01" else: &"node-0{i}"
server = &"{serverShortName}.aws-eu-central-1a.nimbus.test.statusim.net"
for j in 0 ..< instancesCount:
yield Node(id: i*instancesCount + j,
server: server,
container: &"beacon-node-{conf.network}-{j+1}")
iterator validatorAssignments: tuple[node: Node; firstValidator, lastValidator: int] =
let
systemValidators = validators.len - conf.totalUserValidators
defaultValidatorAssignment = proc (nodeIdx: int): int =
(systemValidators div serverCount) div instancesCount
customValidatorAssignments = {
# This is used just to force the correct type of the table
"default": defaultValidatorAssignment
,
"testnet0": proc (nodeIdx: int): int =
if nodeidx < 4:
systemValidators div 4
else:
0
,
"testnet1": proc (nodeIdx: int): int =
if nodeidx < 4:
systemValidators div 4
else:
0
}
var nextValidatorIdx = conf.totalUserValidators
for node in nodes():
let
validatorAssignmentFn = customValidatorAssignments.findOrDefault(
conf.network, defaultValidatorAssignment)
nodeValidatorCount = validatorAssignmentFn(node.id)
yield (node,
nextValidatorIdx,
nextValidatorIdx + nodeValidatorCount)
inc nextValidatorIdx, nodeValidatorCount
case conf.cmd
of restart_nodes:
for n in nodes():
if n.id mod 2 == 0:
echo &"echo Pulling container image on {n.server} ..."
# This will only print one line: "docker.io/statusteam/nimbus_beacon_node:testnet1".
echo &"ssh {n.server} docker pull -q statusteam/nimbus_beacon_node:{conf.network}"
echo &"echo Starting container {n.container}@{n.server} ..."
# docker-compose will rebuild the container if it detects a newer image.
# Prints: "Recreating beacon-node-testnet1-1 ... done".
echo &"ssh {n.server} 'cd /docker/{n.container} && docker-compose --compatibility up -d'"
of reset_network:
for n, firstValidator, lastValidator in validatorAssignments():
var
validatorDirs = ""
secretFiles = ""
networkDataFiles = conf.networkDataDir & "/{genesis.ssz,bootstrap_nodes.txt}"
for i in firstValidator ..< lastValidator:
validatorDirs.add " "
validatorDirs.add conf.validatorsDir / validators[i]
secretFiles.add " "
secretFiles.add conf.secretsDir / validators[i]
let dockerPath = &"/docker/{n.container}/data/BeaconNode"
echo &"echo Syncing {lastValidator - firstValidator} keys starting from {firstValidator} to container {n.container}@{n.server} ... && \\"
echo &" ssh {n.server} 'sudo rm -rf /tmp/nimbus && mkdir -p /tmp/nimbus/{{net-data,validators,secrets}}' && \\"
echo &" rsync -a -zz {networkDataFiles} {n.server}:/tmp/nimbus/net-data/ && \\"
if validators.len > 0:
echo &" rsync -a -zz {validatorDirs} {n.server}:/tmp/nimbus/validators/ && \\"
echo &" rsync -a -zz {secretFiles} {n.server}:/tmp/nimbus/secrets/ && \\"
echo &" ssh {n.server} 'sudo docker container stop {n.container}; " &
&"sudo rm -rf {dockerPath}/{{db,validators,secrets,net-data}}* && " &
&"sudo mv /tmp/nimbus/* {dockerPath}/ && " &
&"sudo chown dockremap:docker -R {dockerPath}'"

View File

@ -1,5 +0,0 @@
#!/bin/bash
export NETWORK=testnet0
make push

View File

@ -1,5 +0,0 @@
#!/bin/bash
export NETWORK=testnet1
make push