Initial commit

This commit is contained in:
Taylor Hornby 2019-04-16 22:44:17 -06:00
commit 62b1334be9
5 changed files with 208 additions and 0 deletions

129
README.md Normal file
View File

@ -0,0 +1,129 @@
# Zcash Docker Development Environment
This repository contains a Dockerfile that will help you get started building
Zcash's mobile app wallet stack. The projects' code is kept on your host
filesystem and shared into the docker container, so you can keep using the
editors and tools you're familiar with, and only use the container to run
builds. You can also run the `zcashd` and `lightwalletd` services within the
container.
The development environment currently supports building:
- `zcashd`
- `librustzcash` (preview branch)
- `lightwalletd` (preview branch)
- `zcash-android-wallet-sdk` (preview branch)
It does not yet support:
- `zcash-android-wallet-poc`
## Quick Start
First, checkout this repository:
```
git checkout <this-repository's-url>
cd zdev-docker
```
Next, build the Docker image. This will create an image called `zdev` which
has all of the build dependencies pre-installed:
```
docker build -t zdev docker
```
Now, clone all of the projects you want to work on into the `mount/` directory:
```
cd mount
git clone git@github.com:zcash/zcash.git
git clone git@github.com:zcash-hackworks/lightwalletd.git
git clone git@github.com:str4d/librustzcash.git --branch preview
git clone git@github.com:zcash/zcash-android-wallet-sdk.git --branch preview
cd ..
```
You can now launch a new container instance of `zdev` and have access to your
clones of `zcash`, `lightwalletd`, etc. from within:
```
docker run -it --mount type=bind,source="$(pwd)"/mount,target=/mount zdev
```
The `./mount` directory will be shared between the host and the container,
accessible in the container at `/mount`. The changes you make to files inside
`/mount` in the container will change the files in `./mount`. **Docker
containers are ephemeral, so any changes you make to the container outside of
`/mount` will be lost.**
You can run build commands inside the container, for example:
```
cd /mount/zcash
./zcutil/build.sh -j$(nproc)
./zcutil/fetch-params.sh
./qa/zcash/full-test-suite.py
```
See the individual projects' documentation for build instructions.
## Docker Tips
To update the Ubuntu packages in the `zdev` image or make changes to which
dependencies are installed, edit the `docker/install-build-dependencies.sh`
script and then re-build the `zdev` image using the same command as above. The
changes will take effect in the next container instance you launch.
To open another shell into a running container, run `docker container ls`, copy
the container ID, and then run `docker exec -it <container ID> bash`.
## Build Instructions
THESE ARE UNOFFICIAL INSTRUCTIONS. SEE THE INDIVIDUAL PROJECTS' DOCUMENTATION
FOR POSSIBLY-MORE-ACCURATE INSTRUCTIONS.
**Note:** All of the builds are independent for now, i.e. the build output of
`librustzcash` *doesn't* get used as an input to the `zcash-android-wallet-sdk`
build.
**`zcashd`**
```
cd /mount/zcash
./zcutil/build.sh -j$(nproc)
```
**`librustzcash`**
```
cd /mount/librustzcash
cargo build --release
```
**`lightwalletd`**
```
cd /mount/lightwalletd
go run cmd/injest/main.go <...>
go run cmd/server/main.go <...>
```
**`zcash-android-wallet-sdk`**
```
cd /mount/zcash-android-wallet-sdk
./gradlew clean assembleZcashtestnetRelease
```
## Running the Stack
TODO
## TODOs
- Put `.zcash-params` in the image.
- Put `.zcash-mainnet` and `.zcash-testnet` fully loaded into the image.
- Make the builds use the output of the dependency builds
- Instructions for starting/stopping the container
- Security review (are tools/code being downloaded safely? etc)

14
docker/Dockerfile Normal file
View File

@ -0,0 +1,14 @@
FROM ubuntu:18.04
COPY * /root/docker/
RUN /root/docker/install-basics.sh
RUN /root/docker/install-build-dependencies.sh
# Set environment variables.
ENV HOME /root
# Define working directory.
WORKDIR /root
# Define default command.
CMD ["bash"]

9
docker/install-basics.sh Executable file
View File

@ -0,0 +1,9 @@
#!/bin/bash
set -e
cd /root/docker
# Update packages and set up the basics.
sed -i 's/# \(.*multiverse$\)/\1/g' /etc/apt/sources.list
apt-get update
apt-get -y upgrade
apt-get install -y software-properties-common curl git htop man unzip vim wget ack

View File

@ -0,0 +1,55 @@
#!/bin/bash
set -e
cd /root/docker
# Dependencies for zcashd
# =================================================
apt-get install -y \
build-essential pkg-config libc6-dev m4 g++-multilib \
autoconf libtool ncurses-dev unzip git python python-zmq \
zlib1g-dev wget curl bsdmainutils automake
apt-get install -y python-pip
pip install pyblake2
# Dependencies for lightwalletd
# =================================================
# Golang
wget https://dl.google.com/go/go1.12.4.linux-amd64.tar.gz -O go.tar.gz
tar xvf go.tar.gz
mv go /usr/local/
rm go.tar.gz
echo 'export GOROOT=/usr/local/go' >> /root/.bashrc
echo 'export PATH=/usr/local/go/bin:$PATH' >> /root/.bashrc
# Dependencies for librustzcash
# =================================================
# Rust
curl https://sh.rustup.rs -sSf | sh -s -- -y
echo 'export PATH=/root/.cargo/bin:$PATH' >> /root/.bashrc
# Dependencies for zcash-android-wallet-sdk
# =================================================
# JDK
apt-get install -y zsh openjdk-8-jdk cmake
# Android SDK
# Credit: https://medium.com/@AndreSand/building-android-with-docker-8dbf717f54d4
ANDROID_HOME=/usr/local/android-sdk
echo 'export ANDROID_SDK_ROOT=/usr/local/android-sdk' >> /root/.bashrc
echo 'export ANDROID_HOME=/usr/local/android-sdk' >> /root/.bashrc
mkdir /root/.android
mkdir -p "$ANDROID_HOME"
cd "$ANDROID_HOME"
wget https://dl.google.com/android/repository/sdk-tools-linux-4333796.zip -O android-sdk.zip
unzip android-sdk.zip
rm android-sdk.zip
mkdir "$ANDROID_HOME/licenses"
echo "24333f8a63b6825ea9c5514f83c2829b004d1fee" > "$ANDROID_HOME/licenses/android-sdk-license"
ls -la "$ANDROID_HOME"
yes | "$ANDROID_HOME/tools/bin/sdkmanager" --licenses
# Android NDK
"$ANDROID_HOME/tools/bin/sdkmanager" "ndk-bundle"

1
mount/test.txt Normal file
View File

@ -0,0 +1 @@
It works!