Skip to content
This repository was archived by the owner on Nov 30, 2023. It is now read-only.

Commit 799bb80

Browse files
authored
Migrate Bazel to Bazelisk version manager (#1160)
* Update Bazel version * Migrate to Bazelisk * Change description of the sha checksum
1 parent 6ef1db6 commit 799bb80

File tree

3 files changed

+25
-32
lines changed

3 files changed

+25
-32
lines changed

containers/bazel/.devcontainer/Dockerfile

+6-7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# You can pick any Debian/Ubuntu-based image. 😊
2-
FROM mcr.microsoft.com/vscode/devcontainers/base:buster
2+
FROM mcr.microsoft.com/vscode/devcontainers/base:bullseye
33

44
# Options for setup script
55
ARG INSTALL_ZSH="true"
@@ -15,12 +15,11 @@ RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
1515
&& apt-get autoremove -y && apt-get clean -y && rm -rf /var/lib/apt/lists/* /tmp/library-scripts
1616

1717
# Install Bazel
18-
ARG BAZEL_VERSION=3.4.1
19-
ARG BAZEL_DOWNLOAD_SHA=dev-mode
20-
RUN curl -fSsL -o /tmp/bazel-installer.sh https://github.com/bazelbuild/bazel/releases/download/${BAZEL_VERSION}/bazel-${BAZEL_VERSION}-installer-linux-x86_64.sh \
21-
&& ([ "${BAZEL_DOWNLOAD_SHA}" = "dev-mode" ] || echo "${BAZEL_DOWNLOAD_SHA} */tmp/bazel-installer.sh" | sha256sum --check - ) \
22-
&& /bin/bash /tmp/bazel-installer.sh --base=/usr/local/bazel \
23-
&& rm /tmp/bazel-installer.sh
18+
ARG BAZELISK_VERSION=v1.10.1
19+
ARG BAZELISK_DOWNLOAD_SHA=dev-mode
20+
RUN curl -fSsL -o /usr/local/bin/bazelisk https://github.com/bazelbuild/bazelisk/releases/download/${BAZELISK_VERSION}/bazelisk-linux-amd64 \
21+
&& ([ "${BAZELISK_DOWNLOAD_SHA}" = "dev-mode" ] || echo "${BAZELISK_DOWNLOAD_SHA} */usr/local/bin/bazelisk" | sha256sum --check - ) \
22+
&& chmod 0755 /usr/local/bin/bazelisk
2423

2524
# [Optional] Uncomment this section to install additional OS packages.
2625
# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \

containers/bazel/.devcontainer/devcontainer.json

+2-8
Original file line numberDiff line numberDiff line change
@@ -3,28 +3,22 @@
33
"build": {
44
"dockerfile": "Dockerfile",
55
"args": {
6-
"BAZEL_VERSION": "3.4.1",
7-
"BAZEL_DOWNLOAD_SHA": "9808adad931ac652e8ff5022a74507c532250c2091d21d6aebc7064573669cc5"
6+
"BAZELISK_VERSION": "v1.10.1",
7+
"BAZELISK_DOWNLOAD_SHA": "4cb534c52cdd47a6223d4596d530e7c9c785438ab3b0a49ff347e991c210b2cd"
88
}
99
},
10-
1110
// Set *default* container specific settings.json values on container create.
1211
"settings": {},
13-
1412
// Add the IDs of extensions you want installed when the container is created.
1513
"extensions": [
1614
"devondcarew.bazel-code"
1715
],
18-
1916
// Use 'forwardPorts' to make a list of ports inside the container available locally.
2017
// "forwardPorts": [],
21-
2218
// Use 'postCreateCommand' to run commands after the container is created.
2319
// "postCreateCommand": "uname -a",
24-
2520
// Uncomment when using a ptrace-based debugger like C++, Go, and Rust
2621
// "runArgs": [ "--cap-add=SYS_PTRACE", "--security-opt", "seccomp=unconfined" ],
27-
2822
// Comment out connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
2923
"remoteUser": "vscode"
3024
}

