Skip to content

Commit 311e019

Browse files
authored
Add devcontainer config (#408)
1 parent 2553afc commit 311e019

16 files changed

+126
-32342
lines changed

.bazelrc

+3
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ common --experimental_collect_load_average_in_profiler
1111
common --experimental_collect_system_network_usage
1212
common --experimental_collect_worker_data_in_profiler
1313

14+
# Disable bzlmod lock file since it's not stable enough yet
15+
common --lockfile_mode=off
16+
1417
# Load any settings specific to the current user.
1518
# .bazelrc.user should appear in .gitignore so that settings are not shared with team members
1619
# This needs to be last statement in this

.bazelversion

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
7.0.0rc4
1+
7.0.1

.devcontainer/Dockerfile

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# See here for image contents: https://github.com/microsoft/vscode-dev-containers/tree/v0.245.0/containers/ubuntu/.devcontainer/base.Dockerfile
2+
3+
# [Choice] Ubuntu version (use ubuntu-22.04 or ubuntu-18.04 on local arm64/Apple Silicon): ubuntu-22.04, ubuntu-20.04, ubuntu-18.04
4+
ARG VARIANT
5+
FROM mcr.microsoft.com/vscode/devcontainers/base:0-${VARIANT}
6+
ARG TARGETARCH
7+
8+
#########################################################
9+
### Create bin folder under $HOME for random binaries ###
10+
#########################################################
11+
USER vscode
12+
RUN mkdir $HOME/bin
13+
ENV PATH=$PATH:$HOME/bin
14+
15+
#########################################
16+
### Bazel and Bazel releated binaries ###
17+
#########################################
18+
# Install bazelisk
19+
RUN curl -o $HOME/bin/bazelisk-linux-$TARGETARCH -fsSL https://github.com/bazelbuild/bazelisk/releases/download/v1.19.0/bazelisk-linux-$TARGETARCH \
20+
&& mv $HOME/bin/bazelisk-linux-$TARGETARCH $HOME/bin/bazelisk \
21+
&& chmod +x $HOME/bin/bazelisk \
22+
&& ln -s $HOME/bin/bazelisk $HOME/bin/bazel
23+
24+
# Install bazel-watcher
25+
RUN curl -o $HOME/bin/ibazel_linux_$TARGETARCH -fsSL https://github.com/bazelbuild/bazel-watcher/releases/download/v0.24.0/ibazel_linux_$TARGETARCH \
26+
&& mv $HOME/bin/ibazel_linux_$TARGETARCH $HOME/bin/ibazel \
27+
&& chmod +x $HOME/bin/ibazel
28+
29+
# Install buildifier
30+
RUN curl -o $HOME/bin/buildifier-linux-$TARGETARCH -fsSL https://github.com/bazelbuild/buildtools/releases/download/v6.4.0/buildifier-linux-$TARGETARCH \
31+
&& mv $HOME/bin/buildifier-linux-$TARGETARCH $HOME/bin/buildifier \
32+
&& chmod +x $HOME/bin/buildifier
33+
34+
# Install buildozer
35+
RUN curl -o $HOME/bin/buildozer-linux-$TARGETARCH -fsSL https://github.com/bazelbuild/buildtools/releases/download/v6.4.0/buildozer-linux-$TARGETARCH \
36+
&& mv $HOME/bin/buildozer-linux-$TARGETARCH $HOME/bin/buildozer \
37+
&& chmod +x $HOME/bin/buildozer
38+
39+
COPY --chown=vscode ./devcontainer.bazelrc /home/vscode/.bazelrc

.devcontainer/devcontainer.bazelrc

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Set the Bazel build outputs to the ~/.cache directory so that the build outputs
2+
# are persisted on the cache volume between devcontainers.
3+
startup --output_user_root=~/.cache/bazel_output_user_root
4+
startup --output_base=~/.cache/bazel_output_base

.devcontainer/devcontainer.json

+64
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at:
2+
// https://github.com/microsoft/vscode-dev-containers/tree/v0.245.0/containers/ubuntu
3+
{
4+
"name": "rules_dotnet",
5+
"containerEnv": {
6+
// Override .Net cache locations: https://learn.microsoft.com/en-us/nuget/consume-packages/managing-the-global-packages-and-cache-folders
7+
"NUGET_PACKAGES": "/home/vscode/.cache/nuget_packages",
8+
"NUGET_HTTP_CACHE_PATH": "/home/vscode/.cache/nuget_http_cache"
9+
},
10+
"mounts": [
11+
// We mount the caches as volumes so that they persist between containers
12+
"source=rules-dotnet-caches,target=/home/vscode/.cache,type=volume"
13+
],
14+
// We need to chown the .cache folder since it's created by the root user during the container creation
15+
"postCreateCommand": "sudo chown vscode /home/vscode/.cache",
16+
"customizations": {
17+
// Configure properties specific to VS Code.
18+
"vscode": {
19+
// Set *default* container specific settings.json values on container create.
20+
"settings": {
21+
// Set the default terminal to use Bash because it can get wonky
22+
// if the user has e.g. zsh or fish configured as their default shell
23+
// and it's not installed in the container.
24+
"terminal.integrated.profiles.linux": {
25+
"bash": {
26+
"path": "bash",
27+
"args": []
28+
}
29+
},
30+
"terminal.integrated.defaultProfile.linux": "bash"
31+
},
32+
// Add the IDs of extensions you want installed when the container is created.
33+
"extensions": [
34+
"BazelBuild.vscode-bazel",
35+
"ms-dotnettools.csharp",
36+
"Ionide.Ionide-fsharp",
37+
"zxh404.vscode-proto3",
38+
"timonwong.shellcheck",
39+
"mutantdino.resourcemonitor"
40+
]
41+
}
42+
},
43+
"build": {
44+
"dockerfile": "Dockerfile",
45+
// Update 'VARIANT' to pick an Ubuntu version: jammy / ubuntu-22.04, focal / ubuntu-20.04, bionic /ubuntu-18.04
46+
// Use ubuntu-22.04 or ubuntu-18.04 on local arm64/Apple Silicon.
47+
"args": {
48+
"VARIANT": "ubuntu-22.04"
49+
}
50+
},
51+
// Comment out to connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
52+
"remoteUser": "vscode",
53+
"features": {
54+
"ghcr.io/devcontainers/features/dotnet:2.0.2": {
55+
"version": "8.0.100"
56+
},
57+
"ghcr.io/devcontainers/features/git:1.1.6": {
58+
"version": "2.43.0"
59+
},
60+
"ghcr.io/devcontainers/features/github-cli:1.0.11": {
61+
"version": "2.42.1"
62+
}
63+
}
64+
}

0 commit comments

Comments
 (0)