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

How to Dockerize wazuh-manager from github source #1014

Open
mehrdadhosseinzadeh opened this issue Sep 24, 2023 · 3 comments
Open

How to Dockerize wazuh-manager from github source #1014

mehrdadhosseinzadeh opened this issue Sep 24, 2023 · 3 comments

Comments

@mehrdadhosseinzadeh
Copy link

we forke wazuh from https://github.com/wazuh/wazuh on our self hosted gitlab.

and want to Dockerize it with dockerfile and docker-compose to deploy automatic after each commit by Ci/CD

anyone can help us ? are you have any availble repository ? any help ?

@mehrdadhosseinzadeh
Copy link
Author

i dont want to use deb file i want build and make from source

@mehrdadhosseinzadeh
Copy link
Author

mehrdadhosseinzadeh commented Sep 24, 2023

i use this way:

my Dockerfile_base
`FROM ubuntu:jammy

Set environment variables to avoid interactive prompts during package installation

ENV DEBIAN_FRONTEND=noninteractive

Update and upgrade packages, install required packages, and clean up

RUN apt-get update
&& apt-get upgrade -y
&& apt-get install -y gcc g++ make libc6-dev curl policycoreutils automake autoconf libtool libssl-dev expect git nano lsb-release
&& apt-get clean
&& apt-get autoremove -y
&& rm -rf /var/lib/apt/lists/* # Remove apt lists to reduce image size

Download and install CMake

RUN curl -OL http://packages.wazuh.com/utils/cmake/cmake-3.18.3.tar.gz &&
tar -zxf cmake-3.18.3.tar.gz &&
cd cmake-3.18.3 &&
./bootstrap --no-system-curl &&
make -j$(nproc) &&
make install &&
cd .. &&
rm -rf cmake-*

RUN echo "deb-src http://archive.ubuntu.com/ubuntu $(lsb_release -cs) main" >> /etc/apt/sources.list
RUN apt-get update -y
RUN apt-get build-dep python3 -y

Set the working directory

WORKDIR /root

Clear the environment variable

ENV DEBIAN_FRONTEND=`

my Dockerfile is
`# Use the official Ubuntu 20.04 as the base image
FROM repo.nordef.io/ubuntu-cmake:latest

Set environment variables to avoid interactive prompts during package installation

ENV DEBIAN_FRONTEND=noninteractive

Set environment variables

ENV USER_LANGUAGE=en
ENV USER_INSTALL_TYPE=server
ENV USER_ENABLE_EMAIL=n
ENV USER_ENABLE_SYSCHECK=y
ENV USER_ENABLE_ROOTCHECK=y
ENV USER_WHITE_LIST=n
ENV USER_ENABLE_SYSLOG=y
ENV USER_ENABLE_AUTHD=y
ENV USER_AUTO_START=y

Create a directory for your installation scripts

RUN mkdir -p /srv

Clone the Wazuh repository and build the server

RUN cd /srv &&
git clone -b develop https://mehrdad:glpat-1234@gitlab.nordef.io/xdr/manager.git &&
cd manager/src &&
make deps &&
make TARGET=server && cd ../

Set up auto_install.sh with expect

COPY auto_install.sh /srv/manager/auto_install.sh
RUN chmod +x /srv/manager/auto_install.sh

WORKDIR /srv/manager/

RUN expect /srv/manager/auto_install.sh

Expose ports 55000, 1515, and 1514

EXPOSE 55000 1515 1514
CMD ["/bin/bash"]`

my auto_install.sh
`#!/usr/bin/expect -f

Path to your shell script

set script_path "/srv/manager/install.sh"

Spawn your script

spawn "$script_path"

Expect and respond to the first prompt

expect "Press ENTER to continue" {
send "\r"
}

Expect and respond to the second prompt

expect "Choose where to install Wazuh" {
send "\r"
}

Expect and respond to the third prompt

expect "Press ENTER to continue" {
send "\r"
}

Expect and respond to the fourth prompt

expect "Press ENTER to continue" {
send "\r"
}

Wait for the "Completed." message and ignore it

expect "Completed."

Wait for the final message and respond with ENTER

expect "Press ENTER to finish" {
send "\r"
}

Wait for the spawned process to complete

expect eof`

my docker compose file
version: '3' services: xdr: image: repo.nordef.io/xdr_manager:latest #command: bash -c "cd /srv/manager/ && expect /srv/manager/auto_install.sh" #command: bash -c "while ! (echo > /dev/tcp/localhost/55000) 2>/dev/null; do sleep 1; done && cd /srv/manager/ && expect /srv/manager/auto_install.sh && /etc/init.d/nordef-manager restart && while true; do sleep 10; done" command: bash -c "while true; do sleep 10; done" container_name: xdr_manager ports: - "55000:55000" - "1514:1514" - "1515:1515"

  i use ubuntu as os and install requirments module and package with apt...and compile cmake after that clone or customized source code of wazuh manager. and make it.
  and use expect to skip prompt of install.sh to install .
  
  but container after run exit 0. and i use while true to up it but dont have wazuh-manager service !

@gecube
Copy link

gecube commented Oct 26, 2023

@mehrdadhosseinzadeh Hi! I am kindly asking you to fix the formatting of the message as it was corrupted by GitHub markdown... and it is really damn hard to read it right now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants