github.com/munnerz/test-infra@v0.0.0-20190108210205-ce3d181dc989/planter/README.md (about) 1 # Planter 2 Bazel in a container. 3 4 <img src="planter-logo.svg" /> 5 6 Planter is a container + wrapper script for your bazel builds. 7 It will run a Docker container as the current user that can run bazel builds 8 in your `$PWD`. It has been tested on macOS and Linux against 9 `kubernetes/test-infra` and `kubernetes/kubernetes`. 10 11 To build kubernetes set up your `$GOPATH/src` to contain: 12 ``` 13 $GOPATH/src/k8s.io/kubernetes/ # ... <kubernetes/kubernetes checkout> 14 $GOPATH/src/k8s.io/test-infra/ # ... <kubernetes/test-infra checkout> 15 ``` 16 Then from `$GOPATH/src/k8s.io/kubernetes/` run: 17 `./../planter/planter.sh make bazel-build`. 18 19 NOTE: if you previously built Kubernetes by other means, you may need to run 20 `make clean` first to clean up some symlink cycles. 21 22 For `test-infra` you can run eg `./planter/planter.sh bazel test //...`. 23 24 ## Options 25 26 Planter respects the following environment variables: 27 28 - `TAG`: The Planter image tag. This will default to the current stable 29 version used to build Kubernetes, but you may override it with EG 30 `TAG=0.9.0 ./planter.sh bazel build //...` 31 - These should now match bazel release versions eg `0.8.0rc2` 32 - `DRY_RUN`: If set, Planter will only echo the Docker command that would have 33 been run. 34 - `HOME`: Your home directory. This will be mounted in to the container. 35 - `PWD`: Will be set to the working directory in the image. 36 - `USER`: Used to run the image as the current user. 37 38 ## SELinux 39 40 Currently, SELinux is disabled for the container that runs the bazel 41 environment, which allows for the rest of the host system to leave SELinux 42 enabled. We could relabel the volumes and enable SELinux but this could cause 43 major issues on the host if planter was used from say $HOME. 44 45 46 Further details can be found in `planter.sh` itself, which is somewhat 47 self-documenting. 48 49 ## Docker for Mac 50 51 Performance with docker for mac can be quite bad compared to installing bazel 52 natively (which is an option!). If you are going to use planter though, 53 consider tuning the following Docker options: 54 55 - Increase CPU reservation, 4+ cores recommended 56 - Increase Memory reservation, 8+ GB recommended 57 58 You can find these under [preferences > advanced](https://docs.docker.com/docker-for-mac/#advanced) 59 60 Check [this unofficial guide](https://medium.com/@TomKeur/how-get-better-disk-performance-in-docker-for-mac-2ba1244b5b70) 61 and make sure that you are using `.raw` formatted VM disk for the daemon. 62 63 Periodically restarting the daemon (docker for mac tray icon > restart) can 64 also help. In particular if you see the Bazel analysis phase taking a long time 65 consider restarting the docker daemon before trying again. 66 67 We also use [delegated volume mounts](https://docs.docker.com/docker-for-mac/osxfs-caching/) to improve osxfs performance. 68