From 94709aaf2864289c8c053e03c6792664622fd6b8 Mon Sep 17 00:00:00 2001 From: Andrew Trainor Date: Wed, 22 Jul 2020 21:23:16 -0400 Subject: [PATCH] rosetta/dockerfile Remove build-everything script and further optimize the final build layers before the prod stage is added --- build-everything-rosetta.sh | 42 -------------------------- dockerfiles/Dockerfile-src-rosetta | 47 +++++++++++++++++++----------- 2 files changed, 30 insertions(+), 59 deletions(-) delete mode 100755 build-everything-rosetta.sh diff --git a/build-everything-rosetta.sh b/build-everything-rosetta.sh deleted file mode 100755 index ec9b9e8f947..00000000000 --- a/build-everything-rosetta.sh +++ /dev/null @@ -1,42 +0,0 @@ -#!/bin/bash - -set -o pipefail - -eval `opam config env` - -export LIBP2P_NIXLESS=1 - -echo "--- Explicitly generate PV-keys and upload before building" -make build_pv_keys - -#echo "--- Publish pvkeys" -#./scripts/publish-pvkeys.sh - -echo "--- Rebuild for pvkey changes" -make build - -echo "--- Build generate-keypair binary" -dune build src/app/generate_keypair/generate_keypair.exe - -echo "--- Build runtime_genesis_ledger binary" -dune exec --profile=$DUNE_PROFILE src/app/runtime_genesis_ledger/runtime_genesis_ledger.exe - -echo "--- Generate runtime_genesis_ledger with 10k accounts" -dune exec --profile=$DUNE_PROFILE src/app/runtime_genesis_ledger/runtime_genesis_ledger.exe -- --config-file genesis_ledgers/phase_three/config.json - -#echo "--- Upload genesis data" -#./scripts/upload-genesis.sh - -#echo "--- Build deb package with pvkeys" -#make deb - -#echo "--- Store genesis keys" -#make genesiskeys - -#echo "--- Upload deb to repo" -#make publish_debs - -#echo "--- Copy artifacts to cloud" -# buildkite-agent artifact upload occurs outside of docker after this script exits - -# TODO save docker cache diff --git a/dockerfiles/Dockerfile-src-rosetta b/dockerfiles/Dockerfile-src-rosetta index 3e50ed1c0b1..cf7582d6efd 100644 --- a/dockerfiles/Dockerfile-src-rosetta +++ b/dockerfiles/Dockerfile-src-rosetta @@ -15,6 +15,9 @@ ARG GO_VERSION=1.13.10 # Rust Version passed into rustup-init, can also be "stable", "nightly" or similar ARG RUST_VERSION=1.43.0 +# Rocksdb commit tag/branch to clone +ARG ROCKSDB_VERSION=v5.17.2 + # OS package dependencies # First add support for https and pkg-config for apt, then install everything else ENV DEBIAN_FRONTEND=noninteractive @@ -84,6 +87,16 @@ RUN curl --proto '=https' --tlsv1.2 -sSf -o /tmp/rustup-init \ # As opposed to introducing another shell script here (that mostly just determines the platform) # we just download the binary for the only platform we care about in this docker environment + +# This builds and installs just the rocksdb static lib for us, and cleans up after itself +RUN git clone https://github.com/facebook/rocksdb \ + --depth 1 --shallow-submodules \ + -b "${ROCKSDB_VERSION}" /rocksdb && \ + make -C /rocksdb static_lib PORTABLE=1 -j$(nproc) && \ + cp /rocksdb/librocksdb.a /usr/local/lib/librocksdb_coda.a && \ + rm -rf /rocksdb && \ + sudo strip -S /usr/local/lib/librocksdb_coda.a + ########################################################################################### # Initialize opam in a minimal fashion ########################################################################################### @@ -137,7 +150,7 @@ FROM build-deps AS opam-deps ARG CODA_DIR=coda # branch to checkout on first clone (this will be the only availible branch in the container) # can also be a tagged release -ARG CODA_BRANCH=rosetta/dockerfile +ARG CODA_BRANCH=develop # location of external packages ARG EXTERNAL_PKG_DIR=$CODA_DIR/src/external @@ -174,10 +187,6 @@ RUN eval $(opam config env) && \ #&& \ #rm -rf src/external -# workaround a permissions problem in rpc_parallel .git -# TODO: Does this issue still exist? -#RUN sudo chmod -R u+rw ~/.opam && eval $(opam config env) - ################################################################################################# # The "builder" Stage # - builds coda and any other binaries required to run a node @@ -186,14 +195,16 @@ RUN eval $(opam config env) && \ FROM opam-deps AS builder ARG DUNE_PROFILE=testnet_postake_medium_curves -ENV LIBP2P_NIXLESS 1 # Set up environment again for running as opam user, to make sure its working properly #USER opam #ENV HOME /home/opam #WORKDIR ${HOME}/${CODA_DIR} -RUN eval $(opam config env) && make build_pv_keys +# don't keep sources, to force reinstall of pinned packages from Coda sources +# and to keep Docker image reasonable size +ENV OPAMKEEPBUILDDIR false +ENV OPAMREUSEBUILDDIR false RUN cd src/app/libp2p_helper && \ rm -rf result && \ @@ -201,16 +212,18 @@ RUN cd src/app/libp2p_helper && \ cd src && \ go mod download && \ cd generate_methodidx && go build -o ../../result/bin/generate_methodidx && cd - && \ - cd libp2p_helper && go build -o ../../result/bin/libp2p_helper + cd libp2p_helper && go build -o ../../result/bin/libp2p_helper && \ + go clean --cache --modcache --testcache -r -#RUN eval $(opam config env) && make build -RUN eval $(opam config env) && \ - dune build src/app/generate_keypair/generate_keypair.exe RUN eval $(opam config env) && \ - dune exec --profile=${DUNE_PROFILE} \ - src/app/runtime_genesis_ledger/runtime_genesis_ledger.exe -RUN eval $(opam config env) && \ - dune exec --profile=${DUNE_PROFILE} \ - src/app/runtime_genesis_ledger/runtime_genesis_ledger.exe -- \ - --config-file genesis_ledgers/phase_three/config.json + dune build --profile=${DUNE_PROFILE} \ + src/app/generate_keypair/generate_keypair.exe \ + src/app/cli/src/coda.exe \ + src/app/archive/archive.exe \ + src/app/rosetta/rosetta.exe && \ + dune cache trim --size=0B && \ + opam clean --unused-repositories --logs -cs && \ + rm -rf /tmp && \ + rm -rf $HOME/.opam + #RUN eval $(opam config env) && make deb