add variables from wazuh version

This commit is contained in:
vcerenu
2022-05-03 15:51:38 -03:00
parent 4c00ffdc16
commit 43d86dd5c8
9 changed files with 76 additions and 15 deletions

15
build-docker-images/build.sh Executable file
View File

@@ -0,0 +1,15 @@
WAZUH_IMAGE_VERSION=4.3.0
WAZUH_VERSION=$(echo $WAZUH_IMAGE_VERSION | sed -e 's/\.//g')
WAZUH_ACTUAL_VERSION=$(curl --silent https://api.github.com/repos/wazuh/wazuh/releases/latest | grep '\"tag_name\":' | sed -E 's/.*\"([^\"]+)\".*/\1/' | cut -c 2- | sed -e 's/\.//g')
## If wazuh manager exists in apt dev repository, change variables, if not exit 1
if [ "$WAZUH_VERSION" -le "$WAZUH_ACTUAL_VERSION" ]; then
IMAGE_VERSION=${WAZUH_IMAGE_VERSION}
else
IMAGE_VERSION=${WAZUH_IMAGE_VERSION}-dev
fi
echo WAZUH_VERSION=$WAZUH_IMAGE_VERSION > env
echo WAZUH_IMAGE_VERSION=$IMAGE_VERSION >> env
docker-compose --env-file env build --no-cache

View File

@@ -3,8 +3,11 @@ version: '3.7'
services: services:
wazuh.manager: wazuh.manager:
build: wazuh-manager/ build:
image: wazuh/wazuh-manager:4.3.0 context: wazuh-manager/
args:
- WAZUH_VERSION=${WAZUH_VERSION}
image: wazuh/wazuh-manager:${WAZUH_IMAGE_VERSION}
hostname: wazuh.manager hostname: wazuh.manager
restart: always restart: always
ports: ports:
@@ -31,8 +34,11 @@ services:
- filebeat_var:/var/lib/filebeat - filebeat_var:/var/lib/filebeat
wazuh.indexer: wazuh.indexer:
build: wazuh-indexer/ build:
image: wazuh/wazuh-indexer:4.3.0 context: wazuh-indexer/
args:
- WAZUH_VERSION=${WAZUH_VERSION}
image: wazuh/wazuh-indexer:${WAZUH_IMAGE_VERSION}
hostname: wazuh.indexer hostname: wazuh.indexer
restart: always restart: always
ports: ports:
@@ -48,8 +54,11 @@ services:
hard: 65536 hard: 65536
wazuh.dashboard: wazuh.dashboard:
build: wazuh-dashboard/ build:
image: wazuh/wazuh-dashboard:4.3.0 context: wazuh-dashboard/
args:
- WAZUH_VERSION=${WAZUH_VERSION}
image: wazuh/wazuh-dashboard:${WAZUH_IMAGE_VERSION}
hostname: wazuh.dashboard hostname: wazuh.dashboard
restart: always restart: always
ports: ports:

2
build-docker-images/env Normal file
View File

@@ -0,0 +1,2 @@
WAZUH_VERSION=4.3.0
WAZUH_IMAGE_VERSION=4.3.0-dev

View File

@@ -1,7 +1,7 @@
# Wazuh Docker Copyright (C) 2021 Wazuh Inc. (License GPLv2) # Wazuh Docker Copyright (C) 2021 Wazuh Inc. (License GPLv2)
FROM ubuntu:focal AS builder FROM ubuntu:focal AS builder
ARG WAZUH_VERSION=4.3.0 ARG WAZUH_VERSION
ARG INSTALL_DIR=/usr/share/wazuh-dashboard ARG INSTALL_DIR=/usr/share/wazuh-dashboard
# Update and install dependencies # Update and install dependencies
@@ -24,8 +24,9 @@ RUN $INSTALL_DIR/bin/opensearch-dashboards-keystore create --allow-root && \
echo kibanaserver | $INSTALL_DIR/bin/opensearch-dashboards-keystore add opensearch.username --stdin --allow-root && \ echo kibanaserver | $INSTALL_DIR/bin/opensearch-dashboards-keystore add opensearch.username --stdin --allow-root && \
echo kibanaserver | $INSTALL_DIR/bin/opensearch-dashboards-keystore add opensearch.password --stdin --allow-root echo kibanaserver | $INSTALL_DIR/bin/opensearch-dashboards-keystore add opensearch.password --stdin --allow-root
# Install Wazuh App COPY config/install_wazuh_app.sh /
RUN $INSTALL_DIR/bin/opensearch-dashboards-plugin install https://packages.wazuh.com/4.x/ui/dashboard/wazuh-${WAZUH_VERSION}.zip --allow-root RUN chmod 775 /install_wazuh_app.sh
RUN bash /install_wazuh_app.sh
# Copy and set permissions to config files # Copy and set permissions to config files
COPY config/opensearch_dashboards.yml $INSTALL_DIR/config/ COPY config/opensearch_dashboards.yml $INSTALL_DIR/config/

View File

@@ -0,0 +1,14 @@
## Variables
WAZUH_IMAGE_VERSION=$(echo $WAZUH_VERSION | sed -e 's/\.//g')
WAZUH_ACTUAL_VERSION=$(curl --silent https://api.github.com/repos/wazuh/wazuh/releases/latest | grep '\"tag_name\":' | sed -E 's/.*\"([^\"]+)\".*/\1/' | cut -c 2- | sed -e 's/\.//g')
echo $WAZUH_IMAGE_VERSION
echo $WAZUH_ACTUAL_VERSION
## If wazuh manager exists in apt dev repository, change variables, if not exit 1
if [ "$WAZUH_IMAGE_VERSION" -le "$WAZUH_ACTUAL_VERSION" ]; then
WAZUH_APP=https://packages.wazuh.com/4.x/ui/dashboard/wazuh-${WAZUH_VERSION}.zip
else
WAZUH_APP=https://packages-dev.wazuh.com/pre-release/ui/dashboard/wazuh-${WAZUH_VERSION}.zip
fi
# Install Wazuh App
$INSTALL_DIR/bin/opensearch-dashboards-plugin install $WAZUH_APP --allow-root

View File

@@ -1,6 +1,8 @@
# Wazuh Docker Copyright (C) 2021 Wazuh Inc. (License GPLv2) # Wazuh Docker Copyright (C) 2021 Wazuh Inc. (License GPLv2)
FROM ubuntu:focal AS builder FROM ubuntu:focal AS builder
ARG WAZUH_VERSION
RUN apt-get update -y && apt-get install curl openssl xz-utils -y RUN apt-get update -y && apt-get install curl openssl xz-utils -y
COPY config/opensearch.yml / COPY config/opensearch.yml /

View File

@@ -8,7 +8,7 @@ export TARGET_DIR=${CURDIR}/debian/${NAME}
# Package build options # Package build options
export USER=${NAME} export USER=${NAME}
export GROUP=${NAME} export GROUP=${NAME}
export VERSION=4.3.0 export VERSION=${WAZUH_VERSION}
export LOG_DIR=/var/log/${NAME} export LOG_DIR=/var/log/${NAME}
export LIB_DIR=/var/lib/${NAME} export LIB_DIR=/var/lib/${NAME}
export PID_DIR=/run/${NAME} export PID_DIR=/run/${NAME}

View File

@@ -1,17 +1,22 @@
# Wazuh Docker Copyright (C) 2021 Wazuh Inc. (License GPLv2) # Wazuh Docker Copyright (C) 2021 Wazuh Inc. (License GPLv2)
FROM ubuntu:focal FROM ubuntu:focal
ARG WAZUH_VERSION=4.3.0 RUN rm /bin/sh && ln -s /bin/bash /bin/sh
ARG TEMPLATE_VERSION=4.3
ARG WAZUH_VERSION
ARG TEMPLATE_VERSION=4.2
ARG FILEBEAT_CHANNEL=filebeat-oss ARG FILEBEAT_CHANNEL=filebeat-oss
ARG FILEBEAT_VERSION=7.10.2 ARG FILEBEAT_VERSION=7.10.2
ARG WAZUH_FILEBEAT_MODULE="wazuh-filebeat-0.1.tar.gz" ARG WAZUH_FILEBEAT_MODULE="wazuh-filebeat-0.1.tar.gz"
RUN apt-get update && apt install curl apt-transport-https lsb-release gnupg -y RUN apt-get update && apt install curl apt-transport-https lsb-release gnupg -y
RUN apt-key adv --fetch-keys https://packages.wazuh.com/key/GPG-KEY-WAZUH && \ COPY config/check_repository.sh /
echo "deb https://packages.wazuh.com/4.x/apt/ stable main" | tee -a /etc/apt/sources.list.d/wazuh.list && \
apt-get update && \ RUN chmod 775 /check_repository.sh
RUN source /check_repository.sh
RUN apt-get update && \
apt-get install wazuh-manager=${WAZUH_VERSION}-1 apt-get install wazuh-manager=${WAZUH_VERSION}-1
RUN curl -L -O https://artifacts.elastic.co/downloads/beats/filebeat/${FILEBEAT_CHANNEL}-${FILEBEAT_VERSION}-amd64.deb &&\ RUN curl -L -O https://artifacts.elastic.co/downloads/beats/filebeat/${FILEBEAT_CHANNEL}-${FILEBEAT_VERSION}-amd64.deb &&\

View File

@@ -0,0 +1,13 @@
## Variables
WAZUH_IMAGE_VERSION=$(echo $WAZUH_VERSION | sed -e 's/\.//g')
WAZUH_ACTUAL_VERSION=$(curl --silent https://api.github.com/repos/wazuh/wazuh/releases/latest | grep '\"tag_name\":' | sed -E 's/.*\"([^\"]+)\".*/\1/' | cut -c 2- | sed -e 's/\.//g')
## If wazuh manager exists in apt dev repository, change variables, if not exit 1
if [ "$WAZUH_IMAGE_VERSION" -le "$WAZUH_ACTUAL_VERSION" ]; then
APT_KEY=https://packages.wazuh.com/key/GPG-KEY-WAZUH
REPOSITORY="deb https://packages.wazuh.com/4.x/apt/ stable main"
else
APT_KEY=https://packages-dev.wazuh.com/key/GPG-KEY-WAZUH
REPOSITORY="deb https://packages-dev.wazuh.com/pre-release/apt/ unstable main"
fi
apt-key adv --fetch-keys ${APT_KEY}
echo ${REPOSITORY} | tee -a /etc/apt/sources.list.d/wazuh.list