Skip to content

Commit

Permalink
Add documentation to build Docker images
Browse files Browse the repository at this point in the history
Simplify names of Docker build args
  • Loading branch information
AlexRuiz7 committed Apr 3, 2024
1 parent c59b7d9 commit 0040997
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 11 deletions.
14 changes: 14 additions & 0 deletions docker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,3 +78,17 @@ Refer to [scripts/README.md](../scripts/README.md) for details about how to buil
[docker-variant]: https://docs.docker.com/desktop/install/linux-install/#differences-between-docker-desktop-for-linux-and-docker-engine
[docker-context]: https://docs.docker.com/desktop/install/linux-install/#context
[wi-repo]: https://github.com/wazuh/wazuh-indexer

## Building Docker images

The [prod](./prod) folder contains the code to build Docker images. A tarball of `wazuh-indexer` needs to be located at the same level that the Dockerfile. Below there is example of the command needed to build the image. Set the build arguments and the image tag accordingly.

```console
docker build --build-arg="VERSION=4.9.0" --build-arg="INDEXER_TAR_NAME=wazuh-indexer-4.9.0-1_linux-x64_cfca84f.tar.gz" --tag=wazuh-indexer:4.9.0 --progress=plain --no-cache .
```

Then, start a container with:

```console
docker run -it --rm wazuh-indexer:4.9.0
```
6 changes: 3 additions & 3 deletions docker/prod/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# Wazuh Docker Copyright (C) 2017, Wazuh Inc. (License GPLv2)
FROM amazonlinux:2023.3.20240219.0 AS builder

ARG WAZUH_VERSION
ARG WAZUH_INDEXER_TAR_NAME
ARG VERSION
ARG INDEXER_TAR_NAME

RUN yum install curl-minimal openssl xz tar findutils shadow-utils -y

COPY ${WAZUH_INDEXER_TAR_NAME} /
COPY ${INDEXER_TAR_NAME} /

COPY config/opensearch.yml /

Expand Down
16 changes: 8 additions & 8 deletions docker/prod/config/config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,26 +11,26 @@ export TARGET_DIR=${CURDIR}/debian/${NAME}
export LOG_DIR=/var/log/${NAME}
export LIB_DIR=/var/lib/${NAME}
export PID_DIR=/run/${NAME}
export INSTALLATION_DIR=/usr/share/${NAME}
export CONFIG_DIR=${INSTALLATION_DIR}/config
export INDEXER_HOME=/usr/share/${NAME}
export CONFIG_DIR=${INDEXER_HOME}/config
export BASE_DIR=${NAME}-*

rm -rf ${INSTALLATION_DIR:?}/
tar -xf "${WAZUH_INDEXER_TAR_NAME}"
rm -rf ${INDEXER_HOME:?}/
tar -xf "${INDEXER_TAR_NAME}"

## TOOLS

## Variables
TOOLS_PATH=${NAME}-${WAZUH_VERSION}/plugins/opensearch-security/tools
TOOLS_PATH=${NAME}-${VERSION}/plugins/opensearch-security/tools
CERT_TOOL=${TOOLS_PATH}/wazuh-certs-tool.sh

# generate certificates
cp $CERT_TOOL .
chmod 755 wazuh-certs-tool.sh && bash wazuh-certs-tool.sh -A

# copy to target
mkdir -p ${TARGET_DIR}${INSTALLATION_DIR}
# mkdir -p ${TARGET_DIR}${INSTALLATION_DIR}/opensearch-security/ <-- empty dir
mkdir -p ${TARGET_DIR}${INDEXER_HOME}
# mkdir -p ${TARGET_DIR}${INDEXER_HOME}/opensearch-security/ <-- empty dir
mkdir -p ${TARGET_DIR}${CONFIG_DIR}
mkdir -p ${TARGET_DIR}${LIB_DIR}
mkdir -p ${TARGET_DIR}${LOG_DIR}
Expand All @@ -41,7 +41,7 @@ mkdir -p ${TARGET_DIR}/usr/lib/sysctl.d
mkdir -p ${TARGET_DIR}/usr/lib/systemd/system
mkdir -p ${TARGET_DIR}${CONFIG_DIR}/certs
# Copy installation files to final location
cp -pr ${BASE_DIR}/* ${TARGET_DIR}${INSTALLATION_DIR}
cp -pr ${BASE_DIR}/* ${TARGET_DIR}${INDEXER_HOME}
cp -pr /opensearch.yml ${TARGET_DIR}${CONFIG_DIR}
# Copy Wazuh indexer's certificates
cp -pr /wazuh-certificates/demo.indexer.pem ${TARGET_DIR}${CONFIG_DIR}/certs/indexer.pem
Expand Down

0 comments on commit 0040997

Please sign in to comment.