Skip to content

Commit

Permalink
Merge pull request #8010 from wazuh/change/8003-fix-the-wazuh-dashboa…
Browse files Browse the repository at this point in the history
…rd-reference-when-cloning-the-repository

Fix the wazuh dashboard reference when cloning the repository
  • Loading branch information
javimed authored Dec 18, 2024
2 parents 3ae034b + bbd7cf7 commit 6171559
Show file tree
Hide file tree
Showing 2 changed files with 139 additions and 104 deletions.
10 changes: 8 additions & 2 deletions source/_variables/replacements.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,15 @@
#
"|CTI_URL|" : "https://cti.wazuh.com/api/v1/catalog/contexts/vd_1.0.0/consumers/vd_4.8.0",
#
# === Environment
"|PYTHON_CLOUD_CONTAINERS_MIN|": "3.8",
"|PYTHON_CLOUD_CONTAINERS_MAX|": "3.12",
"|WAZUH_DASHBOARD_YARN_VERSION|": "1.22.22",
#
# === Global and Wazuh version (wazuh agent, manager, indexer, and dashboard)
"|WAZUH_CURRENT_MAJOR|" : "4.x",
"|WAZUH_CURRENT_MINOR|" : version,
"|WAZUH_CURRENT|" : release,
"|PYTHON_CLOUD_CONTAINERS_MIN|": "3.8",
"|PYTHON_CLOUD_CONTAINERS_MAX|": "3.12",

# --- Revision numbers for Wazuh agent and manager packages versions
# Yum packages revisions
Expand Down Expand Up @@ -143,6 +146,9 @@
"|WAZUH_CURRENT_HPUX|" : release,
"|WAZUH_REVISION_HPUX|" : "1",
#
# === OpenSearch
"|OPENSEARCH_DASHBOARDS_VERSION|": "2.13.0",
#
# === Elastic
# --- Filebeat
"|FILEBEAT_LATEST|" : "7.10.2",
Expand Down
233 changes: 131 additions & 102 deletions source/development/packaging/generate-dashboard-package.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
Wazuh dashboard
===============

The packages generation process is orchestrated by the ``build-packages.sh`` script, which is found within the ``dev-tools/build-packages/`` folder of the repository. This script is responsible for bundling plugins into one single application in tar, rpm and/or deb distributions. It takes the following parameters:
The ``build-packages.sh`` script, located in the ``dev-tools/build-packages/`` folder, orchestrates the package generation process. This script bundles plugins into a single application and supports ``tar``, ``rpm``, and ``deb`` distributions. It accepts the following parameters:

- version
- revision
- distribution
- wazuh-dashboard, wazuh-dashboard-plugins, and wazuh-security-dashboards-plugin package paths
- ``wazuh-dashboard``, ``wazuh-dashboard-plugins``, and ``wazuh-security-dashboards-plugin`` package paths

Official packages are built through a GitHub Actions pipeline, however, the process is designed to be independent enough for maximum portability. The building process is self-contained in the application code.

Expand All @@ -20,15 +20,24 @@ Build manually

Requirements:

- Docker
- **Docker**: Refer to `Docker installation guide <https://docs.docker.com/engine/install/>`__.
- **NVM (Node Version Manager)**: Refer to `NVM installation guide <https://github.com/nvm-sh/nvm#installing-and-updating>`__.
- **Yarn v|WAZUH_DASHBOARD_YARN_VERSION| (Node Package Manager)**: Refer to `Yarn installation guide <https://classic.yarnpkg.com/en/docs/install/>`__.
- **Utilities**: Ensure the following are available:

- ``zip``
- ``unzip``
- ``gzip``
- ``brotli``
- ``curl``

Generating zip packages
~~~~~~~~~~~~~~~~~~~~~~~

To use the script you first need to generate the packages from these repositories:

- ``wazuh-dashboard``
- ``wazuh-security-dashboards-plugin``
- ``wazuh-security-dashboards-plugin``
- ``wazuh-dashboard-plugins``

To build the packages, follow these steps:
Expand All @@ -37,39 +46,43 @@ To build the packages, follow these steps:

.. code:: console
# git clone -b <BRANCH_OR_TAG> https://github.com/wazuh/wazuh-dashboard.git
# cd wazuh-dashboard/
# yarn osd bootstrap
# yarn build --linux --skip-os-packages --release
$ git clone -b <BRANCH_OR_TAG> https://github.com/wazuh/wazuh-dashboard.git
$ cd wazuh-dashboard/
$ nvm install $(cat .nvmrc)
$ nvm use $(cat .nvmrc)
$ yarn osd bootstrap
$ yarn build-platform --linux --skip-os-packages --release
Example:

.. code:: console
# git clone -b 4.9.0 https://github.com/wazuh/wazuh-dashboard.git
# cd wazuh-dashboard/
# yarn osd bootstrap
# yarn build --linux --skip-os-packages --release
$ git clone -b v|WAZUH_CURRENT| https://github.com/wazuh/wazuh-dashboard.git
$ cd wazuh-dashboard/
$ nvm install $(cat .nvmrc)
$ nvm use $(cat .nvmrc)
$ yarn osd bootstrap
$ yarn build-platform --linux --skip-os-packages --release
#. Clone the Wazuh Security Dashboards Plugin repository in the plugins folder and build the plugin.

.. code:: console
# cd plugins/
# git clone -b <BRANCH_OR_TAG> https://github.com/wazuh/wazuh-security-dashboards-plugin.git
# cd wazuh-security-dashboards-plugin/
# yarn
# yarn build
$ cd plugins/
$ git clone -b <BRANCH_OR_TAG> https://github.com/wazuh/wazuh-security-dashboards-plugin.git
$ cd wazuh-security-dashboards-plugin/
$ yarn
$ yarn build
Example:

.. code:: console
# cd plugins/
# git clone -b 4.9.0 https://github.com/wazuh/wazuh-security-dashboards-plugin.git
# cd wazuh-security-dashboards-plugin/
# yarn
# yarn build
$ cd plugins/
$ git clone -b v|WAZUH_CURRENT| https://github.com/wazuh/wazuh-security-dashboards-plugin.git
$ cd wazuh-security-dashboards-plugin/
$ yarn
$ yarn build
#. Clone the Wazuh dashboard plugins repository in the plugins folder, move the contents of the plugins folder to the folder where the repository was cloned and build the plugins.

Expand All @@ -79,59 +92,63 @@ To build the packages, follow these steps:

.. code:: console
# cd ../
# git clone -b <BRANCH_OR_TAG> https://github.com/wazuh/wazuh-dashboard-plugins.git
# cd wazuh-dashboard-plugins/
# cp -r plugins/* ../
# cd ../main
# yarn
# yarn build
# cd ../wazuh-core/
# yarn
# yarn build
# cd ../wazuh-check-updates/
# yarn
# yarn build
$ cd ../
$ git clone -b <BRANCH_OR_TAG> https://github.com/wazuh/wazuh-dashboard-plugins.git
$ cd wazuh-dashboard-plugins/
$ nvm install $(cat .nvmrc)
$ nvm use $(cat .nvmrc)
$ cp -r plugins/* ../
$ cd ../main
$ yarn
$ yarn build
$ cd ../wazuh-core/
$ yarn
$ yarn build
$ cd ../wazuh-check-updates/
$ yarn
$ yarn build
Example:

.. code:: console
# cd ../
# git clone -b 4.9.0 https://github.com/wazuh/wazuh-dashboard-plugins.git
# cd wazuh-dashboard-plugins/
# cp -r plugins/* ../
# cd ../main
# yarn
# yarn build
# cd ../wazuh-core/
# yarn
# yarn build
# cd ../wazuh-check-updates/
# yarn
# yarn build
$ cd ../
$ git clone -b v|WAZUH_CURRENT| https://github.com/wazuh/wazuh-dashboard-plugins.git
$ cd wazuh-dashboard-plugins/
$ nvm install $(cat .nvmrc)
$ nvm use $(cat .nvmrc)
$ cp -r plugins/* ../
$ cd ../main
$ yarn
$ yarn build
$ cd ../wazuh-core/
$ yarn
$ yarn build
$ cd ../wazuh-check-updates/
$ yarn
$ yarn build
#. Zip the packages and move them to the packages folder

.. code:: console
# cd ../../../
# mkdir packages
# cd packages
# zip -r -j ./dashboard-package.zip ../wazuh-dashboard/target/opensearch-dashboards-2.13.0-linux-x64.tar.gz
# zip -r -j ./security-package.zip ../wazuh-dashboard/plugins/wazuh-security-dashboards-plugin/build/security-dashboards-<OPENSEARCH_VERSION>.0.zip
# zip -r -j ./wazuh-package.zip ../wazuh-dashboard/plugins/wazuh-check-updates/build/wazuhCheckUpdates-<OPENSEARCH_VERSION>.zip ../wazuh-dashboard/plugins/main/build/wazuh-<OPENSEARCH_VERSION>.zip ../wazuh-dashboard/plugins/wazuh-core/build/wazuhCore-<OPENSEARCH_VERSION>.zip
$ cd ../../../
$ mkdir packages
$ cd packages
$ zip -r -j ./dashboard-package.zip ../wazuh-dashboard/target/opensearch-dashboards-<OPENSEARCH_VERSION>-linux-x64.tar.gz
$ zip -r -j ./security-package.zip ../wazuh-dashboard/plugins/wazuh-security-dashboards-plugin/build/security-dashboards-<OPENSEARCH_VERSION>.0.zip
$ zip -r -j ./wazuh-package.zip ../wazuh-dashboard/plugins/wazuh-check-updates/build/wazuhCheckUpdates-<OPENSEARCH_VERSION>.zip ../wazuh-dashboard/plugins/main/build/wazuh-<OPENSEARCH_VERSION>.zip ../wazuh-dashboard/plugins/wazuh-core/build/wazuhCore-<OPENSEARCH_VERSION>.zip
Example:

.. code:: console
# cd ../../../
# mkdir packages
# cd packages
# zip -r -j ./dashboard-package.zip ../wazuh-dashboard/target/opensearch-dashboards-2.13.0-linux-x64.tar.gz
# zip -r -j ./security-package.zip ../wazuh-dashboard/plugins/wazuh-security-dashboards-plugin/build/security-dashboards-2.13.0.0.zip
# zip -r -j ./wazuh-package.zip ../wazuh-dashboard/plugins/wazuh-check-updates/build/wazuhCheckUpdates-2.13.0.zip ../wazuh-dashboard/plugins/main/build/wazuh-2.13.0.zip ../wazuh-dashboard/plugins/wazuh-core/build/wazuhCore-2.13.0.zip
$ cd ../../../
$ mkdir packages
$ cd packages
$ zip -r -j ./dashboard-package.zip ../wazuh-dashboard/target/opensearch-dashboards-|OPENSEARCH_DASHBOARDS_VERSION|-linux-x64.tar.gz
$ zip -r -j ./security-package.zip ../wazuh-dashboard/plugins/wazuh-security-dashboards-plugin/build/security-dashboards-|OPENSEARCH_DASHBOARDS_VERSION|.0.zip
$ zip -r -j ./wazuh-package.zip ../wazuh-dashboard/plugins/wazuh-check-updates/build/wazuhCheckUpdates-|OPENSEARCH_DASHBOARDS_VERSION|.zip ../wazuh-dashboard/plugins/main/build/wazuh-|OPENSEARCH_DASHBOARDS_VERSION|.zip ../wazuh-dashboard/plugins/wazuh-core/build/wazuhCore-|OPENSEARCH_DASHBOARDS_VERSION|.zip
At this point you must have three packages in the ``packages`` folder:

Expand All @@ -153,15 +170,17 @@ Run the ``build-packages.sh`` script in the ``dev-tools/build-packages/`` folder

.. code:: console
# cd ../wazuh-dashboard/dev-tools/build-packages/
# ./build-packages.sh -v <VERSION> -r <REVISION> --<DISTRIBUTION_(--deb_OR_--rpm)> -a file:///<PATH_TO_wazuh-package.zip> -s file:///<PATH_TO_security-package.zip> -b file:///<PATH_TO_dashboard-package.zip>
$ cd ../wazuh-dashboard/dev-tools/build-packages/
$ ./build-packages.sh -v <VERSION> -r <REVISION> --<DISTRIBUTION> -a file:///<PATH_TO_wazuh-package.zip> -s file:///<PATH_TO_security-package.zip> -b file:///<PATH_TO_dashboard-package.zip>
Where ``--<DISTRIBUTION>`` is either ``--deb`` or ``--rpm``.

Example:

.. code:: console
# cd ../wazuh-dashboard/dev-tools/build-packages/
# ./build-packages.sh -v 4.9.0 -r 1 --deb -a file:///packages/wazuh-package.zip -s file:///packages/security-package.zip -b file:///packages/dashboard-package.zip
$ cd ../wazuh-dashboard/dev-tools/build-packages/
$ ./build-packages.sh -v v|WAZUH_CURRENT| -r 1 --deb -a file:///packages/wazuh-package.zip -s file:///packages/security-package.zip -b file:///packages/dashboard-package.zip
The package will be generated in the ``output`` folder of the same directory where the script is located.

Expand All @@ -170,19 +189,29 @@ Build with Docker image

With this option you can create an image that has the package in tar.gz format and then if desired you can use the created package to generate the .deb or .rpm file.

Requirements
~~~~~~~~~~~~

- **Docker**: Refer to `Docker installation guide <https://docs.docker.com/engine/install/>`__.
- **Internet connection** to download the Docker images for the first time.
- **Utilities**: Ensure the following are available:

- ``jq``
- ``curl``

#. Clone the Wazuh dashboard repository.

.. code:: console
# git clone -b <BRANCH_OR_TAG> https://github.com/wazuh/wazuh-dashboard.git
# cd wazuh-dashboard/dev-tools/build-packages/
$ git clone -b <BRANCH_OR_TAG> https://github.com/wazuh/wazuh-dashboard.git
$ cd wazuh-dashboard/dev-tools/build-packages/
Example:

.. code:: console
# git clone -b 4.9.0 https://github.com/wazuh/wazuh-dashboard.git
# cd wazuh-dashboard/dev-tools/build-packages/
$ git clone -b v|WAZUH_CURRENT| https://github.com/wazuh/wazuh-dashboard.git
$ cd wazuh-dashboard/dev-tools/build-packages/
#. Build the Docker image with the following parameters:

Expand All @@ -194,52 +223,52 @@ With this option you can create an image that has the package in tar.gz format a
- ``-t``: Tag of the image.

.. code:: console
# docker build \
$ docker build \
--build-arg NODE_VERSION=<NODE_VERSION> \
--build-arg WAZUH_DASHBOARDS_BRANCH=<BRANCH_OF_wazuh-dashboard> \
--build-arg WAZUH_DASHBOARDS_PLUGINS=<BRANCH_OF_wazuh-dashboard-plugins> \
--build-arg WAZUH_SECURITY_DASHBOARDS_PLUGIN_BRANCH=<BRANCH_OF_wazuh-security-dashboards-plugin> \
--build-arg OPENSEARCH_DASHBOARDS_VERSION=<OPENSEARCH_DASHBOARDS_VERSION> \
-t <TAG_OF_IMAGE> \
-t <TAG_OF_IMAGE> \
-f wazuh-dashboard.Dockerfile .
Example:

.. code:: console
# docker build \
--build-arg NODE_VERSION=18.19.0 \
--build-arg WAZUH_DASHBOARDS_BRANCH=4.9.0 \
--build-arg WAZUH_DASHBOARDS_PLUGINS=4.9.0 \
--build-arg WAZUH_SECURITY_DASHBOARDS_PLUGIN_BRANCH=4.9.0 \
--build-arg OPENSEARCH_DASHBOARDS_VERSION=2.13.0 \
-t wzd:4.9.0 \
$ docker build \
--build-arg NODE_VERSION=$(cat ../../.nvmrc) \
--build-arg WAZUH_DASHBOARDS_BRANCH=v|WAZUH_CURRENT| \
--build-arg WAZUH_DASHBOARDS_PLUGINS=v|WAZUH_CURRENT| \
--build-arg WAZUH_SECURITY_DASHBOARDS_PLUGIN_BRANCH=v|WAZUH_CURRENT| \
--build-arg OPENSEARCH_DASHBOARDS_VERSION=|OPENSEARCH_DASHBOARDS_VERSION| \
-t wzd:v|WAZUH_CURRENT| \
-f wazuh-dashboard.Dockerfile .
#. Run the Docker image:

.. code:: console
# docker run -d --rm --name wazuh-dashboard-package <TAG_OF_IMAGE> tail -f /dev/null
$ docker run -d --rm --name wazuh-dashboard-package <TAG_OF_IMAGE> tail -f /dev/null
Example:

.. code:: console
# docker run -d --rm --name wazuh-dashboard-package wzd:4.9.0 tail -f /dev/null
$ docker run -d --rm --name wazuh-dashboard-package wzd:v|WAZUH_CURRENT| tail -f /dev/null
#. Copy the package to the host:

.. code:: console
# docker cp wazuh-dashboard-package:/home/node/packages/. <PATH_TO_SAVE_THE_PACKAGE>
$ docker cp wazuh-dashboard-package:/home/node/packages/. <PATH_TO_SAVE_THE_PACKAGE>
Example:

.. code:: console
# docker cp wazuh-dashboard-package:/home/node/packages/. /
$ docker cp wazuh-dashboard-package:/home/node/packages/. /
This copies the final package and the packages that were used to generate the final package.

Expand All @@ -248,15 +277,15 @@ With this option you can create an image that has the package in tar.gz format a
- ``-v``: Version of the package.
- ``-r``: Revision of the package.
- ``-p``: Path to the package in tar.gz format generated in the previous step

.. code:: console
# ./launcher.sh -v <VERSION> -r <REVISION> -p <PATH_TO_PACKAGE>
$ ./launcher.sh -v <VERSION> -r <REVISION> -p <PATH_TO_PACKAGE>
Example:

.. code:: console
# ./launcher.sh -v 4.9.0 -r 1 -p file:///wazuh-dashboard-4.9.0-1-linux-x64.tar.gz
$ ./launcher.sh -v v|WAZUH_CURRENT| -r 1 -p file:///wazuh-dashboard-|WAZUH_CURRENT|-1-linux-x64.tar.gz
The package will be generated in the ``output`` folder of the ``rpm`` or ``deb`` folder.

0 comments on commit 6171559

Please sign in to comment.