Skip to content

Commit

Permalink
Add devcontainer config (#408)
Browse files Browse the repository at this point in the history
  • Loading branch information
purkhusid authored Jan 22, 2024
1 parent 2553afc commit 311e019
Show file tree
Hide file tree
Showing 16 changed files with 126 additions and 32,342 deletions.
3 changes: 3 additions & 0 deletions .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ common --experimental_collect_load_average_in_profiler
common --experimental_collect_system_network_usage
common --experimental_collect_worker_data_in_profiler

# Disable bzlmod lock file since it's not stable enough yet
common --lockfile_mode=off

# Load any settings specific to the current user.
# .bazelrc.user should appear in .gitignore so that settings are not shared with team members
# This needs to be last statement in this
Expand Down
2 changes: 1 addition & 1 deletion .bazelversion
Original file line number Diff line number Diff line change
@@ -1 +1 @@
7.0.0rc4
7.0.1
39 changes: 39 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# See here for image contents: https://github.com/microsoft/vscode-dev-containers/tree/v0.245.0/containers/ubuntu/.devcontainer/base.Dockerfile

# [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
ARG VARIANT
FROM mcr.microsoft.com/vscode/devcontainers/base:0-${VARIANT}
ARG TARGETARCH

#########################################################
### Create bin folder under $HOME for random binaries ###
#########################################################
USER vscode
RUN mkdir $HOME/bin
ENV PATH=$PATH:$HOME/bin

#########################################
### Bazel and Bazel releated binaries ###
#########################################
# Install bazelisk
RUN curl -o $HOME/bin/bazelisk-linux-$TARGETARCH -fsSL https://github.com/bazelbuild/bazelisk/releases/download/v1.19.0/bazelisk-linux-$TARGETARCH \
&& mv $HOME/bin/bazelisk-linux-$TARGETARCH $HOME/bin/bazelisk \
&& chmod +x $HOME/bin/bazelisk \
&& ln -s $HOME/bin/bazelisk $HOME/bin/bazel

# Install bazel-watcher
RUN curl -o $HOME/bin/ibazel_linux_$TARGETARCH -fsSL https://github.com/bazelbuild/bazel-watcher/releases/download/v0.24.0/ibazel_linux_$TARGETARCH \
&& mv $HOME/bin/ibazel_linux_$TARGETARCH $HOME/bin/ibazel \
&& chmod +x $HOME/bin/ibazel

# Install buildifier
RUN curl -o $HOME/bin/buildifier-linux-$TARGETARCH -fsSL https://github.com/bazelbuild/buildtools/releases/download/v6.4.0/buildifier-linux-$TARGETARCH \
&& mv $HOME/bin/buildifier-linux-$TARGETARCH $HOME/bin/buildifier \
&& chmod +x $HOME/bin/buildifier

# Install buildozer
RUN curl -o $HOME/bin/buildozer-linux-$TARGETARCH -fsSL https://github.com/bazelbuild/buildtools/releases/download/v6.4.0/buildozer-linux-$TARGETARCH \
&& mv $HOME/bin/buildozer-linux-$TARGETARCH $HOME/bin/buildozer \
&& chmod +x $HOME/bin/buildozer

COPY --chown=vscode ./devcontainer.bazelrc /home/vscode/.bazelrc
4 changes: 4 additions & 0 deletions .devcontainer/devcontainer.bazelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Set the Bazel build outputs to the ~/.cache directory so that the build outputs
# are persisted on the cache volume between devcontainers.
startup --output_user_root=~/.cache/bazel_output_user_root
startup --output_base=~/.cache/bazel_output_base
64 changes: 64 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at:
// https://github.com/microsoft/vscode-dev-containers/tree/v0.245.0/containers/ubuntu
{
"name": "rules_dotnet",
"containerEnv": {
// Override .Net cache locations: https://learn.microsoft.com/en-us/nuget/consume-packages/managing-the-global-packages-and-cache-folders
"NUGET_PACKAGES": "/home/vscode/.cache/nuget_packages",
"NUGET_HTTP_CACHE_PATH": "/home/vscode/.cache/nuget_http_cache"
},
"mounts": [
// We mount the caches as volumes so that they persist between containers
"source=rules-dotnet-caches,target=/home/vscode/.cache,type=volume"
],
// We need to chown the .cache folder since it's created by the root user during the container creation
"postCreateCommand": "sudo chown vscode /home/vscode/.cache",
"customizations": {
// Configure properties specific to VS Code.
"vscode": {
// Set *default* container specific settings.json values on container create.
"settings": {
// Set the default terminal to use Bash because it can get wonky
// if the user has e.g. zsh or fish configured as their default shell
// and it's not installed in the container.
"terminal.integrated.profiles.linux": {
"bash": {
"path": "bash",
"args": []
}
},
"terminal.integrated.defaultProfile.linux": "bash"
},
// Add the IDs of extensions you want installed when the container is created.
"extensions": [
"BazelBuild.vscode-bazel",
"ms-dotnettools.csharp",
"Ionide.Ionide-fsharp",
"zxh404.vscode-proto3",
"timonwong.shellcheck",
"mutantdino.resourcemonitor"
]
}
},
"build": {
"dockerfile": "Dockerfile",
// Update 'VARIANT' to pick an Ubuntu version: jammy / ubuntu-22.04, focal / ubuntu-20.04, bionic /ubuntu-18.04
// Use ubuntu-22.04 or ubuntu-18.04 on local arm64/Apple Silicon.
"args": {
"VARIANT": "ubuntu-22.04"
}
},
// Comment out to connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
"remoteUser": "vscode",
"features": {
"ghcr.io/devcontainers/features/dotnet:2.0.2": {
"version": "8.0.100"
},
"ghcr.io/devcontainers/features/git:1.1.6": {
"version": "2.43.0"
},
"ghcr.io/devcontainers/features/github-cli:1.0.11": {
"version": "2.42.1"
}
}
}
Loading

0 comments on commit 311e019

Please sign in to comment.