Skip to content

Improve Docker documentation for 5.0.0+ and MacOS users #7407

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 10 commits into
base: 6.0.0
Choose a base branch
from

Conversation

gonzaarancibia
Copy link
Member

@gonzaarancibia gonzaarancibia commented Apr 22, 2025

Description

This PR improves the Docker documentation for setting up the Wazuh development environment, with a focus on MacOS-specific instructions and clarifying behavior differences between versions. It adds detailed explanations for setting vm.max_map_count on MacOS, updates the jq installation instructions, and includes information about accessing the dashboard via HTTPS in version 5.0.0+.

A key improvement is documenting that in version 5.0.0 and later, the Wazuh Dashboard container automatically installs dependencies and starts the server with yarn start --no-base-path, eliminating the need for developers to manually enter the container to run these commands.

Additionally, this PR documents the --no-start flag which allows developers to prevent automatic startup and manually control the initialization process when needed for debugging or custom configurations.

Issues Resolved

  • Lack of clear MacOS-specific instructions for setting up the development environment
  • Missing information about automatic startup behavior in version 5.0.0+
  • Unclear troubleshooting steps for common issues like "Wazuh dashboard server is not ready yet"
  • Incomplete host file configuration instructions for MacOS users
  • Confusion about manual vs. automatic dashboard startup in different versions
  • No documentation for preventing automatic startup when manual control is needed

Evidence

  1. Automatic startup in version 5.0.0+
  • Video showing the dashboard automatically starting without manual intervention
  • Container logs showing automatic dependency installation and server startup
without.flag.mov
  1. Manual control with --no-start flag
  • Video demonstration showing:
    • Starting the environment with ./dev.sh --no-start -a up
    • Container running but dashboard service not starting automatically
    • Manually connecting to the container, install dependencies and starting the service
    • Dashboard becoming accessible after manual startup
--no-start-redorc.mov
  1. MacOS-specific vm.max_map_count configuration
  • Screenshot showing successful execution of the Docker command to set vm.max_map_count on MacOS:
MacOS-specific vm max_map_count configuration
  1. MacOS user permissions setup
  • Terminal screenshot showing successful execution of the MacOS-specific commands:
Screenshot 2025-04-22 at 2 12 10 PM

Test

To test this PR:

  1. Follow the updated MacOS instructions to set up a new development environment
  2. Verify that the vm.max_map_count command works correctly on MacOS
  3. Confirm that the documentation accurately describes the behavior of version 5.0.0+ containers (automatic dependency installation and server startup)
  4. Test accessing the dashboard via HTTPS as described in the documentation
  5. Verify that developers no longer need to manually run yarn start in version 5.0.0+

Check List

  • New functionality includes testing.
  • New functionality has been documented.
  • Update CHANGELOG.md
  • Commits are signed per the DCO using --signoff

@gonzaarancibia gonzaarancibia force-pushed the enhancement/docker-macos-auto-startup-docs branch from d167f7e to 8fed0f3 Compare April 22, 2025 12:15
@gonzaarancibia gonzaarancibia marked this pull request as ready for review April 22, 2025 17:18
@Machi3mfl Machi3mfl self-requested a review April 22, 2025 17:26
Use the `--no-start` flag if you want to prevent the automatic startup of the dashboard service. This keeps the container running without starting the service, allowing you to connect to it and run commands manually:

``bash
For example:
Copy link
Contributor

Choose a reason for hiding this comment

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

Add ### before the text to avoid confusion with command scripts.

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed in commit SHA

docker/README.md Outdated
@@ -107,11 +118,34 @@ This brings up a Dev environment for the `wazuh-dashboard-plugins` development b
```bash
./dev.sh $WZ_HOME up
```
### Important Note for Version 5.0.0 and Later
Copy link
Contributor

Choose a reason for hiding this comment

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

It's not exclusive to version 5.0.0. The part about installing dependencies and starting the server with the command yarn start --no-base-path applies to any version of Wazuh.

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed in commit [SHA] (7f0c033)

docker/README.md Outdated
Comment on lines 136 to 141
If you need to prevent automatic startup and manually control the initialization process, use the `--no-start` flag:

```bash
./dev.sh --no-start -a up
```
This will keep the container running without starting the dashboard service, allowing you to connect to it and run commands manually.
Copy link
Contributor

Choose a reason for hiding this comment

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

This part is repeated in osd-dev/README.md.

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed in commit [SHA] (7f0c033)

docker/README.md Outdated
Comment on lines 143 to 148
For older versions (before 5.0.0), you'll need to:

1. Once the containers are up, attach a shell to the development container
2. Move to the kbn\plugins\wazuh-core directory
3. Run yarn to install dependencies
4. Move back to the root folder and run yarn start
Copy link
Contributor

Choose a reason for hiding this comment

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

If this part is no longer applicable, we could remove it for version 5.0, since the instructions for previous versions are already available in other branches or tags.

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed in commit SHA

Copy link
Member

@yenienserrano yenienserrano left a comment

Choose a reason for hiding this comment

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

Test: 🔴

When I execute the line sudo chown -R $USER:staff $WZ_HOME it gives an error

sudo dscl . -create /Groups/docker-desktop 
sudo dscl . -create /Groups/docker-desktop PrimaryGroupID 100999
sudo dscl . -create /Users/docker-desktop
sudo dscl . -create /Users/docker-desktop UniqueID 100999
sudo dscl . -create /Users/docker-desktop PrimaryGroupID 100999
sudo chown -R $USER:staff $WZ_HOME
zsh: bad substitution

docker/README.md Outdated

- Connection issues between services
- Problems with Wazuh indexer
- Initialization still in progress (wait a few minutes)
Copy link
Member

Choose a reason for hiding this comment

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

Maybe I would add that you have to finish optimizing the code. and the console would display the optimize/success message.

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks for the suggestion! I've added information about the code optimization process and the success message that appears in the console. commit

@gonzaarancibia gonzaarancibia self-assigned this May 8, 2025
@gonzaarancibia
Copy link
Member Author

gonzaarancibia commented May 8, 2025

Test: 🔴

When I execute the line sudo chown -R $USER:staff $WZ_HOME it gives an error

sudo dscl . -create /Groups/docker-desktop 
sudo dscl . -create /Groups/docker-desktop PrimaryGroupID 100999
sudo dscl . -create /Users/docker-desktop
sudo dscl . -create /Users/docker-desktop UniqueID 100999
sudo dscl . -create /Users/docker-desktop PrimaryGroupID 100999
sudo chown -R $USER:staff $WZ_HOME
zsh: bad substitution

@yenienserrano Could you please try replace the last command:

sudo chown -R $USER:staff $WZ_HOME

to:

sudo chown -R $(whoami):staff $WZ_HOME

I've identified the bug and fixed it in this commit.

The problem is that in zsh the $USER variable isn't always expanded correctly, causing the "zsh: bad substitution" error. I've modified the command to use $(whoami) instead, which works consistently in all shells, including zsh.

./dev.sh -os 2.19.1 -osd 2.19.1-5.0.0 --no-start -a up

### Then connect to the container
docker exec -it os-dev-2191-osd-1 bash
Copy link
Member

Choose a reason for hiding this comment

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

In the example would be docker exec -it os-dev-2191-500-osd-1 bash

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks for the correction. Resolution commit.

docker exec -it os-dev-2191-osd-1 bash

### Manually install dependencies
cd /kbn/plugins/wazuh-core
Copy link
Member

Choose a reason for hiding this comment

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

Already in the kbn folder would be cd plugins/wazuh-core

Copy link
Member Author

Choose a reason for hiding this comment

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

Here, don't we need to install dependencies in all plugin folders?

Copy link
Member Author

Choose a reason for hiding this comment

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

I applied the resolution and added comments to install in all folders. Resolution commit.

yarn install

### And manually start the service
cd /kbn
Copy link
Member

Choose a reason for hiding this comment

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

There is no such folder. cd ../.../ or cd /home/node/kbn would be the case.

Copy link
Member Author

Choose a reason for hiding this comment

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

Resolution commit.

…ashboard in osd-dev documentation

Signed-off-by: gonzaarancibia <[email protected]>
Copy link
Contributor

github-actions bot commented May 9, 2025

Wazuh Fleet Management plugin code coverage (Jest) test % values
Statements 40.38% ( 773 / 1914 )
Branches 36.92% ( 353 / 956 )
Functions 38.38% ( 233 / 607 )
Lines 40.2% ( 753 / 1873 )

Copy link
Contributor

github-actions bot commented May 9, 2025

Wazuh Core plugin code coverage (Jest) test % values
Statements 28.24% ( 711 / 2517 )
Branches 28.92% ( 370 / 1279 )
Functions 26.08% ( 186 / 713 )
Lines 28.38% ( 706 / 2487 )

Copy link
Contributor

github-actions bot commented May 9, 2025

Wazuh Check Updates plugin code coverage (Jest) test % values
Statements 76.44% ( 172 / 225 )
Branches 58.65% ( 61 / 104 )
Functions 61.7% ( 29 / 47 )
Lines 76.44% ( 172 / 225 )

Copy link
Member

@yenienserrano yenienserrano left a comment

Choose a reason for hiding this comment

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

🟢

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.

3 participants