Skip to content

Devcontainer improvements #1137

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 24 commits into
base: master
Choose a base branch
from

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

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

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.

1 participant