Zcash is unfinished and highly experimental. Use at your own risk.
Automate all the things with a Dockerfile
I wanted to try the code but it turns out you have to build the code for yourself - from scratch that you need Ubuntu or Debian on your system. I started to wonder why there was no Dockerfile?
Well I put a quick one together based upon the official instructions:
This Dockerfile enables the app for work on Windows, Mac, other Linux distro and will be just as at home on a cloud instance or on your laptop.
FROM ubuntu:latest
RUN apt-get update -q && apt-get -qy install \
build-essential pkg-config libc6-dev m4 g++-multilib \
autoconf libtool ncurses-dev unzip git python \
zlib1g-dev wget bsdmainutils automake
WORKDIR /root/
RUN git clone https://github.com/zcash/zcash.git
WORKDIR /root/zcash/
RUN git checkout v1.0.0-rc4
RUN ./zcutil/fetch-params.sh
RUN ./zcutil/build.sh -j$(nproc)
$ docker build -t zcash .
At this point you now perform a fully automated build - regardless of whether Ubuntu is installed and running on your base system.
The resulting image had a size of around 4GB, but bare in mind that this also includes the Ubuntu base image in its size. Here's a summary of the layers created:
CREATED BY SIZE
/bin/sh -c ./zcutil/build.sh -j$(nproc) 2.282 GB
/bin/sh -c ./zcutil/fetch-params.sh 910.2 MB
/bin/sh -c git checkout v1.0.0-rc4 600.6 kB
/bin/sh -c #(nop) WORKDIR /root/zcash/ 0 B
/bin/sh -c git clone https://github.com/zcash 67.2 MB
/bin/sh -c #(nop) WORKDIR /root/ 0 B
/bin/sh -c apt-get update -q && apt-get -qy i 433 MB
I would suggest that the Zcash team think about pushing this image to the Docker Hub. It would reduce your build-to-run time from 30-90mins down to the download time. There doesn't appear to be individual secrets or user config in the steps above.
Here's my image if you want to skip ahead and pull it:
docker pull alexellisio/zcash:latest. It will save waiting for the build to complete.
Configuring your user
Zcash has an official video. Here are the next steps needed once you've built your Docker image.
- Run a container interactively:
$ docker run --name zcash -ti zcash /bin/bash
- Make a settings file:
mkdir ~/.zcash/
cd ~/.zcash/
echo testnet=1 > zcash.conf
echo addnode=testnet.z.cash >> zcash.conf
echo rpcuser=username >> zcash.conf
echo rpcpassword=$(head -c 32 /dev/urandom | base64) >> zcash.conf
That just created a strong password and saved your username into a config file.
- Enable mining
echo gen=1 >> ~/.zcash/zcash.conf
Start mining!
Now you simply type in
~/zcash/src/zcashd and watch the stats collect. You can hit (Control + C) at any time to quit.
This screenshot is running Ubuntu on Docker for Mac on a MacBook Air
If you want to detach from the Docker container, but keep it running hit Control P + Q. You can reattach at any time with
docker attach zcash
If you want to save the state of your container use the docker commitcommand.
You can get additional info on the mining process at any time by typing in:
$ docker exec -ti zcash /root/zcash/src/zcash-cli getinfo
{
"version" : 1000028,
"protocolversion" : 170002,
"walletversion" : 60000,
"balance" : 0.00000000,
"blocks" : 0,
"timeoffset" : 0,
"connections" : 0,
"proxy" : "",
"difficulty" : 1.00000000,
"testnet" : false,
"keypoololdest" : 1477728080,
"keypoolsize" : 101,
"paytxfee" : 0.00000000,
"relayfee" : 0.00005000
}