Skip to content

Conversation

hacki11
Copy link

@hacki11 hacki11 commented Apr 12, 2025

PR Checklist:

  • Provide a meaningful description to this PR or mention which issues this fixes.
  • Ensure the project builds with npm run build
  • Add tests for your change. This includes negative tests (i.e. inputs that need to fail) as well as baseline tests (i.e. how should the directory structure look like?).
  • Run the test suite with npm test
  • If there are baseline changes, review them and make a separate commit for them with the comment "accept baselines" if they are desired changes
  • N/A If you added a required option, also add it to the template creation (.github/create_templates.ts)
  • Add a detailed migration description to docs/updates explaining what the user needs to do when manually updating an existing project
  • Add your changes to CHANGELOG.md (referencing the migration description and this PR or the issue you fixed)

Description:

Dev Container Improvements

This pull request brings the improvements and relevant changes to the Dev Container setup for ioBroker adapter development, focusing on robustness, reliability and usability. Key updates include:

  • Simultaneous Adapter Development: Enable development of multiple adapters at the same time without conflicts.
  • Robust Setup Process: Resolve race conditions during container setup to ensure a reliable environment.
  • Support Non-Root User: Use a non-root user to avoid file permission issues, especially when working with Git.
  • Debugging-Ready Environment: Automatically prepare everything so debugging works immediately after setup.
  • Minor Improvements: Schema Updates, Websocket Fix and Integration Test Support

More:
Dev Container Improvements
Allow newer versions of admin

How to test:

git clone https://github.com/hacki11/create-adapter.git
git checkout devcontainer-improvements
cd create-adapter/test/baselines/ioBroker.hello-devcontainer
code .

Select Reopen in Container in VS Code.

This PR also includes #1135

fixes #1128

hacki11 added 24 commits April 3, 2025 21:38
- include adapter name in the devcontainer name to be able to distinguish between different opened vscode instances
- use forwardPorts to make it accessible in the vscode tab "ports"
- use portsAttributes to give the port a name
-  update the position of settings and extensions due to schema update
- put the postcreate commands into a separate script
- allow to extend the post create script with custom script to i.e. configure the adapter with a test configuration automatically
- make the iobroker (non-root) user the default user to not get permission problems because files created or modified (also .git/ files) will be owned by root and working outside the devcontainer is a problem then

postcreate.sh
- create and stop a new instance of the adapter in questions to avoid the manual task
- execute a custom script (postcreate_ext.sh) if the user provided one, so this file can stay as is

docker-compose.yml
- remove obsolete version attribute
- remove persisting the iobroker data to a volume - this will defeat the purpose of "rebuild container" because the volume still stays the same. This causes side effects. A dev container is build and created once, and recreated from scrach if needed. All configuration which is needed for a test must be done in the post create extension script. That way the devcontainer is robust and is always created correctly.
- use non-default ports for the main redis instance, to be able to call integration tests which also start a redis instance on default ports.
- remove the static port mapping to 8082 as it prevents to be able to open devcontainers of two different adapters at the same time. instead rely on the feature of vscode to dynamically assign a available host port.
change postcreate from chaining commands to set -e
simplify custom script execution
avoid the need for execution permissions
call npm install on post create
- move node_modules to / so also non-root is able to use this global node_modules dir
- add node wrapper due capability/non-root/debug issue in nodejs which is a open bug
- rewrite the entrypoint to be able to forward the log into the devcontainer log
boot.sh
- use boot.sh to tee the log of the entrypoint into a log file which can be tail'd in the poststart/postcreate
node-wrapper.sh
- add a node wrapper to support non-root debugging even with cap_net_raw capability
devcontainer.json
- upper case B in ioBroker
- add a poststart script to also show the boot log when the container was created already
postcreate.sh
- add some echos
- add wait for script to avoid race conditions
- find adapter name automatically
poststart.sh
- show boot.log also during container start
wait_for_iobroker.sh
- make sure we don't run into a race condition with the entrypoint which runs in the background
- fix path to custom postcreate
update style flavor
fix typos
- fix indendation
@hacki11 hacki11 mentioned this pull request May 9, 2025
8 tasks
@hacki11
Copy link
Author

hacki11 commented May 21, 2025

Some adapters already using this configuration successfully:

https://github.com/hacki11/ioBroker.valloxmv
https://github.com/hacki11/ioBroker.bsblan
https://github.com/hacki11/ioBroker.mhi-wfrac
https://github.com/ioBroker/ioBroker.zigbee
https://github.com/arteck/ioBroker.zigbee2mqtt

@Apollon77 Apollon77 requested a review from Copilot August 31, 2025 18:57
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR introduces comprehensive improvements to the Dev Container setup for ioBroker adapter development, focusing on robustness, reliability, and usability. The changes enable simultaneous adapter development, add a robust setup process, support non-root users, and provide a debugging-ready environment out of the box.

Key changes include:

  • Dev Container enhancements for multi-adapter development with dynamic naming and port forwarding
  • Admin dependency version constraint updated from fixed to greater-or-equal (>=) for better compatibility
  • Comprehensive file structure additions for new devcontainer baseline test case

Reviewed Changes

Copilot reviewed 92 out of 97 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
test/create-adapter.test.ts Adds new test case for devcontainer functionality and updates file filter logic
test/baselines/ioBroker.hello-devcontainer/* Complete baseline files for new devcontainer test case including Docker configs, scripts, and adapter structure
test/baselines/devcontainer/* Updated devcontainer baseline files with improved configuration
test/baselines/*/io-package.json Updates admin dependency from fixed version to >=7.0.23
templates/* New template files for devcontainer scripts, launch configuration, and updated existing templates
docs/updates/* Migration documentation for the changes
CHANGELOG.md Documents the new features and migration guides

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@Apollon77 Apollon77 requested a review from AlCalzone August 31, 2025 18:59
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.

Invalid admin dependency at io-package.json created
2 participants