containers/bazel/README.md

+17-17
Original file line numberDiff line numberDiff line change
@@ -4,33 +4,33 @@
44

55
*Develop and compile efficiently on any language with the Bazel compilation tool.*
66

7-
| Metadata | Value |
8-
|----------|-------|
9-
| *Contributors* | William Phetsinorath <[email protected]> |
10-
| *Categories* | Community, Other |
11-
| *Definition type* | Dockerfile |
12-
| *Supported architecture(s)* | x86-64 |
13-
| *Works in Codespaces* | Yes |
14-
| *Container host OS support* | Linux, macOS, Windows |
15-
| *Container OS* | Debian |
16-
| *Languages, platforms* | Any |
7+
| Metadata | Value |
8+
| --------------------------- | ---------------------------------------------------- |
9+
| *Contributors* | William Phetsinorath <[email protected]> |
10+
| *Categories* | Community, Other |
11+
| *Definition type* | Dockerfile |
12+
| *Supported architecture(s)* | x86-64 |
13+
| *Works in Codespaces* | Yes |
14+
| *Container host OS support* | Linux, macOS, Windows |
15+
| *Container OS* | Debian |
16+
| *Languages, platforms* | Any |
1717

1818
## Using this definition
1919

20-
While this definition works unmodified, you can set the Bazel version by updating the `BAZEL_VERSION` argument in `devcontainer.json`.
20+
While this definition works unmodified, you can set the Bazelisk version by updating the `BAZELISK_VERSION` argument in `devcontainer.json`.
2121

2222
```json
2323
"args": {
24-
"BAZEL_VERSION": "3.4.1"
24+
"BAZELISK_VERSION": "v1.10.1"
2525
}
2626
```
2727

28-
Optionally, you can validate the SHA256 checksum for `bazel-installer.sh` by adding it to the `BAZEL_DOWNLOAD_SHA` argument:
28+
Optionally, you can validate the SHA256 checksum for `bazelisk` executable by adding it to the `BAZELISK_DOWNLOAD_SHA` argument:
2929

3030
```json
3131
"args": {
32-
"BAZEL_VERSION": "3.4.1",
33-
"BAZEL_DOWNLOAD_SHA": "9808adad931ac652e8ff5022a74507c532250c2091d21d6aebc7064573669cc5"
32+
"BAZELISK_VERSION": "v1.10.1",
33+
"BAZELISK_DOWNLOAD_SHA": "4cb534c52cdd47a6223d4596d530e7c9c785438ab3b0a49ff347e991c210b2cd"
3434
}
3535
```
3636

@@ -40,7 +40,7 @@ Optionally, you can validate the SHA256 checksum for `bazel-installer.sh` by add
4040

4141
2. Start VS Code and open your project folder or connect to a codespace.
4242

43-
3. Press <kbd>F1</kbd> select and **Add Development Container Configuration Files...** command for **Remote-Containers** or **Codespaces**.
43+
3. Press <kbd>F1</kbd> select and **Add Development Container Configuration Files...** command for **Remote-Containers** or **Codespaces**.
4444

4545
> **Note:** If needed, you can drag-and-drop the `.devcontainer` folder from this sub-folder in a locally cloned copy of this repository into the VS Code file explorer instead of using the command.
4646
@@ -56,7 +56,7 @@ This definition includes some test code that will help you verify it is working
5656
2. Clone this repository.
5757
3. Start VS Code, press <kbd>F1</kbd>, and select **Remote-Containers: Open Folder in Container...**
5858
4. Select this folder from the cloned repository.
59-
5. Press <kbd>ctrl</kbd>+<kbd>shift</kbd>+<kbd>\`</kbd> and type the following command to verify installation: `bazel run //test-project:hello-world`
59+
5. Press <kbd>ctrl</kbd>+<kbd>shift</kbd>+<kbd>\`</kbd> and type the following command to verify installation: `bazelisk run //test-project:hello-world`
6060
6. You should see "Hello remote world!" in the Debug Console after the program executes.
6161

6262
## License

0 commit comments

Comments
 (0)