Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ node_modules
yarn.lock
*.log
output
deploy
deploy
38 changes: 13 additions & 25 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,55 +15,43 @@
# along with Bifrost. If not, see <http:#www.gnu.org/licenses/>.

# 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
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"]
ENTRYPOINT ["/usr/local/bin/bifrost"]
31 changes: 28 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -73,11 +73,36 @@ cargo build --release
cd -
```

Launch Polkadot and the parachain:
### Launch Polkadot and the parachain

```bash
cd -
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
```
63 changes: 63 additions & 0 deletions scripts/bifrost-docker-launch.yml
Original file line number Diff line number Diff line change
@@ -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