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 \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
ARG GIT_REVISION
RUN git clone https://github.com/status-im/nimbus.git \
&& cd nimbus \
&& git reset --hard ${GIT_REVISION} \
&& make update deps
ARG NETWORK
@ -18,6 +21,7 @@ RUN cd nimbus \
&& ./env.sh nim \
-o:/usr/bin/beacon_node \
-d:release \
--lineTrace:on \
-d:with${NETWORK_BACKEND} \
-d:SHARD_COUNT=${SHARD_COUNT} \
-d:SLOTS_PER_EPOCH=${SLOTS_PER_EPOCH} \
@ -29,7 +33,7 @@ RUN cd nimbus \
FROM debian:9-slim
RUN apt update \
&& apt install -y librocksdb-dev \
&& apt install -y librocksdb-dev curl \
&& apt clean \
&& 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
GIT_REVISION ?= $(git rev-parse HEAD)
NETWORK ?= testnet0
NETWORK_BACKEND ?= rlpx
@ -7,6 +10,7 @@ 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_BACKEND=$(NETWORK_BACKEND)" \
-t $(IMAGE_NAME) .

View File

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

View File

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

View File

@ -1,16 +1,35 @@
FROM statusteam/nim-base
MAINTAINER Zahary Karadjov <zahary@status.im>
FROM statusteam/nim-base AS build
RUN apt-get update && apt-get install -y build-essential make librocksdb-dev && \
apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
RUN apt update \
&& 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 && \
cd nimbus && \
make update deps
ARG GIT_REVISION
RUN git clone https://github.com/status-im/nimbus.git \
&& cd nimbus \
&& git reset --hard ${GIT_REVISION} \
&& make update deps
RUN cd nimbus && \
make nimbus && \
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