- Install Bazelisk: https://bazel.build/install/bazelisk
- Clone this repository
- Ensure you have a JDK 21 installed, any should work but Zulu is recommended (See troubleshooting if you have issues)
- Run
bazel build //workshop/case1:hello
to see if everything is working - Check out the workshop cases below
- For Mac, openjdk installed through homebrew is missing some libs - try with Zulu JDK
brew install --cask zulu@21
- If Bazel picks up the wrong JDK, you can set the JAVA_HOME environment variable to the correct path and run
echo "startup --server_javabase=\"$JAVA_HOME\"" >> $HOME/.bazelrc
to explicitly tell Bazel to use the correct JDK
This repo contains simple examples to get you started with Bazel.
It also contains a CI workflow that shows how to build and test all changed targets, and how you can use Bazel to build containers in multiple languages with the same CI setup.
- Case 1: Hello World in Bazel
- Case 2: Generate code from OpenApi specifications
- Case 3: Spring Boot in Bazel
- Case 4: Vite + React frontend in Bazel
- Case 5: Bazel in CI / multiple teams
This workshop works with a free online remote cache to speed up builds, called NativeLink.
Register for a free account, and the configuration from the service to .aspect/bazelrc/user.bazelrc
which will not be checked in to the repository.
Example:
build --remote_cache=grpcs://cas-<github-user>.build-faster.nativelink.net
build --remote_header=x-nativelink-api-key=<api-key>
build --bes_backend=grpcs://bes-<github-user>.build-faster.nativelink.net
build --bes_header=x-nativelink-api-key=<api-key>
build --remote_timeout=600
This is in use by the CI workflow for this repository as well, and will speed up your builds significantly.
Contains larger applications with multiple languages and toolsets. Also used as an example how you can structure your monorepo to leverage Team isolation, and thereby also make it possible to use git sparse-checkout to keep only files relevant to you visible.
- Bazel documentation official documentation
- Bazel Examples from Aspect Dev
- Bazel on Slack (You can find us here if you want to chat about anything Bazel related!)
- Aspect dev docs contains a lot of good examples and explanations
Add to .bazelrc
startup --output_user_root=C:/tmp