vmware / photon

Minimal Linux container host
https://vmware.github.io/photon
Other
3.04k stars 698 forks source link

Remote Container debugging using VSCode fails in Photon OS #1340

Open RamWebDev opened 2 years ago

RamWebDev commented 2 years ago

Describe the bug

When using Remote Container debugging extension of VSCode to debug Photon OS container, it fails with below logs msg

[22 ms] Remote-Containers 0.241.3 in VS Code 1.69.2 (3b889b090b5ad5793f524b5d1d39fda662b96a2a). [21 ms] Start: Resolving Remote [23 ms] Setting up container: /type-express-srv4 [30 ms] Start: Run: docker inspect --type container /type-express-srv4 [149 ms] Start: Check Docker is running [149 ms] Start: Run: docker version --format {{.Server.APIVersion}} [292 ms] Server API version: 1.41 [293 ms] Start: Inspecting container [293 ms] Start: Run: docker inspect --type container 6461f8496631948afcf481adcec4569c678cd0847a2cf202230f4e7cb2c40d79 [367 ms] Start: Run in container: /bin/sh [369 ms] Start: Run in container: uname -m [569 ms] aarch64 [569 ms] [569 ms] Start: Run in container: (cat /etc/os-release || cat /usr/lib/os-release) 2>/dev/null [574 ms] NAME="VMware Photon OS" VERSION="4.0" ID=photon VERSION_ID=4.0 PRETTY_NAME="VMware Photon OS/Linux" ANSI_COLOR="1;34" HOME_URL="https://vmware.github.io/photon/" BUG_REPORT_URL="https://github.com/vmware/photon/issues" [574 ms] [574 ms] Start: Run in container: cat /etc/passwd [579 ms] Start: Run in container: test -d /root/.vscode-server [582 ms] [583 ms] [583 ms] Start: Run in container: test ! -f '/root/.vscode-server/data/Machine/.writeMachineSettingsMarker' && set -o noclobber && mkdir -p '/root/.vscode-server/data/Machine' && { > '/root/.vscode-server/data/Machine/.writeMachineSettingsMarker' ; } 2> /dev/null [586 ms] [586 ms] [586 ms] Exit code 1 [586 ms] Start: Run in container: cat /root/.vscode-server/data/Machine/settings.json [590 ms] [590 ms] cat: /root/.vscode-server/data/Machine/settings.json: No such file or directory [590 ms] Exit code 1 [590 ms] Support for ARM64 is in preview.

[590 ms] Start: Run in container: test -d /root/.vscode-server/bin/3b889b090b5ad5793f524b5d1d39fda662b96a2a [593 ms] [593 ms] [593 ms] Exit code 1 [593 ms] Installing VS Code Server for commit 3b889b090b5ad5793f524b5d1d39fda662b96a2a [594 ms] Start: Installing VS Code Server [594 ms] Start: Run in container: mkdir -p /root/.vscode-server/bin/3b889b090b5ad5793f524b5d1d39fda662b96a2a_1659239364084 [599 ms] [599 ms] [625 ms] Start: Run in container: (dd iflag=fullblock bs=8192 count=6258 2>/dev/null; dd iflag=fullblock bs=2631 count=1 2>/dev/null) | tar --no-same-owner -xz -C /root/.vscode-server/bin/3b889b090b5ad5793f524b5d1d39fda662b96a2a_1659239364084 [636 ms] [636 ms] zcat: not gzip [637 ms] Start: Run in container: mv -n /root/.vscode-server/bin/3b889b090b5ad5793f524b5d1d39fda662b96a2a_1659239364084/* /root/.vscode-server/bin/3b889b090b5ad5793f524b5d1d39fda662b96a2a && rmdir /root/.vscode-server/bin/3b889b090b5ad5793f524b5d1d39fda662b96a2a_1659239364084 [662 ms] Shell server terminated (code: 2, signal: null)

Reproduction steps

1. Install VS Code & "Remote Development" extensions for VS Code
2. Bring up a simple NodeJs app within the Photon OS container
3. Use the "Remote Explorer" icon in the left nav bar (installed as part of the "Remote Development" extension) to show a list of containers running (including the PhotonOS container)
4. Right-click on the Photon OS container and select "Attach to container"
5. Monitor the terminal and the error throw

Expected behavior

Should allow using remote development extension to debug and connect to PhotonOS container

Additional context

No response

dcasota commented 2 years ago

Hi @RamWebDev Trying to figure out useful Photon OS installations recipes for VS Code extensions. Unfortunately there isn't yet a "sweet spot" of a stable and easy-to-go installation.

On a test with Photon OS installed on a RPI4, and a laptop with W10 and VS Code, the following Microsoft Marketplace Extensions have been installed. Here some findings.

Now, "Visual Studio Code Remote Server" looks similar to https://github.com/coder/code-server. Simply said, the idea is to use Visual Studio Code in a web browser. On RPi4 Photon OS the standard installation curl -fsSL https://code-server.dev/install.sh | sh fails because the Photon OS arm64 vanilla bits do not include all packages preinstalled. So you have to install them manually e.g.

 cd ~
 tdnf install -y wget curl glibc-iconv glibc glibc-devel glibc-tools libstdc++ libstdc++-devel autoconf automake binutils diffutils 
 gcc glib-devel linux-api-headers make ncurses-devel util-linux-devel zlib-devel nodejs
 curl -J -L -O https://github.com/yarnpkg/yarn/releases/download/v1.22.19/yarn-v1.22.19.tar.gz
 tar -xzvf yarn-v1.22.19.tar.gz
 cd yarn-v1.22.19/
 PATH="~/yarn-v1.22.19/bin:$PATH"
 npm install --global yarn
 cd ~
 curl -J -L -O https://github.com/coder/code-server/releases/download/v4.5.1/code-server-4.5.1-linux-arm64.tar.gz
 tar -xzvf code-server-4.5.1-linux-arm64.tar.gz
 cd code-server-4.5.1-linux-arm64/
 ./postinstall.sh

In ~/.config/code-server/config.yaml you can add the bind address, etc. The password is stored in ~/.config/code-server/config.yaml. The default port 8080 has to be opened on Photon OS: /sbin/iptables -A INPUT -p tcp --dport 8080 -j ACCEPT Start the code-server ~/code-server-4.5.1-linux-arm64/bin/code-server. Connect in a webbrowser to VS Code and login.

Opening a file e.g. server.js worked.

The Java Debug Terminal didn't start successfully. The console window shows issues e.g.

edited: The server.js uses the module express. With npm install express this prerequisite is met. serverjs

It seems to work, hope this helps.