Merge commit 'be3e8236086165e5e45a5a10783823874b3f3ebd' as 'lib/vscode'
This commit is contained in:
100
lib/vscode/.devcontainer/README.md
Normal file
100
lib/vscode/.devcontainer/README.md
Normal file
@ -0,0 +1,100 @@
|
||||
# Code - OSS Development Container
|
||||
|
||||
This repository includes configuration for a development container for working with Code - OSS in an isolated local container or using [GitHub Codespaces](https://github.com/features/codespaces).
|
||||
|
||||
> **Tip:** The default VNC password is `vscode`. The VNC server runs on port `5901` with a web client at `6080`. For better performance, we recommend using a [VNC Viewer](https://www.realvnc.com/en/connect/download/viewer/). Applications like the macOS Screen Sharing app will not perform as well.
|
||||
|
||||
## Quick start - local
|
||||
|
||||
1. Install Docker Desktop or Docker for Linux on your local machine. (See [docs](https://aka.ms/vscode-remote/containers/getting-started) for additional details.)
|
||||
|
||||
2. **Important**: Docker needs at least **4 Cores and 6 GB of RAM (8 GB recommended)** to run full build. If you on macOS, or using the old Hyper-V engine for Windows, update these values for Docker Desktop by right-clicking on the Docker status bar item, going to **Preferences/Settings > Resources > Advanced**.
|
||||
|
||||
> **Note:** The [Resource Monitor](https://marketplace.visualstudio.com/items?itemName=mutantdino.resourcemonitor) extension is included in the container so you can keep an eye on CPU/Memory in the status bar.
|
||||
|
||||
3. Install [Visual Studio Code Stable](https://code.visualstudio.com/) or [Insiders](https://code.visualstudio.com/insiders/) and the [Remote - Containers](https://aka.ms/vscode-remote/download/containers) extension.
|
||||
|
||||

|
||||
|
||||
> Note that the Remote - Containers extension requires the Visual Studio Code distribution of Code - OSS. See the [FAQ](https://aka.ms/vscode-remote/faq/license) for details.
|
||||
|
||||
4. Press <kbd>Ctrl/Cmd</kbd> + <kbd>Shift</kbd> + <kbd>P</kbd> and select **Remote-Containers: Clone Repository in Container Volume...**.
|
||||
|
||||
> **Tip:** While you can use your local source tree instead, operations like `yarn install` can be slow on macOS or using the Hyper-V engine on Windows. We recommend the "clone repository in container" approach instead since it uses "named volume" rather than the local filesystem.
|
||||
|
||||
5. Type `https://github.com/microsoft/vscode` (or a branch or PR URL) in the input box and press <kbd>Enter</kbd>.
|
||||
|
||||
6. After the container is running, open a web browser and go to [http://localhost:6080](http://localhost:6080) or use a [VNC Viewer](https://www.realvnc.com/en/connect/download/viewer/) to connect to `localhost:5901` and enter `vscode` as the password.
|
||||
|
||||
Anything you start in VS Code or the integrated terminal will appear here.
|
||||
|
||||
Next: **[Try it out!](#try-it)**
|
||||
|
||||
## Quick start - GitHub Codespaces
|
||||
|
||||
> **IMPORTANT:** The current free user beta for GitHub Codespaces uses a "Basic" sized codespace which does not have enough RAM to run a full build of VS Code and will be considerably slower during codespace start and running VS Code. You'll soon be able to use a "Standard" sized codespace (4-core, 8GB) that will be better suited for this purpose (along with even larger sizes should you need it).
|
||||
|
||||
1. From the [microsoft/vscode GitHub repository](https://github.com/microsoft/vscode), click on the **Code** dropdown, select **Open with Codespaces**, and the **New codespace**
|
||||
|
||||
> Note that you will not see these options if you are not in the beta yet.
|
||||
|
||||
2. After the codespace is up and running in your browser, press <kbd>Ctrl/Cmd</kbd> + <kbd>Shift</kbd> + <kbd>P</kbd> and select **View: Show Remote Explorer**.
|
||||
|
||||
3. You should see port `6080` under **Forwarded Ports**. Select the line and click on the globe icon to open it in a browser tab.
|
||||
|
||||
> If you do not see port `6080`, press <kbd>Ctrl/Cmd</kbd> + <kbd>Shift</kbd> + <kbd>P</kbd>, select **Forward a Port** and enter port `6080`.
|
||||
|
||||
4. In the new tab, you should see noVNC. Click **Connect** and enter `vscode` as the password.
|
||||
|
||||
Anything you start in VS Code or the integrated terminal will appear here.
|
||||
|
||||
Next: **[Try it out!](#try-it)**
|
||||
|
||||
### Using VS Code with GitHub Codespaces
|
||||
|
||||
You will likely see better performance when accessing the codespace you created from VS Code since you can use a[VNC Viewer](https://www.realvnc.com/en/connect/download/viewer/). Here's how to do it.
|
||||
|
||||
1. [Create a codespace](#quick-start---github-codespaces) if you have not already.
|
||||
|
||||
2. Set up [VS Code for use with GitHub Codespaces](https://docs.github.com/github/developing-online-with-codespaces/using-codespaces-in-visual-studio-code)
|
||||
|
||||
3. After the VS Code is up and running, press <kbd>Ctrl/Cmd</kbd> + <kbd>Shift</kbd> + <kbd>P</kbd>, choose **Codespaces: Connect to Codespace**, and select the codespace you created.
|
||||
|
||||
4. After you've connected to the codespace, use a [VNC Viewer](https://www.realvnc.com/en/connect/download/viewer/) to connect to `localhost:5901` and enter `vscode` as the password.
|
||||
|
||||
5. Anything you start in VS Code or the integrated terminal will appear here.
|
||||
|
||||
Next: **[Try it out!](#try-it)**
|
||||
|
||||
## Try it!
|
||||
|
||||
This container uses the [Fluxbox](http://fluxbox.org/) window manager to keep things lean. **Right-click on the desktop** to see menu options. It works with GNOME and GTK applications, so other tools can be installed if needed.
|
||||
|
||||
Note you can also set the resolution from the command line by typing `set-resolution`.
|
||||
|
||||
To start working with Code - OSS, follow these steps:
|
||||
|
||||
1. In your local VS Code, open a terminal (<kbd>Ctrl/Cmd</kbd> + <kbd>Shift</kbd> + <kbd>\`</kbd>) and type the following commands:
|
||||
|
||||
```bash
|
||||
yarn install
|
||||
bash scripts/code.sh
|
||||
```
|
||||
|
||||
Note that a previous run of `yarn install` will already be cached, so this step should simply pick up any recent differences.
|
||||
|
||||
2. After the build is complete, open a web browser or a [VNC Viewer](https://www.realvnc.com/en/connect/download/viewer/) to the desktop environnement as described in the quick start and enter `vscode` as the password.
|
||||
|
||||
3. You should now see Code - OSS!
|
||||
|
||||
Next, let's try debugging.
|
||||
|
||||
1. Shut down Code - OSS by clicking the box in the upper right corner of the Code - OSS window through your browser or VNC viewer.
|
||||
|
||||
2. Go to your local VS Code client, and use Run / Debug view to launch the **VS Code** configuration. (Typically the default, so you can likely just press <kbd>F5</kbd>).
|
||||
|
||||
> **Note:** If launching times out, you can increase the value of `timeout` in the "VS Code", "Attach Main Process", "Attach Extension Host", and "Attach to Shared Process" configurations in [launch.json](../.vscode/launch.json). However, running `scripts/code.sh` first will set up Electron which will usually solve timeout issues.
|
||||
|
||||
3. After a bit, Code - OSS will appear with the debugger attached!
|
||||
|
||||
Enjoy!
|
1
lib/vscode/.devcontainer/cache/.gitignore
vendored
Normal file
1
lib/vscode/.devcontainer/cache/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
*.manifest
|
15
lib/vscode/.devcontainer/cache/before-cache.sh
vendored
Executable file
15
lib/vscode/.devcontainer/cache/before-cache.sh
vendored
Executable file
@ -0,0 +1,15 @@
|
||||
#!/bin/bash
|
||||
|
||||
# This file establishes a basline for the reposuitory before any steps in the "prepare.sh"
|
||||
# are run. Its just a find command that filters out a few things we don't need to watch.
|
||||
|
||||
set -e
|
||||
|
||||
SCRIPT_PATH="$(cd "$(dirname $0)" && pwd)"
|
||||
SOURCE_FOLDER="${1:-"."}"
|
||||
|
||||
cd "${SOURCE_FOLDER}"
|
||||
echo "[$(date)] Generating ""before"" manifest..."
|
||||
find -L . -not -path "*/.git/*" -and -not -path "${SCRIPT_PATH}/*.manifest" -type f > "${SCRIPT_PATH}/before.manifest"
|
||||
echo "[$(date)] Done!"
|
||||
|
28
lib/vscode/.devcontainer/cache/build-cache-image.sh
vendored
Executable file
28
lib/vscode/.devcontainer/cache/build-cache-image.sh
vendored
Executable file
@ -0,0 +1,28 @@
|
||||
#!/bin/bash
|
||||
|
||||
# This file simply wraps the dockeer build command used to build the image with the
|
||||
# cached result of the commands from "prepare.sh" and pushes it to the specified
|
||||
# container image registry.
|
||||
|
||||
set -e
|
||||
|
||||
SCRIPT_PATH="$(cd "$(dirname $0)" && pwd)"
|
||||
CONTAINER_IMAGE_REPOSITORY="$1"
|
||||
BRANCH="${2:-"master"}"
|
||||
|
||||
if [ "${CONTAINER_IMAGE_REPOSITORY}" = "" ]; then
|
||||
echo "Container repository not specified!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
TAG="branch-${BRANCH//\//-}"
|
||||
echo "[$(date)] ${BRANCH} => ${TAG}"
|
||||
cd "${SCRIPT_PATH}/../.."
|
||||
|
||||
echo "[$(date)] Starting image build..."
|
||||
docker build -t ${CONTAINER_IMAGE_REPOSITORY}:"${TAG}" -f "${SCRIPT_PATH}/cache.Dockerfile" .
|
||||
echo "[$(date)] Image build complete."
|
||||
|
||||
echo "[$(date)] Pushing image..."
|
||||
docker push ${CONTAINER_IMAGE_REPOSITORY}:"${TAG}"
|
||||
echo "[$(date)] Done!"
|
21
lib/vscode/.devcontainer/cache/cache-diff.sh
vendored
Executable file
21
lib/vscode/.devcontainer/cache/cache-diff.sh
vendored
Executable file
@ -0,0 +1,21 @@
|
||||
#!/bin/bash
|
||||
|
||||
# This file is used to archive off a copy of any differences in the source tree into another location
|
||||
# in the image. Once the codespace is up, this will be restored into its proper location (which is
|
||||
# quick and happens parallel to other startup activities)
|
||||
|
||||
set -e
|
||||
|
||||
SCRIPT_PATH="$(cd "$(dirname $0)" && pwd)"
|
||||
SOURCE_FOLDER="${1:-"."}"
|
||||
CACHE_FOLDER="${2:-"/usr/local/etc/devcontainer-cache"}"
|
||||
|
||||
echo "[$(date)] Starting cache operation..."
|
||||
cd "${SOURCE_FOLDER}"
|
||||
echo "[$(date)] Determining diffs..."
|
||||
find -L . -not -path "*/.git/*" -and -not -path "${SCRIPT_PATH}/*.manifest" -type f > "${SCRIPT_PATH}/after.manifest"
|
||||
grep -Fxvf "${SCRIPT_PATH}/before.manifest" "${SCRIPT_PATH}/after.manifest" > "${SCRIPT_PATH}/cache.manifest"
|
||||
echo "[$(date)] Archiving diffs..."
|
||||
mkdir -p "${CACHE_FOLDER}"
|
||||
tar -cf "${CACHE_FOLDER}/cache.tar" --totals --files-from "${SCRIPT_PATH}/cache.manifest"
|
||||
echo "[$(date)] Done! $(du -h "${CACHE_FOLDER}/cache.tar")"
|
14
lib/vscode/.devcontainer/cache/cache.Dockerfile
vendored
Normal file
14
lib/vscode/.devcontainer/cache/cache.Dockerfile
vendored
Normal file
@ -0,0 +1,14 @@
|
||||
# This dockerfile is used to build up from a base image to create an image with cached results of running "prepare.sh".
|
||||
# Other image contents: https://github.com/microsoft/vscode-dev-containers/blob/master/repository-containers/images/github.com/microsoft/vscode/.devcontainer/base.Dockerfile
|
||||
FROM mcr.microsoft.com/vscode/devcontainers/repos/microsoft/vscode:dev
|
||||
|
||||
ARG USERNAME=node
|
||||
COPY --chown=${USERNAME}:${USERNAME} . /repo-source-tmp/
|
||||
RUN mkdir /usr/local/etc/devcontainer-cache \
|
||||
&& chown ${USERNAME} /usr/local/etc/devcontainer-cache /repo-source-tmp \
|
||||
&& su ${USERNAME} -c "\
|
||||
cd /repo-source-tmp \
|
||||
&& .devcontainer/cache/before-cache.sh \
|
||||
&& .devcontainer/prepare.sh \
|
||||
&& .devcontainer/cache/cache-diff.sh" \
|
||||
&& rm -rf /repo-source-tmp
|
23
lib/vscode/.devcontainer/cache/restore-diff.sh
vendored
Executable file
23
lib/vscode/.devcontainer/cache/restore-diff.sh
vendored
Executable file
@ -0,0 +1,23 @@
|
||||
#!/bin/bash
|
||||
|
||||
# This file restores the results of the "prepare.sh" into their proper locations
|
||||
# once the container has been created. It runs as a postCreateCommand which
|
||||
# in GitHub Codespaces occurs parallel to other startup activities and does not
|
||||
# really add to the overal startup time given how quick the operation ends up being.
|
||||
|
||||
set -e
|
||||
|
||||
SOURCE_FOLDER="$(cd "${1:-"."}" && pwd)"
|
||||
CACHE_FOLDER="${2:-"/usr/local/etc/devcontainer-cache"}"
|
||||
|
||||
if [ ! -d "${CACHE_FOLDER}" ]; then
|
||||
echo "No cache folder found."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
echo "[$(date)] Expanding $(du -h "${CACHE_FOLDER}/cache.tar") file to ${SOURCE_FOLDER}..."
|
||||
cd "${SOURCE_FOLDER}"
|
||||
tar -xf "${CACHE_FOLDER}/cache.tar"
|
||||
rm -f "${CACHE_FOLDER}/cache.tar"
|
||||
echo "[$(date)] Done!"
|
||||
|
30
lib/vscode/.devcontainer/devcontainer.json
Normal file
30
lib/vscode/.devcontainer/devcontainer.json
Normal file
@ -0,0 +1,30 @@
|
||||
{
|
||||
"name": "Code - OSS",
|
||||
|
||||
// Image contents: https://github.com/microsoft/vscode-dev-containers/blob/master/repository-containers/images/github.com/microsoft/vscode/.devcontainer/base.Dockerfile
|
||||
"image": "mcr.microsoft.com/vscode/devcontainers/repos/microsoft/vscode:branch-master",
|
||||
|
||||
"workspaceMount": "source=${localWorkspaceFolder},target=/home/node/workspace/vscode,type=bind,consistency=cached",
|
||||
"workspaceFolder": "/home/node/workspace/vscode",
|
||||
"overrideCommand": false,
|
||||
"runArgs": [ "--init", "--security-opt", "seccomp=unconfined"],
|
||||
|
||||
"settings": {
|
||||
"terminal.integrated.shell.linux": "/bin/bash",
|
||||
"resmon.show.battery": false,
|
||||
"resmon.show.cpufreq": false
|
||||
},
|
||||
|
||||
// noVNC, VNC, debug ports
|
||||
"forwardPorts": [6080, 5901, 9222],
|
||||
|
||||
"extensions": [
|
||||
"dbaeumer.vscode-eslint",
|
||||
"mutantdino.resourcemonitor"
|
||||
],
|
||||
|
||||
// Optionally loads a cached yarn install for the repo
|
||||
"postCreateCommand": ".devcontainer/cache/restore-diff.sh",
|
||||
|
||||
"remoteUser": "node"
|
||||
}
|
10
lib/vscode/.devcontainer/prepare.sh
Executable file
10
lib/vscode/.devcontainer/prepare.sh
Executable file
@ -0,0 +1,10 @@
|
||||
#!/bin/bash
|
||||
|
||||
# This file contains the steps that should be run when creating the intermediary image that contains
|
||||
# contents for that should be in the image by default. It will be used to build up from the base image
|
||||
# to create an image that speeds up first time use of the dev container by "caching" the results
|
||||
# of these commands. Developers can still run these commands without an issue once the container is
|
||||
# up, but only differences will be processed which also speeds up the first time these operations occur.
|
||||
|
||||
yarn install
|
||||
yarn electron
|
Reference in New Issue
Block a user