Devcontainer improvement#1766
Conversation
|
@hovancik please let me know if there's anything I missed or you have any suggestions. I have tested the setup on Ubuntu and MacOS with Docker. Don't have windows machine to test with WSL, but I believe it should work just fine. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## trunk #1766 +/- ##
==========================================
- Coverage 68.21% 67.39% -0.83%
==========================================
Files 15 16 +1
Lines 494 506 +12
==========================================
+ Hits 337 341 +4
- Misses 157 165 +8 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Hi @navidpadid, how does this work? I am not familiar with devcontainer that much. The app runs then normally? I mean with this being docker and Stretchly being UI app? Thanks |
37a45d8 to
f5fc3b7
Compare
5dd7ac8 to
a7b6966
Compare
Hi @hovancik , yes it would be running normally by doing port forwarding. I have added the commands for simplicity to the files. In short, the Here is a screenshot of testing command: Would you also try to follow the readme and do your tests (UI tests) to confirm if everything works? I have tested this on Linux machine. There could be spots I may have missed. Thanks. |
|
Hey, I am quite busy, will have to find time to review/try later |
| @@ -0,0 +1,16 @@ | |||
| FROM mcr.microsoft.com/devcontainers/javascript-node:1-22-bookworm | |||
There was a problem hiding this comment.
could we make it use .nvmrc version? so I don't have to remember update this. Each Electron version is with specific node version so best to keep it in sync.
| "scripts": { | ||
| "start": "electron .", | ||
| "dev": "cross-env NODE_ENV=development electron . --trace-warnings --trace-deprecation --enable-logging --remote-debugging-port=9222", | ||
| "dev:container": "cross-env NODE_ENV=development electron . --no-sandbox --trace-warnings --trace-deprecation --enable-logging --remote-debugging-port=9223 --remote-allow-origins=*", |
There was a problem hiding this comment.
--remote-allow-origins=* is broad; --remote-allow-origins=http://localhost:9223 would be safer?
There was a problem hiding this comment.
also, is there reason to use 9223?
| "ghcr.io/devcontainers/features/git:1": {} | ||
| }, | ||
| "initializeCommand": "touch ~/.gitconfig ~/.npmrc", | ||
| "postCreateCommand": "sudo mkdir -p /workspaces/stretchly/node_modules && sudo chown -R node:node /workspaces/stretchly/node_modules && npm install && find node_modules/.bin -maxdepth 1 -type l -exec sh -c 'chmod u+x \"$(readlink -f \"$0\")\"' {} \\;", |

Issue: closes #1765
nodeversion specified inpackage.jsonwas used.npm run lintreports no offenses.npm run testis error-free.Description of the Change
Adds a VS Code Dev Container so contributors can get a fully working development environment in one click, without manually installing Electron runtime libraries or native build dependencies on their host machine.
.devcontainer/Dockerfilemcr.microsoft.com/devcontainers/javascript-node:1-22-bookwormlibasound2,libatk-bridge2.0-0,libgbm1,libgtk-3-0,libnss3,libxshmfence1,xvfb)libinput-devandlibudev-devwhich are required bynode-desktop-idle-v2to compile its native binding vianode-gyp— without these,npm installfails withgyp ERR! configure error.devcontainer/devcontainer.jsonnpm installautomatically on container creation, including afind-basedchmod u+xpass on.bin/symlink targets to fix a missing execute bit oncross-env(shipped without it in the npm tarball), which otherwise causesnpm run lintto fail withPermission denied~/.ssh,~/.gitconfig, and~/.npmrcread-only from the host so Git over SSH and npm auth work without copying credentials into the container9222for remote debugging withnpm run devREADME.mdVerification Process
Opened the repository in the dev container from scratch and verified:
npm installcompletes without errors (native modulesnode-desktop-idle-v2andwindows-focus-assistbuild successfully)npm run lint— no offensesnpm test— 315/315 tests passnpm run pack -- --linux— produces a validdist/linux-unpacked/stretchlybinaryOther information
The
node_modulesdirectory is kept in a named Docker volume (stretchly-node-modules) to avoid re-downloading packages on every container rebuild.