diff --git a/.gitignore b/.gitignore index 58750fe76c..74bc9bf241 100644 --- a/.gitignore +++ b/.gitignore @@ -13,4 +13,4 @@ node_modules yarn.lock *.log output -deploy \ No newline at end of file +deploy diff --git a/Dockerfile b/Dockerfile index 66590805f8..dd73356549 100644 --- a/Dockerfile +++ b/Dockerfile @@ -15,39 +15,30 @@ # along with Bifrost. If not, see . # syntax=docker/dockerfile:1 -FROM ubuntu:20.04 as builder +FROM rust:buster as builder -ENV DEBIAN_FRONTEND noninteractive - -ENV PATH=$PATH:$HOME/.cargo/bin - -RUN apt-get update && \ - apt-get dist-upgrade -y && \ - apt-get install -y cmake pkg-config libssl-dev git clang libclang-dev curl apt-utils openssh-client - -RUN curl https://sh.rustup.rs -sSf | sh -s -- -y && \ - export PATH="$PATH:$HOME/.cargo/bin" && \ - rustup default nightly && \ - rustup target add wasm32-unknown-unknown --toolchain nightly +RUN apt-get update && apt-get install time clang libclang-dev llvm -y +RUN rustup toolchain install nightly +RUN rustup target add wasm32-unknown-unknown --toolchain nightly WORKDIR /app COPY . /app RUN mkdir -p -m 0600 ~/.ssh && ssh-keyscan github.com >> ~/.ssh/known_hosts - RUN --mount=type=ssh export PATH="$PATH:$HOME/.cargo/bin" && \ make build-all-release - # ===== SECOND STAGE ====== FROM ubuntu:20.04 WORKDIR /bifrost -RUN apt-get update && \ - apt-get dist-upgrade -y && \ - apt install -y openssl libssl-dev -RUN useradd -m -u 1000 -U -s /bin/sh -d /bifrost bifrost +RUN rm -rf /usr/share && \ + rm -rf /usr/lib/python* && \ + useradd -m -u 1000 -U -s /bin/sh -d /bifrost bifrost && \ + mkdir -p /bifrost/.local/data && \ + chown -R bifrost:bifrost /bifrost && \ + ln -s /bifrost/.local/data /data COPY --from=builder /app/target/release/bifrost /usr/local/bin COPY ./node/service/res/asgard.json /bifrost @@ -55,15 +46,12 @@ COPY ./node/service/res/bifrost.json /bifrost # checks RUN ldd /usr/local/bin/bifrost && \ - /usr/local/bin/bifrost --version + /usr/local/bin/bifrost --version -# Shrinking -RUN rm -rf /usr/lib/python* && \ - rm -rf /usr/bin /usr/sbin /usr/share/man USER bifrost EXPOSE 30333 9933 9944 -VOLUME ["/bifrost"] +VOLUME ["/data"] -ENTRYPOINT ["/usr/local/bin/bifrost"] \ No newline at end of file +ENTRYPOINT ["/usr/local/bin/bifrost"] \ No newline at end of file diff --git a/README.md b/README.md index 21b72b63b1..ba7b4f2782 100644 --- a/README.md +++ b/README.md @@ -56,14 +56,14 @@ RUST_LOG=debug cargo run -p node-cli --locked --features "with-dev-runtime" -- - ## Run local testnet with polkadot-launch -Install `polkadot-launch`: +### Install `polkadot-launch` ```bash yarn global add polkadot-launch cd - ``` -Build polkadot: +### Build polkadot ```bash git clone -n https://github.com/paritytech/polkadot.git /tmp/polkadot @@ -73,7 +73,7 @@ cargo build --release cd - ``` -Launch Polkadot and the parachain: +### Launch Polkadot and the parachain ```bash cd - @@ -81,3 +81,28 @@ polkadot-launch ./scripts/bifrost-launch.json ``` It will take about 1-2 minutes for the parachain to start producing blocks. + +## Run local testnet with parachain-launch + +### Install `parachain-launch` + +```sh +yarn global add @open-web3/parachain-launch +``` + +### Generate docker files + +```sh +parachain-launch generate --config=scripts/bifrost-docker-launch.yml --yes +``` + +It will pull images and generate required docker files in a folder called `output` in your current working directory + +### Start relaychain and parachain + +To start the nodes, navigate to the output folder that the generated docker scripts in and start containers: + +```sh +cd ./output +docker-compose up -d --build +``` \ No newline at end of file diff --git a/scripts/bifrost-docker-launch.yml b/scripts/bifrost-docker-launch.yml new file mode 100644 index 0000000000..b0b1affed2 --- /dev/null +++ b/scripts/bifrost-docker-launch.yml @@ -0,0 +1,63 @@ +# Relaychain Configuration +relaychain: + image: parity/polkadot:v0.9.8 # the docker image to use + chain: rococo-local # for test purpose we use rococo + runtimeGenesisConfig: # additonal genesis override + parachainsConfiguration: + config: + validation_upgrade_frequency: 1 + validation_upgrade_delay: 1 + env: # environment variables for all relaychain nodes + RUST_LOG: parachain::candidate-backing=trace + flags: # additional CLI flags for all relaychain nodes + - --rpc-methods=unsafe + - --no-beefy + nodes: # nodes config + - name: alice # the node name and session key, this imply `--alice` + wsPort: 9944 # default ws port number is `9944 + global_node_index` + rpcPort: 9933 # default rpc port number is `9933 + global_node_index` + port: 30333 # default libp2p port number is `30333 + global_node_index` + flags: # additional CLI flags for this node + - --force-authoring + env: + RUST_LOG: debug # environment varitables for this node + - name: bob + - name: charlie + +# Parachain Configuration +parachains: + # Config for first parachain + - image: ronyang/bifrost:0.8.1-fix_data + chain: # this could be a string like `dev` or a config object + base: bifrost-local # the chain to use + collators: # override collators + - alice # this imply //Alice + - rXMrmePtNnyZ61hvpjfEEZ1zmKzueUnTqijDncTzE8Wa2sJ # or could be a session key public address + - charlie + sudo: alice # override sudo key to //Alice + id: 3000 # override parachain id + parachain: true # this is parachain, not parathread + flags: # CLI flags for this parachain nodes + - --rpc-methods=unsafe + - --force-authoring + - --execution=wasm + relaychainFlags: # CLI flags for the relaychain port + - --execution=wasm + - --no-beefy + env: # environment variables for this parachain nodes + RUST_LOG: sc_basic_authorship=trace + nodes: # nodes config + - wsPort: 9947 + rpcPort: 9936 + port: 30336 + flags: # additional CLI flags for this node + - --alice + relaychainFlags: # additional CLI flags for relaychian part + - --name=relaychain-alice + env: + RUST_LOG: debug # environment varitables for this node + - flags: + - --bob + - flags: + - --charlie +