More improvements to the docker build scripts

* Make the build deterministic by pinning it to a particular revision
* Add curl as a run-time dependency
* Use the improved Docker practices for the Nimbus build as well
This commit is contained in:
Zahary Karadjov 2019-03-23 13:12:22 +02:00 committed by zah
parent 6de2dd167e
commit e9754cf69c
7 changed files with 56 additions and 16 deletions

View File

@ -5,8 +5,11 @@ RUN apt update \
&& apt clean \ && apt clean \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
ARG GIT_REVISION
RUN git clone https://github.com/status-im/nimbus.git \ RUN git clone https://github.com/status-im/nimbus.git \
&& cd nimbus \ && cd nimbus \
&& git reset --hard ${GIT_REVISION} \
&& make update deps && make update deps
ARG NETWORK ARG NETWORK
@ -18,6 +21,7 @@ RUN cd nimbus \
&& ./env.sh nim \ && ./env.sh nim \
-o:/usr/bin/beacon_node \ -o:/usr/bin/beacon_node \
-d:release \ -d:release \
--lineTrace:on \
-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} \
@ -29,7 +33,7 @@ RUN cd nimbus \
FROM debian:9-slim FROM debian:9-slim
RUN apt update \ RUN apt update \
&& apt install -y librocksdb-dev \ && apt install -y librocksdb-dev curl \
&& apt clean \ && apt clean \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

View File

@ -1,4 +1,7 @@
# These default settings can be overriden by exporting env variables # These default settings can be overriden by exporting env variables
GIT_REVISION ?= $(git rev-parse HEAD)
NETWORK ?= testnet0 NETWORK ?= testnet0
NETWORK_BACKEND ?= rlpx NETWORK_BACKEND ?= rlpx
@ -7,6 +10,7 @@ IMAGE_NAME ?= statusteam/nimbus_beacon_node:$(IMAGE_TAG)
build: $(NIX_INSTALL) build: $(NIX_INSTALL)
docker build \ docker build \
--build-arg="GIT_REVISION=$(GIT_REVISION)" \
--build-arg="NETWORK=$(NETWORK)" \ --build-arg="NETWORK=$(NETWORK)" \
--build-arg="NETWORK_BACKEND=$(NETWORK_BACKEND)" \ --build-arg="NETWORK_BACKEND=$(NETWORK_BACKEND)" \
-t $(IMAGE_NAME) . -t $(IMAGE_NAME) .

View File

@ -2,13 +2,13 @@
set -euv set -euv
DOCKERHUB_REPO_NAME=statusteam/nimbus_beacon_node cd $(dirname "$0")
buildAndPush() { buildAndPush() {
export NETWORK=$1 export NETWORK=$1
export NETWORK_BACKEND=$2 export NETWORK_BACKEND=$2
(cd $(dirname "$0")/beacon_node && make push) (cd beacon_node && make push)
} }
buildAndPush testnet0 rlpx buildAndPush testnet0 rlpx

View File

@ -1,9 +1,7 @@
#!/bin/bash #!/bin/bash
set -euv set -euv
cd $(dirname "$0")
CONTAINER_NAME=statusteam/nimbus (cd nimbus && make push)
docker build -t $CONTAINER_NAME nimbus
docker push $CONTAINER_NAME

View File

@ -1,16 +1,35 @@
FROM statusteam/nim-base FROM statusteam/nim-base AS build
MAINTAINER Zahary Karadjov <zahary@status.im>
RUN apt-get update && apt-get install -y build-essential make librocksdb-dev && \ RUN apt update \
apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* && apt install -y build-essential make \
&& apt clean \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
RUN git clone https://github.com/status-im/nimbus.git && \ ARG GIT_REVISION
cd nimbus && \
make update deps RUN git clone https://github.com/status-im/nimbus.git \
&& cd nimbus \
&& git reset --hard ${GIT_REVISION} \
&& make update deps
RUN cd nimbus && \ RUN cd nimbus && \
make nimbus && \ make nimbus && \
mv build/nimbus /usr/bin/ mv build/nimbus /usr/bin/
ENTRYPOINT ["nimbus"] # --------------------------------- #
# 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/nimbus /usr/bin/nimbus
MAINTAINER Zahary Karadjov <zahary@status.im>
LABEL description="Nimbus: an Ethereum 2.0 Sharding Client for Resource-Restricted Devices"
ENTRYPOINT ["/usr/bin/nimbus"]

15
docker/nimbus/Makefile Normal file
View File

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

@ -1 +1 @@
Subproject commit 13c7f7fcec8a1694f5523e38a9dd3990861e6c80 Subproject commit 8adffc3f0ffb1d2212452d3d015d03b7652a1887