Skip to content

Devcontainer improvement#1766

Open
navidpadid wants to merge 5 commits into
hovancik:trunkfrom
navidpadid:devcontainer-improvement
Open

Devcontainer improvement#1766
navidpadid wants to merge 5 commits into
hovancik:trunkfrom
navidpadid:devcontainer-improvement

Conversation

@navidpadid
Copy link
Copy Markdown

@navidpadid navidpadid commented Mar 31, 2026

Issue: closes #1765

  • issue was opened to discuss proposed changes before starting implementation.
  • during development, node version specified in package.json was used.
  • package versions and package-lock.json were not changed.
  • app version number was not changed.
  • all new code has tests to ensure against regressions.
  • npm run lint reports no offenses.
  • npm run test is error-free.
  • README and CHANGELOG were updated accordingly.

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/Dockerfile

  • Based on mcr.microsoft.com/devcontainers/javascript-node:1-22-bookworm
  • Installs all Electron runtime libraries needed for the app and tests (libasound2, libatk-bridge2.0-0, libgbm1, libgtk-3-0, libnss3, libxshmfence1, xvfb)
  • Includes libinput-dev and libudev-dev which are required by node-desktop-idle-v2 to compile its native binding via node-gyp — without these, npm install fails with gyp ERR! configure error

.devcontainer/devcontainer.json

  • Runs npm install automatically on container creation, including a find-based chmod u+x pass on .bin/ symlink targets to fix a missing execute bit on cross-env (shipped without it in the npm tarball), which otherwise causes npm run lint to fail with Permission denied
  • Mounts SSH agent, ~/.ssh, ~/.gitconfig, and ~/.npmrc read-only from the host so Git over SSH and npm auth work without copying credentials into the container
  • Forwards port 9222 for remote debugging with npm run dev
  • Pre-installs the ESLint and Vitest VS Code extensions and configures ESLint to auto-fix on save

README.md

  • Adds a Dev Container section under the contributing guide explaining prerequisites and usage

Verification Process

Opened the repository in the dev container from scratch and verified:

  • npm install completes without errors (native modules node-desktop-idle-v2 and windows-focus-assist build successfully)
  • npm run lint — no offenses
  • npm test — 315/315 tests pass
  • npm run pack -- --linux — produces a valid dist/linux-unpacked/stretchly binary

Other information

The node_modules directory is kept in a named Docker volume (stretchly-node-modules) to avoid re-downloading packages on every container rebuild.

@navidpadid
Copy link
Copy Markdown
Author

@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
Copy link
Copy Markdown

codecov Bot commented Apr 5, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 67.39%. Comparing base (5372a0c) to head (a7b6966).
⚠️ Report is 10 commits behind head on trunk.

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@hovancik
Copy link
Copy Markdown
Owner

hovancik commented Apr 5, 2026

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

@navidpadid navidpadid force-pushed the devcontainer-improvement branch from 37a45d8 to f5fc3b7 Compare April 6, 2026 01:14
@navidpadid navidpadid force-pushed the devcontainer-improvement branch from 5dd7ac8 to a7b6966 Compare April 6, 2026 03:08
@navidpadid
Copy link
Copy Markdown
Author

navidpadid commented Apr 6, 2026

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

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 npm run dev:devcontainer would do the trick. I added another command for your testing.

Here is a screenshot of testing command:
Screenshot_20260405_200349

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.

@hovancik
Copy link
Copy Markdown
Owner

Hey, I am quite busy, will have to find time to review/try later

Comment thread .devcontainer/Dockerfile
@@ -0,0 +1,16 @@
FROM mcr.microsoft.com/devcontainers/javascript-node:1-22-bookworm
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

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.

Comment thread package.json
"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=*",
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

--remote-allow-origins=* is broad; --remote-allow-origins=http://localhost:9223 would be safer?

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

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\")\"' {} \\;",
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

What's this doing?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature request]: Improving the developer productivity and streamline setup using devcontainers

2 participants