| 1 | Quick Gitian building with docker |
| 2 | ================================= |
| 3 | |
| 4 | *Setup instructions for a Gitian build of Monero using Docker.* |
| 5 | |
| 6 | Gitian supports other container mechanisms too but if you have a Debian or |
| 7 | Ubuntu-based host the steps can be greatly simplified. |
| 8 | |
| 9 | Preparing the Gitian builder host |
| 10 | --------------------------------- |
| 11 | |
| 12 | The procedure here will create a docker container for build preparation, as well as |
| 13 | for actually running the builds. The only items you must install on your own host |
| 14 | are docker and apt-cacher-ng. With docker installed, you should also give yourself |
| 15 | permission to use docker by adding yourself to the docker group. |
| 16 | |
| 17 | ```bash |
| 18 | sudo apt-get install docker.io apt-cacher-ng |
| 19 | sudo usermod -aG docker $USER |
| 20 | su $USER |
| 21 | ``` |
| 22 | |
| 23 | The final `su` command is needed to start a new shell with your new group membership, |
| 24 | since the `usermod` command doesn't affect any existing sessions. |
| 25 | |
| 26 | You'll also need to clone the monero repository and navigate to the `contrib/gitian` directory: |
| 27 | |
| 28 | ```bash |
| 29 | git clone https://github.com/monero-project/monero.git |
| 30 | cd monero/contrib/gitian |
| 31 | ``` |
| 32 | |
| 33 | Other User Preparation |
| 34 | ---------------------- |
| 35 | |
| 36 | The final step will be to `gpg` sign the results of your build and upload them to GitHub. |
| 37 | Before you can do that, you'll need |
| 38 | * a GitHub account. |
| 39 | If your GitHub account name is different from your local account name, you must |
| 40 | set your GitHub account name for the script to use: |
| 41 | |
| 42 | ```bash |
| 43 | export GH_USER=<github account name> |
| 44 | ``` |
| 45 | |
| 46 | * PGP keys - if you don't have one already, you can use `gpg --quick-gen-key` to generate it. |
| 47 | * a fork of the [gitian.sigs](https://github.com/monero-project/gitian.sigs/) repo on your GitHub account. |
| 48 | Please follow the directions there for uploading your key first. |
| 49 | |
| 50 | **Note:** Please ensure your gpg public key is available to check signatures by adding it to the [gitian.sigs/gitian-pubkeys/](https://github.com/monero-project/gitian.sigs/tree/master/gitian-pubkeys) directory in a pull request. |
| 51 | |
| 52 | |
| 53 | Building the Binaries |
| 54 | --------------------- |
| 55 | |
| 56 | The dockrun.sh script will do everything to build the binaries. Just specify the |
| 57 | version to build as its only argument, e.g. |
| 58 | |
| 59 | ```bash |
| 60 | VERSION=v0.18.5.0 |
| 61 | ./dockrun.sh $VERSION |
| 62 | ``` |
| 63 | |
| 64 | The build should run to completion with no errors, and will display the SHA256 checksums |
| 65 | of the resulting binaries. You'll be prompted to check if the sums look good, and if so |
| 66 | then the results will be signed, and the signatures will be pushed to GitHub. |
| 67 | |
| 68 | ***Note: In order to publish the signed assertions via this script, you need to have your SSH key uploaded to GitHub beforehand. See https://docs.github.com/articles/generating-an-ssh-key/ for more info.*** |
| 69 | |
| 70 | You can also look in the [gitian.sigs](https://github.com/monero-project/gitian.sigs/) repo and / or [getmonero.org release checksums](https://web.getmonero.org/downloads/hashes.txt) to see if others got the same checksum for the same version tag. If there is ever a mismatch -- **STOP! Something is wrong**. Contact others on IRC / GitHub to figure out what is going on. |
| 71 | |
| 72 | |
| 73 | Other Options |
| 74 | ------------- |
| 75 | |
| 76 | This script just runs the [gitian-build.py](gitian-build.py) inside a container named `gitrun`. |
| 77 | You can set other options for that script by setting the OPT variable when running `dockrun.sh` |
| 78 | e.g. |
| 79 | |
| 80 | ```bash |
| 81 | # Run build processes with 8 threads |
| 82 | OPT="-j 8" ./dockrun.sh $VERSION |
| 83 | ``` |
| 84 | |
| 85 | Post-build |
| 86 | ---------- |
| 87 | |
| 88 | You can examine the build and install logs by running a shell in the container, e.g. |
| 89 | |
| 90 | ```bash |
| 91 | # Tail running logs |
| 92 | docker exec -it gitrun /bin/bash |
| 93 | tail -F builder/var/install.log |
| 94 | tail -F builder/var/build.log |
| 95 | |
| 96 | # Inspect logs, in format install-<OS>.log and build-<OS>.log |
| 97 | docker exec -it gitrun /bin/bash |
| 98 | more builder/var/install-linux.log |
| 99 | more builder/var/build-linux.log |
| 100 | ``` |
| 101 | |
| 102 | You can find the compiled archives inside of the container at the following directory: |
| 103 | |
| 104 | ```bash |
| 105 | docker exec -it gitrun /bin/bash |
| 106 | ls -la out/$VERSION/ |
| 107 | ``` |
| 108 | |
| 109 | To copy the compiled archives to the local host out of the Docker container, you can run the following: |
| 110 | |
| 111 | ```bash |
| 112 | mkdir out |
| 113 | docker cp gitrun:/home/ubuntu/out/$VERSION out |
| 114 | ``` |