rs-ipfs / substrate

Substrate: The platform for blockchain innovators
Apache License 2.0
28 stars 5 forks source link

dockerfile and rust-ipfs update for offchain-ipfs-bleeding-edge #1

Closed whalelephant closed 4 years ago

whalelephant commented 4 years ago

Updates: This is now updates to the bleeding edge branch with

Warning: Dockerfile does not expose port for ipfsConnect function.


Building the image

cd substrate
docker build --file .maintain/Dockerfile --tag substrate-ipfs .

This is a multistage build with the target being an image with name substrate-ipfs:latest containing the substrate binary and the node-template binary.

Run the node-template binary

docker run \
    -p 9944:9944 \
    -p 9933:9933 \
    -p 30333:30333 \
    -p 9615:9615 \
    -it \
    --rm \
    --name node-template \
    substrate-ipfs

By default, the container will execute a command for staring the node-template binary with a development chainspec. We expose the default websockets, rpc, p2p and promentheus ports from the container to the host machine for interactions.

To run with persistent storage volume between contains, create a volume with docker volume create substrate-ipfs-vol and -v substrate-ipfs-vol:/substrate-ipfs to the docker run command.

Run substrate node

docker run \
    -p 9944:9944 \
    -p 9933:9933 \
    -p 30333:30333 \
    -p 9615:9615 \
    -it \
    --rm \
    --name sub-ipfs \
    substrate-ipfs \
    substrate

To overwrite the default container commands, simply add binary name followed by flags / options / subcommand.

aphelionz commented 4 years ago

So far so good! The first docker run command in your issue description works for me:

The second command however...

$ docker run \
    -p 9944:9944 \
    -p 9933:9933 \
    -p 30333:30333 \
    -p 9615:9615 \
    -it \
    --rm \
    --name sub-ipfs \
    substrate-ipfs \
    substrate

Gives me this in the logs. Not sure if consequential. @ljedrz ?

2020-10-06 13:39:14.439 tokio-runtime-worker WARN telemetry  ❌ Error while dialing /dns/telemetry.polkadot.io/tcp/443/x-parity-wss/%2Fsubmit%2F: Custom { kind: Other, error: Other(B(A(Transport(Underlying(Kind(ConnectionRefused)))))) }
aphelionz commented 4 years ago

Still getting a 217MB image at the end as well, wondering if we can get that smaller somehow :thinking:

Edit: although to your credit, the builder image is 7 GB :rofl:

REPOSITORY                           TAG                 IMAGE ID            CREATED             SIZE
substrate-ipfs                       latest              0349ec5e1bdb        5 minutes ago       217MB
<none>                               <none>              04088caa4803        5 minutes ago       7.07GB
ljedrz commented 4 years ago

Not sure if consequential.

don't think so, looks like just some telemetry server

whalelephant commented 4 years ago

😄 it did slim down quite a bit!

The binaries themselves are around 120MB and the container 69MB, can look at what is not needed in the container after the updates.

-rwxr-xr-x   2 root root   53M Oct  6 08:58 node-template
-rwxr-xr-x   2 root root   65M Oct  6 08:57 substrate
aphelionz commented 4 years ago

@whalelephant This looks great, and I'm comfortable approving this for merging into our branch, just the comment above and the questions below remain:

  1. I don't thInk we need to PR this upstream given the long compile times and their explicit note about not using Alpine. On our end, we can accept the trade off of the long build time because we're delivering a small docker container.
  2. For merging, @ljedrz which branch should this be merged to. I assume we can git-fu the commit anywhere we need it to go, but just let us know.
aphelionz commented 4 years ago

@whalelephant minor housekeeping thing - let's change all the references from substrate-ipfs to offchain-ipfs as I'll be publishing the docker image to eqlabs/offchain-ipfs

aphelionz commented 4 years ago

Closing this now that we have the branch :+1: re-open if I'm wrong.