Skip to content

Commit

Permalink
Update docs for the new builder.sh script
Browse files Browse the repository at this point in the history
  • Loading branch information
f-galland committed Dec 30, 2024
1 parent b7ea426 commit 397e7c0
Showing 1 changed file with 32 additions and 162 deletions.
194 changes: 32 additions & 162 deletions source/development/packaging/generate-indexer-package.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,10 @@ Wazuh indexer
Local packages generation
#########################

While official ``Wazuh Indexer`` packages are generated in a GitHub Actions pipeline, packages can also be compiled locally or within a docker container.
While official ``Wazuh Indexer`` packages are generated in a GitHub Actions pipeline, packages can also be compiled locally within a :doc:`docker</deployment-options/docker/docker-installation>` container.

The packages' generation process is orchestrated by two scripts, found under the ``build-scripts`` directory of the repository:
The packages' generation process is controlled by the ``docker/builder/builder.sh`` script. This script prepares and launches a docker container that automates the build process.

- ``build.sh``: compiles the Java application and bundles it into a package.
- ``assemble.sh``: uses the package from the previous step and inflates it with plugins and configuration files, ready for production deployment.

.. contents:: Table of contents:
:depth: 2
Expand All @@ -30,185 +28,57 @@ Docker environment
Pre-requisistes
===============

1. Clone the ``Wazuh Indexer`` GitHub repository and switch to the ``v|WAZUH_CURRENT|`` tag:
1. Install the :doc:`docker engine</deployment-options/docker/docker-installation>`

2. Clone the ``Wazuh Indexer`` GitHub repository and switch to the ``v|WAZUH_CURRENT|`` tag:

.. code:: console
# git clone https://github.com/wazuh/wazuh-indexer/
# git checkout v|WAZUH_CURRENT|
2. Bring the docker environment up:

.. code:: console
# cd wazuh-indexer/docker/ci
# bash ci.sh up
# cd ../..
Build a minimal package
=======================

A basic package including only the ``Wazuh Indexer`` engine without extra plugin is generated first.

1. Set the environment variables:

.. note::
Build the package
=================

Replace ``<arch>`` with one of ``x64`` or ``arm64`` and ``<package-type>`` with one of ``rpm``, ``deb`` or ``tar``
The `builder.sh` script is controlled by a number of optional arguments that are detailed in its help page:

.. code:: console
# ARCHITECTURE=<arch>
# PACKAGE_TYPE=<package-type>
$ ./builder.sh -h
Usage: ./builder.sh [args]
2. Run the build script:
Arguments:
-p INDEXER_PLUGINS_BRANCH [Optional] wazuh-indexer-plugins repo branch, default is 'master'.
-r INDEXER_REPORTING_BRANCH [Optional] wazuh-indexer-reporting repo branch, default is 'master'.
-R REVISION [Optional] Package revision, default is '0'.
-s STAGE [Optional] Staging build, default is 'false'.
-d DISTRIBUTION [Optional] Distribution, default is 'rpm'.
-a ARCHITECTURE [Optional] Architecture, default is 'x64'.
-D Destroy the docker environment
-h Print help
.. code:: console
# docker exec -it wi-build_$(<VERSION) bash build-scripts/build.sh -a $ARCHITECTURE -d $PACKAGE_TYPE -n $(bash build-scripts/baptizer.sh -a $ARCHITECTURE -d $PACKAGE_TYPE -m)
After this step, a minimal package (without plugins) will be present under the ``artifacts`` directory.

Full package assembly
=====================
Use these to select the desired target and the repo branch of the plugins. If none is provided, a ``rpm`` package for the ``amd64`` architecture will be built.

1. Set the environment variables:

.. note::

Replace ``<arch>`` with one of ``x64`` or ``arm64`` and ``<package-type>`` with one of ``rpm``, ``deb`` or ``tar``.
1. Change directory to the docker environment's path:

.. code:: console
# ARCHITECTURE=<arch>
# PACKAGE_TYPE=<package-type>
$ cd wazuh-indexer/docker/builder
2. Run the assembly process:
2. Launch the script with the selected option flags:

.. code:: console
# docker exec -it wi-assemble_$(<VERSION) bash build-scripts/assemble.sh -a $ARCHITECTURE -d $PACKAGE_TYPE -r 1
Native environment
******************
.. raw:: html

<div class="accordion-section open">


Pre-requisistes
================

1. Install build dependencies

.. tabs::

