Skip to content

Commit f41efe5

Browse files
committed
Merge branch 'master' into pr/85074
2 parents d9d314e + 0fbda8e commit f41efe5

File tree

3,793 files changed

+320606
-166010
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

3,793 files changed

+320606
-166010
lines changed

.devcontainer/Dockerfile

Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
#-------------------------------------------------------------------------------------------------------------
2+
# Copyright (c) Microsoft Corporation. All rights reserved.
3+
# Licensed under the MIT License. See https://go.microsoft.com/fwlink/?linkid=2090316 for license information.
4+
#-------------------------------------------------------------------------------------------------------------
5+
6+
FROM mcr.microsoft.com/vscode/devcontainers/typescript-node:0-12
7+
8+
ARG TARGET_DISPLAY=":1"
9+
10+
# VNC options
11+
ARG MAX_VNC_RESOLUTION=1920x1080x16
12+
ARG TARGET_VNC_RESOLUTION=1920x1080
13+
ARG TARGET_VNC_DPI=72
14+
ARG TARGET_VNC_PORT=5901
15+
ARG VNC_PASSWORD="vscode"
16+
17+
# noVNC (VNC web client) options
18+
ARG INSTALL_NOVNC="true"
19+
ARG NOVNC_VERSION=1.1.0
20+
ARG TARGET_NOVNC_PORT=6080
21+
ARG WEBSOCKETIFY_VERSION=0.9.0
22+
23+
# Firefox is useful for testing things like browser launch events, but optional
24+
ARG INSTALL_FIREFOX="false"
25+
26+
# Expected non-root username from base image
27+
ARG USERNAME=node
28+
29+
# Core environment variables for X11, VNC, and fluxbox
30+
ENV DBUS_SESSION_BUS_ADDRESS="autolaunch:" \
31+
MAX_VNC_RESOLUTION="${MAX_VNC_RESOLUTION}" \
32+
VNC_RESOLUTION="${TARGET_VNC_RESOLUTION}" \
33+
VNC_DPI="${TARGET_VNC_DPI}" \
34+
VNC_PORT="${TARGET_VNC_PORT}" \
35+
NOVNC_PORT="${TARGET_NOVNC_PORT}" \
36+
DISPLAY="${TARGET_DISPLAY}" \
37+
LANG="en_US.UTF-8" \
38+
LANGUAGE="en_US.UTF-8" \
39+
VISUAL="nano" \
40+
EDITOR="nano"
41+
42+
# Configure apt and install packages
43+
RUN apt-get update \
44+
&& export DEBIAN_FRONTEND=noninteractive \
45+
#
46+
# Install the Cascadia Code fonts - https://github.com/microsoft/cascadia-code
47+
&& curl -sSL https://github.com/microsoft/cascadia-code/releases/download/v2004.30/CascadiaCode_2004.30.zip -o /tmp/cascadia-fonts.zip \
48+
&& unzip /tmp/cascadia-fonts.zip -d /tmp/cascadia-fonts \
49+
&& mkdir -p /usr/share/fonts/truetype/cascadia \
50+
&& mv /tmp/cascadia-fonts/ttf/* /usr/share/fonts/truetype/cascadia/ \
51+
&& rm -rf /tmp/cascadia-fonts.zip /tmp/cascadia-fonts \
52+
#
53+
# Install X11, fluxbox and VS Code dependencies
54+
&& apt-get -y install --no-install-recommends \
55+
xvfb \
56+
x11vnc \
57+
fluxbox \
58+
dbus-x11 \
59+
x11-utils \
60+
x11-xserver-utils \
61+
xdg-utils \
62+
fbautostart \
63+
xterm \
64+
eterm \
65+
gnome-terminal \
66+
gnome-keyring \
67+
seahorse \
68+
nautilus \
69+
libx11-dev \
70+
libxkbfile-dev \
71+
libsecret-1-dev \
72+
libnotify4 \
73+
libnss3 \
74+
libxss1 \
75+
libasound2 \
76+
xfonts-base \
77+
xfonts-terminus \
78+
fonts-noto \
79+
fonts-wqy-microhei \
80+
fonts-droid-fallback \
81+
vim-tiny \
82+
nano \
83+
#
84+
# [Optional] Install noVNC
85+
&& if [ "${INSTALL_NOVNC}" = "true" ]; then \
86+
mkdir -p /usr/local/novnc \
87+
&& curl -sSL https://github.com/novnc/noVNC/archive/v${NOVNC_VERSION}.zip -o /tmp/novnc-install.zip \
88+
&& unzip /tmp/novnc-install.zip -d /usr/local/novnc \
89+
&& cp /usr/local/novnc/noVNC-${NOVNC_VERSION}/vnc_lite.html /usr/local/novnc/noVNC-${NOVNC_VERSION}/index.html \
90+
&& rm /tmp/novnc-install.zip \
91+
&& curl -sSL https://github.com/novnc/websockify/archive/v${WEBSOCKETIFY_VERSION}.zip -o /tmp/websockify-install.zip \
92+
&& unzip /tmp/websockify-install.zip -d /usr/local/novnc \
93+
&& apt-get -y install --no-install-recommends python-numpy \
94+
&& ln -s /usr/local/novnc/websockify-${WEBSOCKETIFY_VERSION} /usr/local/novnc/noVNC-${NOVNC_VERSION}/utils/websockify \
95+
&& rm /tmp/websockify-install.zip; \
96+
fi \
97+
#
98+
# [Optional] Install Firefox
99+
&& if [ "${INSTALL_FIREFOX}" = "true" ]; then \
100+
apt-get -y install --no-install-recommends firefox-esr; \
101+
fi \
102+
#
103+
# Clean up
104+
&& apt-get autoremove -y \
105+
&& apt-get clean -y \
106+
&& rm -rf /var/lib/apt/lists/*
107+
108+
COPY bin/init-dev-container.sh /usr/local/share/
109+
COPY bin/set-resolution /usr/local/bin/
110+
COPY fluxbox/* /root/.fluxbox/
111+
COPY fluxbox/* /home/${USERNAME}/.fluxbox/
112+
113+
# Update privs, owners of config files
114+
RUN mkdir -p /var/run/dbus /root/.vnc /home/${USERNAME}/.vnc \
115+
&& touch /root/.Xmodmap /home/${USERNAME}/.Xmodmap \
116+
&& echo "${VNC_PASSWORD}" | tee /root/.vnc/passwd > /home/${USERNAME}/.vnc/passwd \
117+
&& chown -R ${USERNAME}:${USERNAME} /home/${USERNAME}/.Xmodmap /home/${USERNAME}/.fluxbox /home/${USERNAME}/.vnc \
118+
&& chmod +x /usr/local/share/init-dev-container.sh /usr/local/bin/set-resolution
119+
120+
ENTRYPOINT ["/usr/local/share/init-dev-container.sh"]
121+
CMD ["sleep", "infinity"]

.devcontainer/README.md

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
# Code - OSS Development Container
2+
3+
This repository includes configuration for a development container for working with Code - OSS in an isolated local container or using [Visual Studio Codespaces](https://aka.ms/vso).
4+
5+
> **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. [Chicken](https://sourceforge.net/projects/chicken/) is a good macOS alternative.
6+
7+
## Quick start - local
8+
9+
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.)
10+
11+
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**.
12+
13+
> **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.
14+
15+
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.
16+
17+
![Image of Remote - Containers extension](https://microsoft.github.io/vscode-remote-release/images/remote-containers-extn.png)
18+
19+
> 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.
20+
21+
4. Press <kbd>Ctrl/Cmd</kbd> + <kbd>Shift</kbd> + <kbd>P</kbd> and select **Remote - Containers: Open Repository in Container...**.
22+
23+
> **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 "open repository" approach instead since it uses "named volume" rather than the local filesystem.
24+
25+
5. Type `https://github.com/microsoft/vscode` (or a branch or PR URL) in the input box and press <kbd>Enter</kbd>.
26+
27+
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.
28+
29+
Anything you start in VS Code or the integrated terminal will appear here.
30+
31+
Next: **[Try it out!](#try-it)**
32+
33+
## Quick start - Codespaces
34+
35+
>Note that the Codespaces browser-based editor cannot currently access the desktop environment in this container (due to a [missing feature](https://github.com/MicrosoftDocs/vsonline/issues/117)). We recommend using Visual Studio Code from the desktop to connect instead in the near term.
36+
37+
1. Install [Visual Studio Code Stable](https://code.visualstudio.com/) or [Insiders](https://code.visualstudio.com/insiders/) and the [Visual Studio Codespaces](https://aka.ms/vscs-ext-vscode) extension.
38+
39+
![Image of VS Codespaces extension](https://microsoft.github.io/vscode-remote-release/images/codespaces-extn.png)
40+
41+
> Note that the Visual Studio Codespaces extension requires the Visual Studio Code distribution of Code - OSS.
42+
43+
2. Sign in by pressing <kbd>Ctrl/Cmd</kbd> + <kbd>Shift</kbd> + <kbd>P</kbd> and selecting **Codespaces: Sign In**. You may also need to use the **Codespaces: Create Plan** if you do not have a plan. See the [Codespaces docs](https://aka.ms/vso-docs/vscode) for details.
44+
45+
3. Press <kbd>Ctrl/Cmd</kbd> + <kbd>Shift</kbd> + <kbd>P</kbd> and select **Codespaces: Create New Codespace**.
46+
47+
4. Use default settings (which should include **Standard** 4 core, 8 GB RAM Codespace), select a plan, and then enter the repository URL `https://github.com/microsoft/vscode` (or a branch or PR URL) in the input box when prompted.
48+
49+
5. 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.
50+
51+
6. Anything you start in VS Code or the integrated terminal will appear here.
52+
53+
## Try it!
54+
55+
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.
56+
57+
Note you can also set the resolution from the command line by typing `set-resolution`.
58+
59+
To start working with Code - OSS, follow these steps:
60+
61+
1. In your local VS Code, open a terminal (<kbd>Ctrl/Cmd</kbd> + <kbd>Shift</kbd> + <kbd>\`</kbd>) and type the following commands:
62+
63+
```bash
64+
yarn install
65+
bash scripts/code.sh
66+
```
67+
68+
2. After the build is complete, 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.
69+
70+
3. You should now see Code - OSS!
71+
72+
Next, let's try debugging.
73+
74+
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.
75+
76+
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>).
77+
78+
> **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.
79+
80+
3. After a bit, Code - OSS will appear with the debugger attached!
81+
82+
Enjoy!
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
#!/bin/bash
2+
3+
NONROOT_USER=node
4+
LOG=/tmp/container-init.log
5+
6+
# Execute the command it not already running
7+
startInBackgroundIfNotRunning()
8+
{
9+
log "Starting $1."
10+
echo -e "\n** $(date) **" | sudoIf tee -a /tmp/$1.log > /dev/null
11+
if ! pidof $1 > /dev/null; then
12+
keepRunningInBackground "$@"
13+
while ! pidof $1 > /dev/null; do
14+
sleep 1
15+
done
16+
log "$1 started."
17+
else
18+
echo "$1 is already running." | sudoIf tee -a /tmp/$1.log > /dev/null
19+
log "$1 is already running."
20+
fi
21+
}
22+
23+
# Keep command running in background
24+
keepRunningInBackground()
25+
{
26+
($2 sh -c "while :; do echo [\$(date)] Process started.; $3; echo [\$(date)] Process exited!; sleep 5; done 2>&1" | sudoIf tee -a /tmp/$1.log > /dev/null & echo "$!" | sudoIf tee /tmp/$1.pid > /dev/null)
27+
}
28+
29+
# Use sudo to run as root when required
30+
sudoIf()
31+
{
32+
if [ "$(id -u)" -ne 0 ]; then
33+
sudo "$@"
34+
else
35+
"$@"
36+
fi
37+
}
38+
39+
# Use sudo to run as non-root user if not already running
40+
sudoUserIf()
41+
{
42+
if [ "$(id -u)" -eq 0 ]; then
43+
sudo -u ${NONROOT_USER} "$@"
44+
else
45+
"$@"
46+
fi
47+
}
48+
49+
# Log messages
50+
log()
51+
{
52+
echo -e "[$(date)] $@" | sudoIf tee -a $LOG > /dev/null
53+
}
54+
55+
log "** SCRIPT START **"
56+
57+
# Start dbus.
58+
log 'Running "/etc/init.d/dbus start".'
59+
if [ -f "/var/run/dbus/pid" ] && ! pidof dbus-daemon > /dev/null; then
60+
sudoIf rm -f /var/run/dbus/pid
61+
fi
62+
sudoIf /etc/init.d/dbus start 2>&1 | sudoIf tee -a /tmp/dbus-daemon-system.log > /dev/null
63+
while ! pidof dbus-daemon > /dev/null; do
64+
sleep 1
65+
done
66+
67+
# Set up Xvfb.
68+
startInBackgroundIfNotRunning "Xvfb" sudoIf "Xvfb ${DISPLAY:-:1} +extension RANDR -screen 0 ${MAX_VNC_RESOLUTION:-1920x1080x16}"
69+
70+
# Start fluxbox as a light weight window manager.
71+
startInBackgroundIfNotRunning "fluxbox" sudoUserIf "dbus-launch startfluxbox"
72+
73+
# Start x11vnc
74+
startInBackgroundIfNotRunning "x11vnc" sudoIf "x11vnc -display ${DISPLAY:-:1} -rfbport ${VNC_PORT:-5901} -localhost -no6 -xkb -shared -forever -passwdfile $HOME/.vnc/passwd"
75+
76+
# Set resolution
77+
/usr/local/bin/set-resolution ${VNC_RESOLUTION:-1280x720} ${VNC_DPI:-72}
78+
79+
80+
# Spin up noVNC if installed and not runnning.
81+
if [ -d "/usr/local/novnc" ] && [ "$(ps -ef | grep /usr/local/novnc/noVNC*/utils/launch.sh | grep -v grep)" = "" ]; then
82+
keepRunningInBackground "noVNC" sudoIf "/usr/local/novnc/noVNC*/utils/launch.sh --listen ${NOVNC_PORT:-6080} --vnc localhost:${VNC_PORT:-5901}"
83+
log "noVNC started."
84+
else
85+
log "noVNC is already running or not installed."
86+
fi
87+
88+
# Run whatever was passed in
89+
log "Executing \"$@\"."
90+
"$@"
91+
log "** SCRIPT EXIT **"

