2017-06-16 10:59:01 -07:00
# Building Rook
2021-06-04 13:45:01 -06:00
Rook is composed of a golang project and can be built directly with standard `golang` tools,
2017-06-16 10:59:01 -07:00
and storage software (like Ceph) that are built inside containers. We currently support
2021-06-04 13:45:01 -06:00
these platforms for building:
2017-06-16 10:59:01 -07:00
2020-06-08 10:50:50 +02:00
* Linux: most modern distributions should work although most testing has been done on Ubuntu
* Mac: macOS 10.6+ is supported
2017-06-16 10:59:01 -07:00
## Build Requirements
2021-06-04 13:45:12 -06:00
Recommend 2+ cores, 8+ GB of memory and 128GB of SSD. Inside your build environment (Docker for Mac or a VM), 2+ GB memory is also recommended.
2017-06-16 10:59:01 -07:00
The following tools are need on the host:
2020-06-08 10:50:50 +02:00
* curl
* docker (1.12+) or Docker for Mac (17+)
* git
* make
* golang
* rsync (if you're using the build container on mac)
2021-12-27 02:00:18 +00:00
* helm
2017-06-16 10:59:01 -07:00
## Build
2018-07-19 12:36:30 -06:00
You can build the Rook binaries and all container images for the host platform by simply running the
command below. Building in parallel with the `-j` option is recommended.
2017-06-16 10:59:01 -07:00
2020-06-08 10:50:50 +02:00
```console
2017-06-16 10:59:01 -07:00
make -j4
```
2018-07-19 12:36:30 -06:00
Developers may often wish to make only images for a particular backend in their testing. This can
be done by specifying the `IMAGES` environment variable with `make` as exemplified below. Possible
2020-06-08 10:50:50 +02:00
values for are as defined by sub-directory names in the `/rook/images/` dir. Multiple images can be separated by a space.
2017-06-16 10:59:01 -07:00
2020-06-08 10:50:50 +02:00
```console
2018-10-02 15:43:53 -06:00
make -j4 IMAGES='ceph' build
2018-04-26 15:28:39 +08:00
```
2017-06-16 10:59:01 -07:00
Run `make help` for more options.
2021-06-04 13:45:01 -06:00
## CI Workflow
2017-06-16 10:59:01 -07:00
2021-06-04 13:45:01 -06:00
Every PR and every merge to master triggers the CI process in Github actions.
On every commit to PR and master the CI will build, run unit tests, and run integration tests.
If the build is for master or a release, the build will also be published to
[dockerhub.com ](https://cloud.docker.com/u/rook/repository/list ).
2017-06-16 10:59:01 -07:00
2021-09-22 12:39:16 -06:00
> Note that if the pull request title follows Rook's [contribution guidelines](https://rook.io/docs/rook/latest/development-flow.html#commit-structure), the CI will automatically run the appropriate test scenario. For example if a pull request title is "ceph: add a feature", then the tests for the Ceph storage provider will run. Similarly, tests will only run for a single provider with the "cassandra:" and "nfs:" prefixes.
2017-06-16 10:59:01 -07:00
## Building for other platforms
2018-07-19 12:36:30 -06:00
You can also run the build for all supported platforms:
2020-06-08 10:50:50 +02:00
```console
2018-07-19 12:36:30 -06:00
make -j4 build.all
```
Or from the cross container:
2020-06-08 10:50:50 +02:00
```console
2018-07-19 12:36:30 -06:00
build/run make -j4 build.all
```
Currently, only `amd64` platform supports this kind of 'cross' build. In order to make `build.all`
succeed, we need to follow the steps specified by the below section `Building for other platforms`
first.
We suggest to use native `build` to create the binaries and container images on `arm{32,64}`
platform, but if you do want to build those `arm{32,64}` binaries and images on `amd64` platform
with `build.all` command, please make sure the multi-arch feature is supported. To test run the
following:
2020-06-08 10:50:50 +02:00
```console
2018-07-19 12:36:30 -06:00
> docker run --rm -ti arm32v7/ubuntu uname -a
Linux bad621a75757 4.8.0-58-generic #63~16.04.1-Ubuntu SMP Mon Jun 26 18:08:51 UTC 2017 armv7l armv7l armv7l GNU/Linux
> docker run --rm -ti arm64v8/ubuntu uname -a
Linux f51ea93e76a2 4.8.0-58-generic #63~16.04.1-Ubuntu SMP Mon Jun 26 18:08:51 UTC 2017 aarch64 aarch64 aarch64 GNU/Linux
```
2017-06-16 10:59:01 -07:00
In order to build container images for these platforms we rely on cross-compilers and QEMU. Cross compiling is much faster than QEMU and so we lean heavily on it.
In order for QEMU to work inside docker containers you need to do a few things on
the linux host. If you are using a recent Docker for Mac build you can skip this section, since they added support for binfmt and multi-arch docker builds.
On an Ubuntu machine with a 4.8+ kernel you need to run install the following:
2020-06-08 10:50:50 +02:00
```console
2017-06-16 10:59:01 -07:00
DEBIAN_FRONTEND=noninteractive apt-get install -yq --no-install-recommends \
binfmt-support
qemu-user-static
```
You also need to run the following on every boot:
2020-06-08 10:50:50 +02:00
```console
2017-06-16 10:59:01 -07:00
docker run --rm --privileged hypriot/qemu-register
```
you can install a systemd unit to help with this if you'd like, for example:
2020-06-08 10:50:50 +02:00
```console
2017-06-16 10:59:01 -07:00
cat <<EOF > /etc/systemd/system/update-binfmt.service
[Unit]
After=docker.service
[Service]
Type=oneshot
ExecStartPre=/usr/bin/docker pull hypriot/qemu-register
ExecStart=/usr/bin/docker run --rm --privileged hypriot/qemu-register
RemainAfterExit=yes
[Install]
WantedBy=multi-user.target
EOF
systemctl enable update-binfmt.service
```