.. group-tab:: RPM

.. code-block:: console
# yum install -y git curl gnupg2 gcc gcc-c++ make cpio rpm-build mesa-libGLU freeglut alsa-lib atk at-spi2-core cairo cairo-devel cups-libs libdrm libgbm nspr nspr-devel nss pango libXcomposite libXdamage libXfixes libXfixes-devel libXi libxkbcommon libXrandr libXrender libXtst rpm rpm-build maven
.. group-tab:: DEB
$ bash builder.sh \
-p master \
-r master \
-R 0 \
-s false \
-d deb \
-a amd64
.. code-block:: console
# apt-get update
# apt-get install -y git curl gnupg2 y build-essential cpio debhelper-compat debmake freeglut3 libasound2 libatk-bridge2.0-0 libatk1.0-0 libatspi2.0-dev libcairo2 libcairo2-dev libcups2 libdrm2 libgbm-dev libgconf-2-4 libnspr4 libnspr4-dev libnss3 libpangocairo-1.0-0 libxcomposite-dev libxdamage1 libxfixes-dev libxfixes3 libxi6 libxkbcommon-x11-0 libxrandr2 libxrender1 libxtst6 rpm rpm2cpio maven
The code above will build a ``.deb`` package for the ``amd64`` architecture, using the plugins' master branch. The package revision will be set to ``0``.

2. Clone the ``wazuh-indexer`` repository and switch to the appropriate branch
Once the build process finishes, built packages will be deployed to the ``artifacts/dist`` directory under the repo's root.

.. code:: console
# git clone https://github.com/wazuh/wazuh-indexer
# git checkout v|WAZUH_CURRENT|
Build a minimal package
=======================

A basic package including only the ``Wazuh Indexer`` engine without extra plugin is generated first.

1. Set the environment variables:

.. note::

Replace ``<arch>`` with one of ``x64`` or ``arm64`` and ``<package-type>`` with one of ``rpm``, ``deb`` or ``tar``

.. code:: console
# ARCHITECTURE=<arch>
# PACKAGE_TYPE=<package-type>
2. Run the build script:

.. code:: console
# bash build-scripts/build.sh -a $ARCHITECTURE -d $PACKAGE_TYPE -n $(bash build-scripts/baptizer.sh -a $ARCHITECTURE -d $PACKAGE_TYPE -m)
After this step, a minimal package (without plugins) will be present under the ``artifacts`` directory.

Full package assembly
=====================

1. Set the ``ARCHITECTURE`` and ``PACKAGE_TYPE`` environment variables replacing ``<package-type>`` with one of ``tar``, ``deb`` or ``rpm`` and ``<arch>`` with ``x64`` or ``arm64`` depending on the target system the packages are being built for.

.. code:: console
# ARCHITECTURE=<arch>
# PACKAGE_TYPE=<package-type>
2. Run the assembly process:

.. code:: console
# bash build-scripts/assemble.sh -a $ARCHITECTURE -d $PACKAGE_TYPE
Build and assemble scripts reference
####################################
.. raw:: html

<div class="accordion-section open">

The packages' generation process is guided through bash scripts.

Below is a reference of their inputs, outputs and code:

.. code:: none
scripts:
- file: build.sh
description: |
generates a distribution package by running the appropiate Gradle task
depending on the parameters.
inputs:
architecture: [x64, arm64] # Note: we only build x86_64 packages
distribution: [tar, deb, rpm]
name: the name of the package to be generated.
outputs:
package: minimal wazuh-indexer package for the required distribution.
- file: assemble.sh
description: |
bundles the wazuh-indexer package generated in by build.sh with plugins,
configuration files and demo certificates (certificates yet to come).
inputs:
architecture: [x64, arm64] # Note: we only build x86_64 packages
distribution: [tar, deb, rpm]
revision: revision number. 0 by default.
outputs:
package: wazuh-indexer package.
- file: provision.sh
description: Provision script for the assembly of DEB packages.
- file: baptizer.sh
description: generate the wazuh-indexer package name depending on the parameters.
inputs:
architecture: [x64, arm64] # Note: we only build x86_64 packages
distribution: [tar, deb, rpm]
revision: revision number. 0 by default.
is_release: if set, uses release naming convention.
is_min: if set, the package name will start by `wazuh-indexer-min`. Used on the build stage.
outputs:
package: the name of the wazuh-indexer package

0 comments on commit 397e7c0

Please sign in to comment.