Skip to content
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

Migrate /docker to /build-scripts and delete unused files #684

Merged
merged 4 commits into from
Feb 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build-push-docker-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ jobs:
needs: [call-build-workflow]
runs-on: ubuntu-24.04
env:
docker_path: ./docker/prod
docker_path: ./build-scripts/docker
steps:
- uses: actions/checkout@v4

Expand Down
42 changes: 37 additions & 5 deletions build-scripts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,24 @@ The process to build packages requires Docker and Docker Compose.

Before you get started, make sure to clean your environment by running `./gradlew clean`.

## Pre-requisites

1. Install [Docker](https://docs.docker.com/engine/install/) as per its instructions.

2. Your workstation must meet the minimum hardware requirements:

- 8 GB of RAM (minimum)
- 4 cores

The more resources the better ☺

3. Clone the [wazuh-indexer](https://github.com/wazuh/wazuh-indexer).

## Building wazuh-indexer packages

Use the script under `wazuh-indexer/docker/builder/builder.sh` to build a package.
The `builder` image automates the build and assemble process for the Wazuh Indexer and its plugins, making it easy to create packages on any system.

Use the script under `wazuh-indexer/build-scripts/builder/builder.sh` to build a package.

```bash
./builder.sh -h
Expand All @@ -35,15 +50,34 @@ Arguments:
-h Print help
```

The example below it will generate a wazuh-indexer package for Debian based systems, for the x64 architecture, using 1 as revision number and using the production naming convention.

```bash
# Wihtin wazuh-indexer/build-scripts/builder
bash builder.sh -d deb -a x64 -R 1 -s true
```

The resulting package will be stored at `wazuh-indexer/artifacts/dist`.

> The `STAGE` option defines the naming of the package. When set to `false`, the package will be unequivocally named with the commits' SHA of the `wazuh-indexer`, `wazuh-indexer-plugins` and `wazuh-indexer-reporting` repositories, in that order. For example: `wazuh-indexer_5.0.0-0_x86_64_aff30960363-846f143-494d125.rpm`.

## Building wazuh-indexer Docker images

The `build-and-push-docker-image.sh` script automates the process to build and push Wazuh Indexer Docker images to our repository in quay.io. The script takes serveral parameters. Use the `-h` option to display them.
The [docker](./docker) folder contains the code to build Docker images. Below there is an example of the command needed to build the image. Set the build arguments and the image tag accordingly.

The Docker image is built from a wazuh-indexer tarball (tar.gz), which must be present in the same folder as the Dockerfile in `wazuh-indexer/build-scripts/docker`.

```bash
docker build --build-arg="VERSION=5.0.0" --build-arg="INDEXER_TAR_NAME=wazuh-indexer_5.0.0-0_linux-x64.tar.gz" --tag=wazuh-indexer:5.0.0-0 --progress=plain --no-cache .
```

The Docker image is built from a wazuh-indexer tarball (tar.gz), which must be present in the same folder as the Dockerfile in `wazuh-indexer/docker/prod`.
Then, start a container with:

```bash
docker run -p 9200:9200 -it --rm wazuh-indexer:5.0.0-0
```

The `build-and-push-docker-image.sh` script automates the process to build and push Wazuh Indexer Docker images to our repository in quay.io. The script takes serveral parameters. Use the `-h` option to display them.

To push images, credentials must be set at environment level:

Expand All @@ -62,5 +96,3 @@ Arguments:
The script will stop if the credentials are not set, or if any of the required parameters are not provided.

This script is used in the `build-push-docker-image.yml` **GitHub Workflow**, which is used to automate the process even more. When possible, **prefer this method**.

For manual building refer to [our Docker containers guide](../docker/README.md).
7 changes: 3 additions & 4 deletions build-scripts/build-and-push-docker-image.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@

# This script builds and pushes wazuh-indexer docker images to the quay.io registry.
# The Docker image is built from a wazuh-indexer tarball (tar.gz), which must be
# present in the same folder as the Dockerfile in wazuh-indexer/docker/prod.
# For addtional information, read these documents:
# - wazuh-indexer/docker/README.md
# present in the same folder as the Dockerfile in wazuh-indexer/build-scripts/docker.
# For addtional information, read this document:
# - wazuh-indexer/build-scripts/README.md
#
# To push images, credentials must be set at environment level:
Expand Down Expand Up @@ -98,7 +97,7 @@ function main() {
docker login -u="${QUAY_USERNAME}" -p="${QUAY_TOKEN}" "${DOCKER_REGISTRY}"

# Build the Docker image.
local dockerfile_path="docker/prod"
local dockerfile_path="build-scripts/docker"
cd ${dockerfile_path}
docker build \
--build-arg="VERSION=${VERSION}" \
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ RUN mkdir -p /repositories/wazuh-indexer-plugins && \
chown wazuh-indexer:wazuh-indexer /repositories/wazuh-indexer-reporting

# Copy your build scripts into the container as root
COPY docker/builder/entrypoint.sh /
COPY build-scripts/builder/entrypoint.sh /

# Change file permissions as root
RUN chmod +x /entrypoint.sh
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ function usage() {
# ====
function main() {
check_project_root_folder $0
compose_file="docker/${current}/compose.yml"
compose_file="build-scripts/${current}/compose.yml"
compose_cmd="docker compose -f $compose_file"
REPO_PATH=$(pwd)
VERSION=$(cat VERSION)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ services:
container_name: wazuh-indexer-builder_${VERSION}
build:
context: ./../..
dockerfile: ${REPO_PATH}/docker/builder/Dockerfile
dockerfile: ${REPO_PATH}/build-scripts/builder/Dockerfile
environment:
- INDEXER_PLUGINS_BRANCH=${INDEXER_PLUGINS_BRANCH:-main}
- INDEXER_REPORTING_BRANCH=${INDEXER_REPORTING_BRANCH:-main}
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
62 changes: 0 additions & 62 deletions docker/README.md

This file was deleted.

60 changes: 0 additions & 60 deletions docker/dev/dev.sh

This file was deleted.

17 changes: 0 additions & 17 deletions docker/dev/dev.yml

This file was deleted.

68 changes: 0 additions & 68 deletions docker/dev/images/.dockerignore

This file was deleted.

20 changes: 0 additions & 20 deletions docker/dev/images/Dockerfile

This file was deleted.