Skip to content
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

Bootstrap vscode dev container #1303

Merged
merged 2 commits into from
Oct 17, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
FROM mcr.microsoft.com/devcontainers/base:jammy

# Install dependencies, including clang via through LLVM APT repository. Note that this
# will also install lldb and clangd alongside dependencies.
ARG LLVM_VERSION=15
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
&& apt-get -y install software-properties-common python3 python3-distutils \
&& curl -fSsL -o /tmp/llvm.sh https://apt.llvm.org/llvm.sh && chmod +x /tmp/llvm.sh && bash /tmp/llvm.sh ${LLVM_VERSION} \
&& apt-get -y install --no-install-recommends libunwind-${LLVM_VERSION} libc++abi1-${LLVM_VERSION} libc++1-${LLVM_VERSION} libc++-${LLVM_VERSION}-dev libclang-rt-${LLVM_VERSION}-dev -o DPkg::options::="--force-overwrite"
ENV PATH /usr/lib/llvm-${LLVM_VERSION}/bin:$PATH

# Install NodeJS
ARG NODEJS_VERSION=v18.18.0
ndisidore marked this conversation as resolved.
Show resolved Hide resolved
ARG NODE_PACKAGE=node-${NODEJS_VERSION}-linux-x64
ARG NODE_HOME=/opt/$NODE_PACKAGE
RUN curl https://nodejs.org/dist/${NODEJS_VERSION}/${NODE_PACKAGE}.tar.xz | tar xvfJ - -C /opt
ENV NODE_PATH ${NODE_HOME}/lib/node_modules
ENV PATH ${NODE_HOME}/bin:$PATH

# Install Bazel (via Bazelisk)
ARG BAZELISK_VERSION=v1.18.0
ARG BAZELISK_DOWNLOAD_SHA="ce52caa51ef9e509fb6b7e5ad892e5cf10feb0794b0aed4d2f36adb00a1a2779"
RUN curl -fSsL -o /usr/local/bin/bazel https://github.com/bazelbuild/bazelisk/releases/download/${BAZELISK_VERSION}/bazelisk-linux-amd64 \
&& echo "${BAZELISK_DOWNLOAD_SHA} /usr/local/bin/bazel" | sha256sum --check \
&& chmod 0755 /usr/local/bin/bazel

# Install Bazel Buildifer
ARG BUILDIFER_VERSION=v6.3.3
ARG BUILDIFER_DOWNLOAD_SHA="42f798ec532c58e34401985043e660cb19d5ae994e108d19298c7d229547ffca"
RUN curl -fSsL -o /usr/local/bin/buildifier https://github.com/bazelbuild/buildtools/releases/download/${BUILDIFER_VERSION}/buildifier-linux-amd64 \
&& echo "${BUILDIFER_DOWNLOAD_SHA} /usr/local/bin/buildifier" | sha256sum --check \
&& chmod 0755 /usr/local/bin/buildifier

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change

# Install watchexec https://watchexec.github.io/downloads/watchexec/
ARG WATCHEXEC_VERSION=1.23.0
ARG WATCHEXEC_ARCH=x86_64
ADD https://github.com/watchexec/watchexec/releases/download/v${WATCHEXEC_VERSION}/watchexec-${WATCHEXEC_VERSION}-${WATCHEXEC_ARCH}-unknown-linux-gnu.deb /tmp/
ADD https://github.com/watchexec/watchexec/releases/download/v${WATCHEXEC_VERSION}/watchexec-${WATCHEXEC_VERSION}-${WATCHEXEC_ARCH}-unknown-linux-gnu.deb.sha256 /tmp/
RUN echo "`cat /tmp/watchexec-${WATCHEXEC_VERSION}-${WATCHEXEC_ARCH}-unknown-linux-gnu.deb.sha256` /tmp/watchexec-${WATCHEXEC_VERSION}-${WATCHEXEC_ARCH}-unknown-linux-gnu.deb" | sha256sum --check \
&& dpkg -i /tmp/watchexec-${WATCHEXEC_VERSION}-${WATCHEXEC_ARCH}-unknown-linux-gnu.deb
29 changes: 29 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"name": "C++: Workerd",
"build": {
"dockerfile": "Dockerfile"
},
"postStartCommand": "npm i",
"customizations": {
// Configure properties specific to VS Code.
"vscode": {
// Add the IDs of extensions you want installed when the container is created.
"extensions": [
"BazelBuild.vscode-bazel",
"eamodio.gitlens",
"streetsidesoftware.code-spell-checker",
"llvm-vs-code-extensions.vscode-clangd",
"ms-vscode.cpptools",
"abronan.capnproto-syntax",
"DavidAnson.vscode-markdownlint"
],
"settings": {
// The Microsoft C/C++ extension has IntelliSense support that is not compatible with the clangd extension.
"C_Cpp.intelliSenseEngine": "disabled",
"C_Cpp.default.cppStandard": "c++20"
}
}
}
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
// "remoteUser": "root"
}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ node_modules
/npm/*/bin
/npm/workerd/install.js
/npm/workerd/lib/
package-lock.json

# The external link for compile_flags.txt: Differs on Windows vs macOS/Linux, so we can't check it in. The pattern needs to not have a trailing / because it's a symlink on macOS/Linux.
/external
Expand Down
1 change: 1 addition & 0 deletions compile_flags.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
-isystemexternal/v8
-isystemexternal/v8/include
-isystemexternal/zlib
-isystemexternal/sqlite3
-D_FORTIFY_SOURCE=1
-DBAZEL_CURRENT_REPOSITORY=\"\"
-DCAPNP_VERSION=11000
Expand Down
Binary file added docs/assets/vscode-dev-container-modal.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/assets/vscode-dev-container-progress.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions docs/vscode.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,16 @@

Visual Studio Code is a commonly used editor by workerd developers (other editors are great too!). These notes present some getting started tips. If you have tricks and tips that would improve the developer experience, please let us know!

## Using the [dev container](https://containers.dev/)

workerd includes a [devcontainer](https://containers.dev/) setup that automates a majority of the developer environment setup by shifting the development to a container based setup. To make use of this, install the [devcontainer extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers). You can then either (a) use the **Dev Containers: Open Folder In Container** command and navigate to the checked out location or (b) open the project normally, in which case vscode should detect the presence of the devcontainer. Clicking **Reopen in Container** on the modal below will relaunch your workspaces in a container.

![dev container modal](./assets/vscode-dev-container-modal.png)

_Note_: It may take some time to initially bootstrap the dev container. To monitor its progress, click **show log** modal on the new window. Subsequent launches will be cached.

![dev container bootstrap log](./assets/vscode-dev-container-progress.png)

## Recommended extensions for developing workerd

The recommended extensions to install are:
Expand Down
Loading