Skip to content

support floonet, separate entrypoint from cmd, add docker volume#2265

Merged
ignopeverell merged 3 commits intomimblewimble:masterfrom
kim0:master
Jan 2, 2019
Merged

support floonet, separate entrypoint from cmd, add docker volume#2265
ignopeverell merged 3 commits intomimblewimble:masterfrom
kim0:master

Conversation

@kim0
Copy link
Contributor

@kim0 kim0 commented Dec 31, 2018

  • Support floonet as a buildtime ARG
  • Separate entrypoint from cmd, allowing the use of different grin sub-commands on docker run
  • Adding a docker volume to hold state

@kim0
Copy link
Contributor Author

kim0 commented Dec 31, 2018

@Kargakis .. This is a continuation of #2257 which it seems I closed .. Anyway, this is a bigger revamp.

@ignopeverell
Copy link
Contributor

This doesn't look like it's going to run Floonet (no --floonet option) but exposes future mainnet ports?

@kim0
Copy link
Contributor Author

kim0 commented Dec 31, 2018

@ignopeverell .. I default to mainnet .. To build --floonet use the below

docker build -t grin -f etc/Dockerfile . --build-arg grinnet=--floonet

Ofc, grinnet could be anything else supported by grin. If not mentioned (default), it should default to mainnet

RUN grin ${grinnet} server config && \
sed -i -e 's/run_tui = true/run_tui = false/' grin-server.toml

VOLUME ["/root/.grin"]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The volume cmd is unnecessary?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope, it's useful .. When it's not marked as a volume .. docker does not copy data from inside the image to that location .. so the grin-server.toml is not copied to that external location. While when marked as a volume, it is. When it's marked as a volume, we should pass a volume name like docker run ... -v dotgrin:/root/.grin .. and see the volume with docker volume ls

AFAICT, this is how docker should be used! And it works well. When bind mounting a volume -v .:/root/.grin .. docker does NOT copy the grin-server.toml file.

EXPOSE 13413 13414 13415 13416

ENTRYPOINT ["grin", "server", "run"]
EXPOSE 3413 3414 3415 3416
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a comment that these are the mainnet ports.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

ENTRYPOINT ["grin", "server", "run"]
EXPOSE 3413 3414 3415 3416

ENTRYPOINT ["grin"]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't you be using grinnet here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not really .. since ARG is only available at buildtime. In run time, passing --floonet should just be regarded as extra cli args, which are now supported. So for running a floonet container, I use:
docker run --rm -it -p 13413-13416:13413-13416 -v dotgrin:/root/.grin --name grin grin --floonet server run

@0xmichalis
Copy link
Contributor

docker build -t grin -f etc/Dockerfile . --build-arg grinnet=--floonet

@kim0 can you update the build docs with this?

https://github.com/mimblewimble/grin/blob/master/doc/build.md#docker

ARG grinnet=""

RUN grin ${grinnet} server config && \
sed -i -e 's/run_tui = true/run_tui = false/' grin-server.toml
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This command is going to fail now since each network gets its own directory. Are you able to build the image correctly?

Copy link
Contributor

@0xmichalis 0xmichalis Dec 31, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hrm, maybe grin server config just spits out the config w/o creating the extra directory..

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That was my impression too .. but when I tested, it worked .. I see the below inside the container

root@27fa945a58d6:~/.grin# ls
chain_data  floo  grin-server.log  grin-server.toml
root@27fa945a58d6:~/.grin# ls floo/
root@27fa945a58d6:~/.grin# ls -la floo/
total 10
drwxr-xr-x 2 root root  3 Dec 31 19:31 .
drwxr-xr-x 4 root root  6 Dec 31 19:31 ..
-rw-r--r-- 1 root root 20 Dec 31 19:31 .api_secret

@kim0
Copy link
Contributor Author

kim0 commented Dec 31, 2018

@Kargakis .. I see 2 paths ... either the one above .. and I simply add a couple of lines of docs on how to build and run in both cases (floonet and mainnet) .. or we simply create 2 dockerfiles (Dockerfile for mainnet, and Dockerfile.floonet for floonet) and we basically avoid the 2 extra pieces of config when using floonet (--build-arg when building, and --floonet arg when running), at the expense of maintaining 2 separate files

Let me know which path makes more sense to you, and I'll adjust and update the readme
thanks!

@kim0
Copy link
Contributor Author

kim0 commented Dec 31, 2018

In my opinion, I think the 2 files solution would be slightly better. Also, ideally grin would accept some configs from environment variables export GRINNET=floonet or so! Like all buzzword compliant apps (cloud-native ..etc) should :)

@0xmichalis
Copy link
Contributor

0xmichalis commented Dec 31, 2018 via email

@kim0
Copy link
Contributor Author

kim0 commented Dec 31, 2018

@Kargakis .. Does that look better? I'm still awaiting the build on my box, which takes 24 mins :) Is there any interest to try improving performance by caching some docker layers? Let me know, and I can work on it .. it will add a few lines to the dockerfile though

doc/build.md Outdated
```sh
docker build -t grin -f etc/Dockerfile .
```
for floonet, use `etc/Dockerfile.floonet` instead
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: "For floonet, use etc/Dockerfile.floonet instead."

doc/build.md Outdated
```sh
docker run -it -d -v $HOME/.grin:/root/.grin grin
```
if you prefer to use a docker named volume, you can pass `-v dotgrin:/root/.grin` instead.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If

doc/build.md Outdated
docker run -it -d -v $HOME/.grin:/root/.grin grin
```
if you prefer to use a docker named volume, you can pass `-v dotgrin:/root/.grin` instead.
Using a named volume copies a default grin-server.toml
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The grin cache does not contain only the server config. Also, is this true for named volumes that already contain cached data?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I know it contains other data. When docker creates a new volume .. it will copy everything in the image under /root/.grin to that volume. But it will not for a bind mounted directory. When using a named volume -v dotgrin:/root/.grin .. if the volume contains data, it will not be overwritten

@0xmichalis
Copy link
Contributor

@Kargakis .. Does that look better? I'm still awaiting the build on my box, which takes 24 mins :) Is there any interest to try improving performance by caching some docker layers? Let me know, and I can work on it .. it will add a few lines to the dockerfile though

Yes, it looks good to me, had just a couple of comments in the docs. Regarding speeding up the docker build, we could tear down the whole build step process and bind-mount the binary from the host, so the flow for building the image would be something like this:

cargo build --release
docker build -t grin -f etc/Dockerfile

and inside the container we would

COPY target/release/grin /usr/bin/

The downside would be that we would have to keep the dependencies on the host but I think most folks who build it have the necessary deps installed already.

@kim0
Copy link
Contributor Author

kim0 commented Dec 31, 2018

@Kargakis .. I fixed the typos .. Let's get this merged if you like :)

I don't really like having the build deps on the host for reproducibility at least .. let's look at improving build performance in a separate PR .. Thanks!

@0xmichalis
Copy link
Contributor

0xmichalis commented Dec 31, 2018

Thanks, lgtm

@ignopeverell ignopeverell merged commit daa712a into mimblewimble:master Jan 2, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants