From 943929d87865cf627e021d76805330f5169f3cd9 Mon Sep 17 00:00:00 2001 From: Ian Yenien Serrano Date: Tue, 21 May 2024 23:08:03 +0200 Subject: [PATCH 1/5] Add dockerfile --- .../build-packages/wazuh-dashboard.Dockerfile | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 dev-tools/build-packages/wazuh-dashboard.Dockerfile diff --git a/dev-tools/build-packages/wazuh-dashboard.Dockerfile b/dev-tools/build-packages/wazuh-dashboard.Dockerfile new file mode 100644 index 000000000000..1ecb104c7850 --- /dev/null +++ b/dev-tools/build-packages/wazuh-dashboard.Dockerfile @@ -0,0 +1,40 @@ +# Usage: docker build --build-arg NODE_VERSION=18.19.0 --build-arg WAZUH_DASHBOARD_VERSION=4.9.0 -t wzd:4.9.0 -f wzd-dev.Dockerfile . + +ARG NODE_VERSION +FROM node:${NODE_VERSION} AS base +ARG WAZUH_DASHBOARD_VERSION +USER node +RUN git clone --depth 1 --branch ${WAZUH_DASHBOARD_VERSION} https://github.com/wazuh/wazuh-dashboard.git /home/node/kbn +RUN chown node.node /home/node/kbn + +WORKDIR /home/node/kbn +RUN yarn osd bootstrap --production +RUN yarn build --linux --skip-os-packages --release + + +WORKDIR /home/node/kbn/plugins +RUN git clone --depth 1 --branch ${WAZUH_DASHBOARD_VERSION} https://github.com/wazuh/wazuh-security-dashboards-plugin.git +RUN git clone --depth 1 --branch ${WAZUH_DASHBOARD_VERSION} https://github.com/wazuh/wazuh-dashboard-plugins.git +WORKDIR /home/node/kbn/plugins/wazuh-security-dashboards-plugin +RUN yarn +RUN yarn build +WORKDIR /home/node/kbn/plugins +RUN mv ./wazuh-dashboard-plugins/plugins/main ./wazuh +RUN mv ./wazuh-dashboard-plugins/plugins/wazuh-core ./wazuh-core +RUN mv ./wazuh-dashboard-plugins/plugins/wazuh-check-updates ./wazuh-check-updates +WORKDIR /home/node/kbn/plugins/wazuh +RUN yarn +RUN yarn build +WORKDIR /home/node/kbn/plugins/wazuh-core +RUN yarn +RUN yarn build +WORKDIR /home/node/kbn/plugins/wazuh-check-updates +RUN yarn +RUN yarn build + +RUN mkdir -p /home/node/kbn/data/wazuh/config + +FROM node:${NODE_VERSION} +USER node +COPY --chown=node:node --from=base /home/node/kbn /home/node/kbn +WORKDIR /home/node/kbn From 6fe8e7c95026f91aed064f74819315b4ba8e6c88 Mon Sep 17 00:00:00 2001 From: Ian Yenien Serrano Date: Wed, 22 May 2024 22:39:24 +0200 Subject: [PATCH 2/5] Add osd version to build packages --- dev-tools/build-packages/wazuh-dashboard.Dockerfile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/dev-tools/build-packages/wazuh-dashboard.Dockerfile b/dev-tools/build-packages/wazuh-dashboard.Dockerfile index 1ecb104c7850..ade772e58448 100644 --- a/dev-tools/build-packages/wazuh-dashboard.Dockerfile +++ b/dev-tools/build-packages/wazuh-dashboard.Dockerfile @@ -1,8 +1,10 @@ -# Usage: docker build --build-arg NODE_VERSION=18.19.0 --build-arg WAZUH_DASHBOARD_VERSION=4.9.0 -t wzd:4.9.0 -f wzd-dev.Dockerfile . +# Usage: docker build --build-arg NODE_VERSION=18.19.0 --build-arg OPENSEARCH_DASHBOARDS_VERSION=2.13.0 --build-arg WAZUH_DASHBOARD_VERSION=4.9.0 -t wzd:4.9.0 -f wzd-dev.Dockerfile . ARG NODE_VERSION FROM node:${NODE_VERSION} AS base ARG WAZUH_DASHBOARD_VERSION +ARG OPENSEARCH_DASHBOARDS_VERSION +ENV OPENSEARCH_DASHBOARDS_VERSION=${OPENSEARCH_DASHBOARDS_VERSION} USER node RUN git clone --depth 1 --branch ${WAZUH_DASHBOARD_VERSION} https://github.com/wazuh/wazuh-dashboard.git /home/node/kbn RUN chown node.node /home/node/kbn From 8eebf90a2dfd7bf08b1c47814e5a81fe23294e2d Mon Sep 17 00:00:00 2001 From: Ian Yenien Serrano Date: Thu, 23 May 2024 23:04:00 +0200 Subject: [PATCH 3/5] Update dockerfile --- .../build-packages/wazuh-dashboard.Dockerfile | 33 ++++++++++++------- 1 file changed, 21 insertions(+), 12 deletions(-) diff --git a/dev-tools/build-packages/wazuh-dashboard.Dockerfile b/dev-tools/build-packages/wazuh-dashboard.Dockerfile index ade772e58448..3c8ae5e162a3 100644 --- a/dev-tools/build-packages/wazuh-dashboard.Dockerfile +++ b/dev-tools/build-packages/wazuh-dashboard.Dockerfile @@ -5,38 +5,47 @@ FROM node:${NODE_VERSION} AS base ARG WAZUH_DASHBOARD_VERSION ARG OPENSEARCH_DASHBOARDS_VERSION ENV OPENSEARCH_DASHBOARDS_VERSION=${OPENSEARCH_DASHBOARDS_VERSION} +USER root +RUN apt-get update && apt-get install -y git zip unzip USER node -RUN git clone --depth 1 --branch ${WAZUH_DASHBOARD_VERSION} https://github.com/wazuh/wazuh-dashboard.git /home/node/kbn -RUN chown node.node /home/node/kbn +RUN git clone --depth 1 --branch ${WAZUH_DASHBOARD_VERSION} https://github.com/wazuh/wazuh-dashboard.git /home/node/wzd +RUN chown node.node /home/node/wzd -WORKDIR /home/node/kbn +WORKDIR /home/node/wzd RUN yarn osd bootstrap --production RUN yarn build --linux --skip-os-packages --release -WORKDIR /home/node/kbn/plugins +WORKDIR /home/node/wzd/plugins RUN git clone --depth 1 --branch ${WAZUH_DASHBOARD_VERSION} https://github.com/wazuh/wazuh-security-dashboards-plugin.git RUN git clone --depth 1 --branch ${WAZUH_DASHBOARD_VERSION} https://github.com/wazuh/wazuh-dashboard-plugins.git -WORKDIR /home/node/kbn/plugins/wazuh-security-dashboards-plugin +WORKDIR /home/node/wzd/plugins/wazuh-security-dashboards-plugin RUN yarn RUN yarn build -WORKDIR /home/node/kbn/plugins +WORKDIR /home/node/wzd/plugins RUN mv ./wazuh-dashboard-plugins/plugins/main ./wazuh RUN mv ./wazuh-dashboard-plugins/plugins/wazuh-core ./wazuh-core RUN mv ./wazuh-dashboard-plugins/plugins/wazuh-check-updates ./wazuh-check-updates -WORKDIR /home/node/kbn/plugins/wazuh +WORKDIR /home/node/wzd/plugins/wazuh RUN yarn RUN yarn build -WORKDIR /home/node/kbn/plugins/wazuh-core +WORKDIR /home/node/wzd/plugins/wazuh-core RUN yarn RUN yarn build -WORKDIR /home/node/kbn/plugins/wazuh-check-updates +WORKDIR /home/node/wzd/plugins/wazuh-check-updates RUN yarn RUN yarn build -RUN mkdir -p /home/node/kbn/data/wazuh/config +WORKDIR /home/node/ +RUN mkdir packages +WORKDIR /home/node/packages +RUN zip -r -j ./dashboard-package.zip ../wazuh-dashboard/target/opensearch-dashboards-2.13.0-linux-x64.tar.gz +RUN zip -r -j ./security-package.zip ../wazuh-dashboard/plugins/wazuh-security-dashboards-plugin/build/security-dashboards-2.13.0.0.zip +RUN zip -r -j ./wazuh-package.zip ../wazuh-dashboard/plugins/wazuh-check-updates/build/wazuhCheckUpdates-2.13.0.zip ../wazuh-dashboard/plugins/main/build/wazuh-2.13.0.zip ../wazuh-dashboard/plugins/wazuh-core/build/wazuhCore-2.13.0.zip + +RUN mkdir -p /home/node/wzd/data/wazuh/config FROM node:${NODE_VERSION} USER node -COPY --chown=node:node --from=base /home/node/kbn /home/node/kbn -WORKDIR /home/node/kbn +COPY --chown=node:node --from=base /home/node/wzd /home/node/wzd +WORKDIR /home/node/wzd From 6d89ba583070f712e58cb36da1fffe2c0f57ae07 Mon Sep 17 00:00:00 2001 From: Ian Yenien Serrano Date: Fri, 24 May 2024 22:33:42 +0200 Subject: [PATCH 4/5] Build final tar --- .../build-packages/wazuh-dashboard.Dockerfile | 24 +++++++++++-------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/dev-tools/build-packages/wazuh-dashboard.Dockerfile b/dev-tools/build-packages/wazuh-dashboard.Dockerfile index 3c8ae5e162a3..cdeb411491ad 100644 --- a/dev-tools/build-packages/wazuh-dashboard.Dockerfile +++ b/dev-tools/build-packages/wazuh-dashboard.Dockerfile @@ -1,14 +1,16 @@ -# Usage: docker build --build-arg NODE_VERSION=18.19.0 --build-arg OPENSEARCH_DASHBOARDS_VERSION=2.13.0 --build-arg WAZUH_DASHBOARD_VERSION=4.9.0 -t wzd:4.9.0 -f wzd-dev.Dockerfile . +# Usage: docker build --build-arg NODE_VERSION=18.19.0 --build-arg WAZUH_DASHBOARDS_BRANCH=4.9.0 --build-arg WAZUH_DASHBOARDS_PLUGINS=4.9.0 --build-arg WAZUH_SECURITY_DASHBOARDS_PLUGIN_BRANCH=4.9.0 --build-arg OPENSEARCH_DASHBOARDS_VERSION=2.13.0 -t wzd:4.9.0 -f wazuh-dashboard.Dockerfile . ARG NODE_VERSION FROM node:${NODE_VERSION} AS base -ARG WAZUH_DASHBOARD_VERSION ARG OPENSEARCH_DASHBOARDS_VERSION +ARG WAZUH_DASHBOARDS_BRANCH +ARG WAZUH_DASHBOARDS_PLUGINS +ARG WAZUH_SECURITY_DASHBOARDS_PLUGIN_BRANCH ENV OPENSEARCH_DASHBOARDS_VERSION=${OPENSEARCH_DASHBOARDS_VERSION} USER root -RUN apt-get update && apt-get install -y git zip unzip +RUN apt-get update && apt-get install -y git zip unzip curl brotli jq USER node -RUN git clone --depth 1 --branch ${WAZUH_DASHBOARD_VERSION} https://github.com/wazuh/wazuh-dashboard.git /home/node/wzd +RUN git clone --depth 1 --branch ${WAZUH_DASHBOARDS_BRANCH} https://github.com/wazuh/wazuh-dashboard.git /home/node/wzd RUN chown node.node /home/node/wzd WORKDIR /home/node/wzd @@ -17,8 +19,8 @@ RUN yarn build --linux --skip-os-packages --release WORKDIR /home/node/wzd/plugins -RUN git clone --depth 1 --branch ${WAZUH_DASHBOARD_VERSION} https://github.com/wazuh/wazuh-security-dashboards-plugin.git -RUN git clone --depth 1 --branch ${WAZUH_DASHBOARD_VERSION} https://github.com/wazuh/wazuh-dashboard-plugins.git +RUN git clone --depth 1 --branch ${WAZUH_SECURITY_DASHBOARDS_PLUGIN_BRANCH} https://github.com/wazuh/wazuh-security-dashboards-plugin.git +RUN git clone --depth 1 --branch ${WAZUH_DASHBOARDS_PLUGINS} https://github.com/wazuh/wazuh-dashboard-plugins.git WORKDIR /home/node/wzd/plugins/wazuh-security-dashboards-plugin RUN yarn RUN yarn build @@ -39,13 +41,15 @@ RUN yarn build WORKDIR /home/node/ RUN mkdir packages WORKDIR /home/node/packages -RUN zip -r -j ./dashboard-package.zip ../wazuh-dashboard/target/opensearch-dashboards-2.13.0-linux-x64.tar.gz -RUN zip -r -j ./security-package.zip ../wazuh-dashboard/plugins/wazuh-security-dashboards-plugin/build/security-dashboards-2.13.0.0.zip -RUN zip -r -j ./wazuh-package.zip ../wazuh-dashboard/plugins/wazuh-check-updates/build/wazuhCheckUpdates-2.13.0.zip ../wazuh-dashboard/plugins/main/build/wazuh-2.13.0.zip ../wazuh-dashboard/plugins/wazuh-core/build/wazuhCore-2.13.0.zip +RUN zip -r -j ./dashboard-package.zip ../wzd/target/opensearch-dashboards-2.13.0-linux-x64.tar.gz +RUN zip -r -j ./security-package.zip ../wzd/plugins/wazuh-security-dashboards-plugin/build/security-dashboards-2.13.0.0.zip +RUN zip -r -j ./wazuh-package.zip ../wzd/plugins/wazuh-check-updates/build/wazuhCheckUpdates-2.13.0.zip ../wzd/plugins/wazuh/build/wazuh-2.13.0.zip ../wzd/plugins/wazuh-core/build/wazuhCore-2.13.0.zip +WORKDIR /home/node/wzd/dev-tools/build-packages/base +RUN ./generate_base.sh -v 4.9.0 -r 1 -a file:///home/node/packages/wazuh-package.zip -s file:///home/node/packages/security-package.zip -b file:///home/node/packages/dashboard-package.zip -RUN mkdir -p /home/node/wzd/data/wazuh/config FROM node:${NODE_VERSION} USER node COPY --chown=node:node --from=base /home/node/wzd /home/node/wzd +COPY --chown=node:node --from=base /home/node/packages /home/node/packages WORKDIR /home/node/wzd From b9870061a39632e86c292abdc3f40ae52d26c357 Mon Sep 17 00:00:00 2001 From: Ian Yenien Serrano Date: Mon, 27 May 2024 18:25:50 +0200 Subject: [PATCH 5/5] Move package final to /home/node/packages --- dev-tools/build-packages/wazuh-dashboard.Dockerfile | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/dev-tools/build-packages/wazuh-dashboard.Dockerfile b/dev-tools/build-packages/wazuh-dashboard.Dockerfile index cdeb411491ad..640f459f78f0 100644 --- a/dev-tools/build-packages/wazuh-dashboard.Dockerfile +++ b/dev-tools/build-packages/wazuh-dashboard.Dockerfile @@ -37,15 +37,16 @@ RUN yarn build WORKDIR /home/node/wzd/plugins/wazuh-check-updates RUN yarn RUN yarn build - WORKDIR /home/node/ RUN mkdir packages WORKDIR /home/node/packages -RUN zip -r -j ./dashboard-package.zip ../wzd/target/opensearch-dashboards-2.13.0-linux-x64.tar.gz -RUN zip -r -j ./security-package.zip ../wzd/plugins/wazuh-security-dashboards-plugin/build/security-dashboards-2.13.0.0.zip -RUN zip -r -j ./wazuh-package.zip ../wzd/plugins/wazuh-check-updates/build/wazuhCheckUpdates-2.13.0.zip ../wzd/plugins/wazuh/build/wazuh-2.13.0.zip ../wzd/plugins/wazuh-core/build/wazuhCore-2.13.0.zip +RUN zip -r -j ./dashboard-package.zip ../wzd/target/opensearch-dashboards-${OPENSEARCH_DASHBOARDS_VERSION}-linux-x64.tar.gz +RUN zip -r -j ./security-package.zip ../wzd/plugins/wazuh-security-dashboards-plugin/build/security-dashboards-${OPENSEARCH_DASHBOARDS_VERSION}.0.zip +RUN zip -r -j ./wazuh-package.zip ../wzd/plugins/wazuh-check-updates/build/wazuhCheckUpdates-${OPENSEARCH_DASHBOARDS_VERSION}.zip ../wzd/plugins/wazuh/build/wazuh-${OPENSEARCH_DASHBOARDS_VERSION}.zip ../wzd/plugins/wazuh-core/build/wazuhCore-${OPENSEARCH_DASHBOARDS_VERSION}.zip WORKDIR /home/node/wzd/dev-tools/build-packages/base RUN ./generate_base.sh -v 4.9.0 -r 1 -a file:///home/node/packages/wazuh-package.zip -s file:///home/node/packages/security-package.zip -b file:///home/node/packages/dashboard-package.zip +WORKDIR /home/node/wzd/dev-tools/build-packages/base/output +RUN cp ./* /home/node/packages/ FROM node:${NODE_VERSION}