Add docker build scripts

This commit is contained in:
Zahary Karadjov 2019-09-10 12:18:39 -04:00
parent f72de67f63
commit d1b1ecf86b
No known key found for this signature in database
GPG Key ID: C8936F8A3073D609
6 changed files with 102 additions and 0 deletions

62
docker/Dockerfile Normal file
View File

@ -0,0 +1,62 @@
FROM statusteam/nim-base AS build
RUN apt update \
&& apt install -y build-essential make wget \
&& apt clean \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
RUN export GO_TAR_GZ=go1.12.6.linux-amd64.tar.gz \
&& cd /tmp/ \
&& wget https://dl.google.com/go/$GO_TAR_GZ \
&& tar -xvf $GO_TAR_GZ \
&& mv go /usr/local \
&& rm $GO_TAR_GZ
ARG GIT_REVISION
RUN export GOROOT=/usr/local/go \
&& export PATH=$GOROOT/bin:$PATH \
&& git clone https://github.com/status-im/nimbus.git \
&& cd nimbus \
&& git reset --hard ${GIT_REVISION} \
&& make update deps vendor/go/bin/p2pd nat-libs \
&& cp vendor/go/bin/p2pd /usr/bin/p2pd \
&& cp docker/beacon_node/run_in_docker.sh /usr/bin/run_beacon_node.sh
ARG NETWORK
ARG NETWORK_TYPE
RUN cd nimbus \
&& set -a \
&& . vendor/nim-beacon-chain/scripts/${NETWORK}.env \
&& ./env.sh nim \
-o:/usr/bin/beacon_node \
-d:release \
--debugger:native \
--debugInfo \
-d:"network_type=${NETWORK_TYPE}" \
-d:SHARD_COUNT=${SHARD_COUNT} \
-d:SLOTS_PER_EPOCH=${SLOTS_PER_EPOCH} \
-d:SECONDS_PER_SLOT=${SECONDS_PER_SLOT} \
-d:chronicles_log_level=DEBUG \
-d:chronicles_sinks=json \
c vendor/nim-beacon-chain/beacon_chain/beacon_node.nim
# --------------------------------- #
# Starting new image to reduce size #
# --------------------------------- #
FROM debian:9-slim
RUN apt update \
&& apt install -y librocksdb-dev curl \
&& apt clean \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
COPY --from=build /usr/bin/beacon_node /usr/bin/beacon_node
COPY --from=build /usr/bin/run_beacon_node.sh /usr/bin/run_beacon_node.sh
COPY --from=build /usr/bin/p2pd /usr/bin/p2pd
MAINTAINER Zahary Karadjov <zahary@status.im>
LABEL description="Nimbus installation that can act as an ETH2 network bootstrap node."
ENTRYPOINT ["/usr/bin/run_beacon_node.sh"]

20
docker/Makefile Normal file
View File

@ -0,0 +1,20 @@
# These default settings can be overriden by exporting env variables
GIT_REVISION ?= $(git rev-parse HEAD)
NETWORK ?= testnet1
NETWORK_TYPE ?= libp2p
IMAGE_TAG ?= $(NETWORK)
IMAGE_NAME ?= statusteam/nimbus_beacon_node:$(IMAGE_TAG)
build: $(NIX_INSTALL)
docker build \
--build-arg="GIT_REVISION=$(GIT_REVISION)" \
--build-arg="NETWORK=$(NETWORK)" \
--build-arg="NETWORK_TYPE=$(NETWORK_TYPE)" \
-t $(IMAGE_NAME) .
push: build
docker push $(IMAGE_NAME)

3
docker/README.md Normal file
View File

@ -0,0 +1,3 @@
# 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).

5
docker/publish_testnet0.sh Executable file
View File

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

5
docker/publish_testnet1.sh Executable file
View File

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

7
docker/run_in_docker.sh Executable file
View File

@ -0,0 +1,7 @@
#!/bin/bash
killall p2pd
rm -rf /tmp/*
beacon_node --nat:none $*