Skip to content

Commit add67d9

Browse files
konstantin-s-bogomgvisor-bot
authored andcommitted
Update README with instructions on using Bazel directly.
A pointer to the build Dockerfile will be helpful. PiperOrigin-RevId: 797484293
1 parent a995f54 commit add67d9

File tree

2 files changed

+34
-3
lines changed

2 files changed

+34
-3
lines changed

README.md

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,22 @@ To build specific libraries or binaries, you can specify the target:
8787
make build TARGETS="//pkg/tcpip:tcpip"
8888
```
8989

90+
### Building directly with Bazel (without Docker)
91+
92+
Using Bazel directly isn't recommended due to the extra overhead, but in order
93+
to get started:
94+
95+
- Look at the [build dockerfile](images/default/Dockerfile) for the canonical
96+
list of needed dependencies.
97+
- Install and use [bazelisk][bazelisk]. Otherwise, make sure your bazel
98+
version matches the one listed in the [.bazelversion](.bazelversion) file.
99+
100+
After setting up dependencies, using Bazel is similar to the Makefile:
101+
102+
```sh
103+
bazel build //runsc:runsc
104+
```
105+
90106
### Testing
91107

92108
To run standard test suites, you can use:
@@ -99,17 +115,22 @@ make tests
99115
To run specific tests, you can specify the target:
100116

101117
```sh
118+
# Makefile
102119
make test TARGETS="//runsc:version_test"
120+
# Bazel
121+
bazel test //runsc:version_test
103122
```
104123

124+
### Mac OS
125+
105126
Some packages support running tests directly on macOS. At the time of this
106-
writing, gVisor requires bazel 7, which you can install via homebrew:
127+
writing, gVisor requires bazel 8, which you can install via homebrew:
107128

108129
```sh
109-
brew install bazel@7
130+
brew install bazel@8
110131

111132
# You can then run the tests, e.g.:
112-
$(brew --prefix bazel@7)/bin/bazel test --macos_sdk_version=$(xcrun --show-sdk-version) -- //tools/nogo/... //tools/check{aligned,const,escape,linkname,locks,unsafe}/...
133+
$(brew --prefix bazel@8)/bin/bazel test --macos_sdk_version=$(xcrun --show-sdk-version) -- //tools/nogo/... //tools/check{aligned,const,escape,linkname,locks,unsafe}/...
113134
```
114135

115136
### Using `go get`
@@ -161,3 +182,4 @@ See [Contributing.md](CONTRIBUTING.md).
161182
[oci]: https://www.opencontainers.org
162183
[old-linux]: https://gvisor.dev/docs/user_guide/networking/#gso
163184
[sandbox]: https://en.wikipedia.org/wiki/Sandbox_(computer_security)
185+
[bazelisk]: https://github.com/bazelbuild/bazelisk

images/default/Dockerfile

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
FROM ubuntu:22.04
22

33
ENV DEBIAN_FRONTEND="noninteractive"
4+
5+
#-------------------------------------------------------------------------------
6+
# Note: If you want to use bazel directly you will need these packages or their
7+
# equivalents for your distribution:
8+
#-------------------------------------------------------------------------------
49
RUN apt-get update && apt-get install -y curl gnupg2 git \
510
python-is-python3 python3 python3-distutils python3-pip \
611
build-essential crossbuild-essential-arm64 qemu-user-static \
@@ -14,6 +19,10 @@ RUN apt-get update && apt-get install -y curl gnupg2 git \
1419
# This package is needed to build eBPF on amd64, but not on arm64 where it
1520
# doesn't exist.
1621
RUN test "$(uname -m)" != x86_64 && exit 0 || apt-get install -y libc6-dev-i386
22+
#-------------------------------------------------------------------------------
23+
# The rest of the file is unnecessary for building `runsc`, but are necessary
24+
# for test targets.
25+
#-------------------------------------------------------------------------------
1726

1827
# Install Docker client for the website build.
1928
RUN curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add -

0 commit comments

Comments
 (0)