gantree-io / gantree-lib-nodejs

Javascript lib for gantree-cli
Apache License 2.0
12 stars 3 forks source link

add custom build-setup commands (or build on host) #26

Closed brenzi closed 4 years ago

brenzi commented 4 years ago

In order to build our node we need to install additional dependencies:

Here are the cecessary commands from our dockerfile

# prepare the linux system
RUN apt-get update && \
    apt-get install -y --no-install-recommends\
    build-essential ocaml ocamlbuild automake autoconf \
    libtool wget python libssl-dev libcurl4-openssl-dev protobuf-compiler \
    libprotobuf-dev kmod vim curl git-core libprotobuf-c0-dev \
    libboost-thread-dev libboost-system-dev liblog4cpp5-dev libjsoncpp-dev \
    alien uuid-dev libxml2-dev cmake pkg-config expect systemd-sysv gdb unzip \
    clang libclang-dev rsync ca-certificates && \
    rm -rf /var/lib/apt/lists/* && \
    rm -rf /var/cache/apt/archives/*

# install the Intel SGX PSW and SDK
RUN mkdir /root/sgx && \
    mkdir /etc/init && \
    wget -O /root/sgx/psw.deb ${psw_deb} && \
    wget -O /root/sgx/psw_dev.deb ${psw_dev_deb} && \
    wget -O /root/sgx/psw_dbgsym.deb ${psw_dbgsym_deb} && \
    wget -O /root/sgx/sdk.bin ${sdk_bin} && \
    cd /root/sgx && \
    dpkg -i /root/sgx/psw.deb && \
    dpkg -i /root/sgx/psw_dev.deb && \
    dpkg -i /root/sgx/psw_dbgsym.deb && \
    chmod +x /root/sgx/sdk.bin && \
    echo -e 'no\n/opt' | /root/sgx/sdk.bin && \
    echo 'source /opt/sgxsdk/environment' >> /root/.bashrc && \
    rm -rf /root/sgx/*

# installing rust-sgx-sdk
ENV rust_toolchain nightly-2019-11-17
RUN wget 'https://static.rust-lang.org/rustup/dist/x86_64-unknown-linux-gnu/rustup-init' -O /root/rustup-init && \
    chmod +x /root/rustup-init && \
    echo '1' | /root/rustup-init --default-toolchain ${rust_toolchain} && \
    echo 'source /root/.cargo/env' >> /root/.bashrc && \
    /root/.cargo/bin/rustup component add rust-src && \
    HI=$(/root/.cargo/bin/rustup which rustc) && HI=${HI%/bin/rustc} && export TOOLCHAIN_DIR=$HI && echo TOOLCHAIN_DIR=$TOOLCHAIN_DIR && \
    rm -rf $TOOLCHAIN_DIR/share/doc && \
    rm -rf $TOOLCHAIN_DIR/share/man && \
    rm -rf /root/.cargo/registry && rm -rf /root/.cargo/git
    # /root/.cargo/bin/cargo install xargo && \

How would I configure gantree to add these setup steps?

brenzi commented 4 years ago

Actually, our preferred solution would be that the host (where we execute gantree-cli) would build the node. We have a very powerful machine for this purpose and all the build dependencies are installed. This might actually be a very robust way for any node with special build requirements

morelazers commented 4 years ago

@brenzi thanks for this - local compile & upload is on our roadmap. Will update this thread when we have a release for you.

morelazers commented 4 years ago

Hey @brenzi - it's not in an official release yet but there's a preview of this feature on the branch feature/binary-local-compile. You can test the branch by cloning the repo and executing it with the command:

node . sync -c my_config_file.json

There are some changes to the config spec in this release, so I would advise you to use this as your config file (some things taken from the other issue you created):

{
  "project": "substraTEE testnet",
  "binary": {
    "url": "https://github.com/scs/substraTEE-node.git",
    "version": "HEAD",
    "name": "substratee-node",
    "localCompile": true
  },
  "validators": {
    "loggingFilter": "runtime=debug,txpool=debug",
    "nodes": [
      {
        "provider": "do",
        "machineType": "s-2vcpu-4gb",
        "count": 3,
        "zone": "fra1",
        "sshUser": "root"
      }
    ]
  }
}

(Note that the "repository" top level key has been changed to "binary")

This assumes that you all the requirements for compilation already installed on the machine you're executing the CLI on. Let me know how you get on!

Also this isn't in our docker container yet, we'll be updating that when we have another stable release.

DrTexx commented 4 years ago

@brenzi we've rolled out stable builds of gantree-lib since with support for this feature, if you experience any issues with localCompile please don't hesitate to open another issue.

Please keep in mind however that you may experience issues using locally compiled binaries on instances if the cloud providers architecture differs significantly enough.