-
Notifications
You must be signed in to change notification settings - Fork 5.3k
devex: initial commit of devcontainer setup #11207
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
3335233
c0c979a
e16797e
5e01363
9199ba1
45f0d1c
4633a9e
2cffcc9
1ae78b0
da13bee
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| devcontainer.env |
| 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 | ||
htuch marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| 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= | ||
| 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 | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you be a bit more precise in wording here. I think it's the
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's in L3? |
||
| 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> | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is it worth diving into download minimal vs. all here? I think that can make a huge difference if you are sitting behind a cable modem connection vs. same region GCP?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. added. |
||
| ``` | ||
|
|
||
| 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. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think the mount consistency option is a noop for linux, so should this just be enabled by default?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This goes to user's
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is a |
||
| 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" | ||
| ] | ||
| } |
| 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} |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| settings.json | ||
| launch.json |
| 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": [] | ||
| } | ||
| ] | ||
| } |
| 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 | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As discussion on Slack, probably worth some warnings on what needs to be done when doing API work in this environment.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| 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 | ||
Uh oh!
There was an error while loading. Please reload this page.