.devcontainer/bin/set-resolution

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/bin/bash
2+
RESOLUTION=${1:-${VNC_RESOLUTION:-1920x1080}}
3+
DPI=${2:-${VNC_DPI:-72}}
4+
if [ -z "$1" ]; then
5+
echo -e "**Current Settings **\n"
6+
xrandr
7+
echo -n -e "\nEnter new resolution (WIDTHxHEIGHT, blank for ${RESOLUTION}, Ctrl+C to abort).\n> "
8+
read NEW_RES
9+
if [ "${NEW_RES}" != "" ]; then
10+
RESOLUTION=${NEW_RES}
11+
fi
12+
if [ -z "$2" ]; then
13+
echo -n -e "\nEnter new DPI (blank for ${DPI}, Ctrl+C to abort).\n> "
14+
read NEW_DPI
15+
if [ "${NEW_DPI}" != "" ]; then
16+
DPI=${NEW_DPI}
17+
fi
18+
fi
19+
fi
20+
21+
xrandr --fb ${RESOLUTION} --dpi ${DPI} > /dev/null 2>&1
22+
23+
echo -e "\n**New Settings **\n"
24+
xrandr
25+
echo

.devcontainer/devcontainer.json

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
{
2+
"name": "Code - OSS",
3+
"build": {
4+
"dockerfile": "Dockerfile",
5+
"args": {
6+
"MAX_VNC_RESOLUTION": "1920x1080x16",
7+
"TARGET_VNC_RESOLUTION": "1280x768",
8+
"TARGET_VNC_PORT": "5901",
9+
"TARGET_NOVNC_PORT": "6080",
10+
"VNC_PASSWORD": "vscode",
11+
"INSTALL_FIREFOX": "true"
12+
}
13+
},
14+
"overrideCommand": false,
15+
"runArgs": [
16+
"--init",
17+
// seccomp=unconfined is required for Chrome sandboxing
18+
"--security-opt", "seccomp=unconfined"
19+
],
20+
21+
"settings": {
22+
// zsh is also available
23+
"terminal.integrated.shell.linux": "/bin/bash",
24+
"resmon.show.battery": false,
25+
"resmon.show.cpufreq": false,
26+
"remote.extensionKind": {
27+
"ms-vscode.js-debug-nightly": "workspace",
28+
"msjsdiag.debugger-for-chrome": "workspace"
29+
},
30+
"debug.chrome.useV3": true
31+
},
32+
33+
// noVNC, VNC ports
34+
"forwardPorts": [6080, 5901],
35+
36+
"extensions": [
37+
"dbaeumer.vscode-eslint",
38+
"EditorConfig.EditorConfig",
39+
"msjsdiag.debugger-for-chrome",
40+
"mutantdino.resourcemonitor",
41+
"GitHub.vscode-pull-request-github"
42+
],
43+
44+
"remoteUser": "node"
45+
}

.devcontainer/fluxbox/apps

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
[app] (name=code-oss-dev)
2+
[Position] (CENTER) {0 0}
3+
[Maximized] {yes}
4+
[Dimensions] {100% 100%}
5+
[end]
6+
[transient] (role=GtkFileChooserDialog)
7+
[Position] (CENTER) {0 0}
8+
[Dimensions] {70% 70%}
9+
[end]

.devcontainer/fluxbox/init

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
session.menuFile: ~/.fluxbox/menu
2+
session.keyFile: ~/.fluxbox/keys
3+
session.styleFile: /usr/share/fluxbox/styles//Squared_for_Debian
4+
session.configVersion: 13
5+
session.screen0.workspaces: 1
6+
session.screen0.workspacewarping: false
7+
session.screen0.toolbar.widthPercent: 100
8+
session.screen0.strftimeFormat: %d %b, %a %02k:%M:%S
9+
session.screen0.toolbar.tools: prevworkspace, workspacename, nextworkspace, clock, prevwindow, nextwindow, iconbar, systemtray

0 commit comments

Comments
 (0)