add Makefile for beacon_node Dockerfile, make image smaller

Signed-off-by: Jakub Sokołowski <jakub@status.im>
This commit is contained in:
Jakub Sokołowski 2019-03-22 17:10:53 +01:00 committed by zah
parent 46aca468bb
commit 6de2dd167e
4 changed files with 57 additions and 28 deletions

View File

@ -1,26 +1,41 @@
FROM statusteam/nim-base FROM statusteam/nim-base AS build
MAINTAINER Zahary Karadjov <zahary@status.im>
ARG network RUN apt update \
ARG network_backend && apt install -y build-essential make \
&& apt clean \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
RUN apt-get update && apt-get install -y build-essential make librocksdb-dev && \ RUN git clone https://github.com/status-im/nimbus.git \
apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* && cd nimbus \
&& make update deps
RUN git clone https://github.com/status-im/nimbus.git && \ ARG NETWORK
cd nimbus && \ ARG NETWORK_BACKEND
make update deps
RUN cd nimbus && \ RUN cd nimbus \
set -a && \ && set -a \
. vendor/nim-beacon-chain/scripts/${network}.env && \ && . vendor/nim-beacon-chain/scripts/${NETWORK}.env \
./env.sh nim \ && ./env.sh nim \
-o:/usr/bin/beacon_node \ -o:/usr/bin/beacon_node \
-d:release \ -d:release \
-d:with$network_backend \ -d:with${NETWORK_BACKEND} \
-d:SHARD_COUNT=$SHARD_COUNT \ -d:SHARD_COUNT=${SHARD_COUNT} \
-d:SLOTS_PER_EPOCH=$SLOTS_PER_EPOCH \ -d:SLOTS_PER_EPOCH=${SLOTS_PER_EPOCH} \
c vendor/nim-beacon-chain/beacon_chain/beacon_node.nim c vendor/nim-beacon-chain/beacon_chain/beacon_node.nim
ENTRYPOINT ["beacon_node"] # --------------------------------- #
# Starting new image to reduce size #
# --------------------------------- #
FROM debian:9-slim
RUN apt update \
&& apt install -y librocksdb-dev \
&& apt clean \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
COPY --from=build /usr/bin/beacon_node /usr/bin/beacon_node
MAINTAINER Zahary Karadjov <zahary@status.im>
LABEL description="Nimbus installation that can act as an ETH2 network bootstrap node."
ENTRYPOINT ["/usr/bin/beacon_node"]

View File

@ -0,0 +1,15 @@
# These default settings can be overriden by exporting env variables
NETWORK ?= testnet0
NETWORK_BACKEND ?= rlpx
IMAGE_TAG ?= $(NETWORK)-$(NETWORK_BACKEND)
IMAGE_NAME ?= statusteam/nimbus_beacon_node:$(IMAGE_TAG)
build: $(NIX_INSTALL)
docker build \
--build-arg="NETWORK=$(NETWORK)" \
--build-arg="NETWORK_BACKEND=$(NETWORK_BACKEND)" \
-t $(IMAGE_NAME) .
push: build
docker push $(IMAGE_NAME)

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).

View File

@ -2,21 +2,17 @@
set -euv set -euv
DOCKERHUB_REPO_NAME=statusteam/nimbus_beacon_node
buildAndPush() { buildAndPush() {
NETWORK=$1 export NETWORK=$1
BACKEND=$2 export NETWORK_BACKEND=$2
CONTAINER_NAME=statusteam/beacon_node_${NETWORK}_${BACKEND}
docker build -t $CONTAINER_NAME beacon_node \ (cd $(dirname "$0")/beacon_node && make push)
--build-arg network=$NETWORK \
--build-arg network_backend=$BACKEND
docker push $CONTAINER_NAME
} }
buildAndPush testnet0 rlpx buildAndPush testnet0 rlpx
buildAndPush testnet1 rlpx buildAndPush testnet1 rlpx
buildAndPush testnet0 libp2p #buildAndPush testnet0 libp2p
buildAndPush testnet1 libp2p #buildAndPush testnet1 libp2p