-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
devex: initial commit of devcontainer setup (#11207)
Risk Level: Low (not affecting any output) Testing: local Docs Changes: `.devcontainer/README.md` Release Notes: N/A Signed-off-by: Lizan Zhou <lizan@tetrate.io>
- Loading branch information
Showing
10 changed files
with
159 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
devcontainer.env |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
FROM gcr.io/envoy-ci/envoy-build:04f06115b6ee7cfea74930353fb47a41149cbec3 | ||
|
||
ARG USERNAME=vscode | ||
ARG USER_UID=501 | ||
ARG USER_GID=$USER_UID | ||
|
||
ENV BUILD_DIR=/build | ||
ENV ENVOY_STDLIB=libstdc++ | ||
|
||
ENV DEBIAN_FRONTEND=noninteractive | ||
RUN apt-get -y update \ | ||
&& apt-get -y install --no-install-recommends libpython2.7 net-tools psmisc vim 2>&1 \ | ||
# | ||
# Create a non-root user to use if preferred - see https://aka.ms/vscode-remote/containers/non-root-user. | ||
&& groupadd --gid $USER_GID $USERNAME \ | ||
&& useradd -s /bin/bash --uid $USER_UID --gid $USER_GID -m $USERNAME \ | ||
# [Optional] Add sudo support for non-root user | ||
&& echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME \ | ||
&& chmod 0440 /etc/sudoers.d/$USERNAME | ||
|
||
ENV DEBIAN_FRONTEND= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# Envoy Dev Container (experimental) | ||
|
||
This directory contains some experimental tools for Envoy Development in [VSCode Remote - Containers](https://code.visualstudio.com/docs/remote/containers). | ||
|
||
## How to use | ||
|
||
Open with VSCode with the Container extension installed. Follow the [official guide](https://code.visualstudio.com/docs/remote/containers) to open this | ||
repository directly from GitHub or from checked-out source tree. | ||
|
||
After opening, run the `Refresh Compilation Database` task to generate compilation database to navigate in source code. | ||
This will run partial build of Envoy and may take a while depends on the machine performance. | ||
This task is needed to run everytime after: | ||
- Changing a BUILD file that add/remove files from a target, changes dependencies | ||
- Changing API proto files | ||
|
||
## Advanced Usages | ||
|
||
### Using Remote Build Execution | ||
|
||
Write the following content to `devcontainer.env` and rebuild the container. The key will be persisted in the container's `~/.bazelrc`. | ||
|
||
``` | ||
GCP_SERVICE_ACCOUNT_KEY=<base64 encoded service account key> | ||
BAZEL_REMOTE_INSTANCE=<RBE Instance> | ||
BAZEL_REMOTE_CACHE=grpcs://remotebuildexecution.googleapis.com | ||
BAZEL_BUILD_EXTRA_OPTIONS=--config=remote-ci --config=remote --jobs=<Number of jobs> | ||
``` | ||
|
||
By default the `--config=remote` implies [`--remote_download_toplevel`](https://docs.bazel.build/versions/master/command-line-reference.html#flag--remote_download_toplevel), | ||
change this to `minimal` or `all` depending on where you're running the container by adding them to `BAZEL_BUILD_EXTRA_OPTIONS`. | ||
|
||
### Disk performance | ||
|
||
Docker for Mac/Windows is known to have disk performance issue, this makes formatting all files in the container very slow. | ||
[Update the mount consistency to 'delegated'](https://code.visualstudio.com/docs/remote/containers-advanced#_update-the-mount-consistency-to-delegated-for-macos) is recommended. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
{ | ||
"name": "Envoy Dev", | ||
"dockerFile": "Dockerfile", | ||
"runArgs": [ | ||
"--user=vscode", | ||
"--cap-add=SYS_PTRACE", | ||
"--security-opt=seccomp=unconfined", | ||
"--volume=${env:HOME}:${env:HOME}", | ||
"--volume=envoy-build:/build", | ||
// Uncomment next line if you have devcontainer.env | ||
// "--env-file=.devcontainer/devcontainer.env" | ||
], | ||
"settings": { | ||
"terminal.integrated.shell.linux": "/bin/bash", | ||
"bazel.buildifierFixOnFormat": true, | ||
"clangd.path": "/opt/llvm/bin/clangd", | ||
"python.pythonPath": "/usr/bin/python3", | ||
"files.exclude": { | ||
"**/.clangd/**": true, | ||
"**/bazel-*/**": true | ||
} | ||
}, | ||
"remoteUser": "vscode", | ||
"containerUser": "vscode", | ||
"postCreateCommand": ".devcontainer/setup.sh", | ||
"extensions": [ | ||
"github.vscode-pull-request-github", | ||
"zxh404.vscode-proto3", | ||
"bazelbuild.vscode-bazel", | ||
"llvm-vs-code-extensions.vscode-clangd", | ||
"webfreak.debug" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#!/usr/bin/env bash | ||
|
||
. ci/setup_cache.sh | ||
trap - EXIT # Don't remove the key file written into a temporary file | ||
|
||
BAZELRC_FILE=~/.bazelrc bazel/setup_clang.sh /opt/llvm | ||
|
||
# Use generated toolchain config because we know the base container is the one we're using in RBE. | ||
# Not using libc++ here because clangd will raise some tidy issue in libc++ header as of version 9. | ||
echo "build --config=rbe-toolchain-clang" >> ~/.bazelrc | ||
echo "build --symlink_prefix=/" >> ~/.bazelrc | ||
echo "build ${BAZEL_BUILD_EXTRA_OPTIONS}" | tee -a ~/.bazelrc | ||
echo "startup --output_base=/build/tmp" | ||
|
||
[[ ! -z "${BUILD_DIR}" ]] && sudo chown -R "$(id -u):$(id -g)" ${BUILD_DIR} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
settings.json | ||
launch.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
{ | ||
// See https://go.microsoft.com/fwlink/?LinkId=733558 | ||
// for the documentation about the tasks.json format | ||
"version": "2.0.0", | ||
"tasks": [ | ||
{ | ||
"label": "Build All Tests", | ||
"type": "shell", | ||
"command": "bazel build //test/...", | ||
"group": { | ||
"kind": "build", | ||
"isDefault": true | ||
} | ||
}, | ||
{ | ||
"label": "Run All Tests", | ||
"type": "shell", | ||
"command": "bazel test //test/...", | ||
"group": { | ||
"kind": "test", | ||
"isDefault": true | ||
} | ||
}, | ||
{ | ||
"label": "Refresh Compilation Database", | ||
"type": "shell", | ||
"command": "tools/vscode/refresh_compdb.sh", | ||
"problemMatcher": [] | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#!/usr/bin/env bash | ||
|
||
tools/proto_format/proto_format.sh fix | ||
|
||
# Setting platform suffix here so the compdb headers won't be overwritten by another bazel run | ||
BAZEL_BUILD_OPTIONS=--platform_suffix=-compdb tools/gen_compilation_database.py --run_bazel_build -k | ||
|
||
# Kill clangd to reload the compilation database | ||
killall -v /opt/llvm/bin/clangd |