forked from opensearch-project/OpenSearch-Dashboards
-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Dockerfile to obtain the necessary files locally (#391)
- Loading branch information
1 parent
71b85b8
commit 1627daa
Showing
10 changed files
with
243 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# Package building | ||
|
||
This folder contains the tools used to create packages from the different repositories necessary for the creation of deb and rpm packages. | ||
|
||
## Requirements | ||
|
||
- A system with Docker. | ||
- Internet connection (to download the docker images the first time). | ||
|
||
## How to build packages | ||
|
||
The script `run-docker-compose.sh` is in charge of coordinating the different steps to build each package. | ||
|
||
### Building packages | ||
|
||
The script can build a `.tar.gz` (former base), and `rpm` and `deb` packages. This can be for x64 and arm architectures (it is not cross-architecture building. You need to run the script in a machine of the same architecture that you are building). | ||
|
||
The inputs are the following: | ||
|
||
- `-a`, `--app`: Set the `wazuh-dashboard-plugins` branch. | ||
- `-b`, `--base`: Set the `wazuh-dashboard` branch. | ||
- `-s`, `--security`: Set the `wazuh-security-dashboards-plugin` branch. | ||
- `--node-version`: [Optional] Set the node version. | ||
- `--arm`: [Optional] Build for arm64 instead of x64. | ||
|
||
Example: | ||
|
||
```bash | ||
bash run-docker-compose.sh \ | ||
--app 4.10.2 \ | ||
--base 4.10.2 \ | ||
--security 4.10.2 \ | ||
--arm \ | ||
--node-version 18.19.0 | ||
``` | ||
|
||
This example will create a packages folder that inside will have the packages divided by repository of the 4.10.2 branch of each one. |
31 changes: 31 additions & 0 deletions
31
dev-tools/build-packages/base-packages-to-base/base-packages.Dockerfile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# Usage: | ||
# docker build \ | ||
# --build-arg NODE_VERSION=18.19.0 \ | ||
# --build-arg WAZUH_DASHBOARD_BRANCH=4.10.2 \ | ||
# --build-arg WAZUH_DASHBOARD_SECURITY_BRANCH=4.10.2 \ | ||
# --build-arg WAZUH_DASHBOARD_PLUGINS_BRANCH=4.10.2 \ | ||
# --build-arg ARCHITECTURE=arm \ | ||
# -t wazuh-packages-to-base:4.10.2 \ | ||
# -f base-packages.Dockerfile . | ||
|
||
ARG NODE_VERSION=18.19.0 | ||
FROM node:${NODE_VERSION} AS base | ||
ARG ARCHITECTURE='amd' | ||
ARG WAZUH_DASHBOARD_BRANCH | ||
ARG WAZUH_DASHBOARD_SECURITY_BRANCH | ||
ARG WAZUH_DASHBOARD_PLUGINS_BRANCH | ||
ENV OPENSEARCH_DASHBOARDS_VERSION=2.16.0 | ||
ENV ENV_ARCHITECTURE=${ARCHITECTURE} | ||
USER root | ||
RUN apt-get update && apt-get install -y jq | ||
USER node | ||
ADD ./clone-plugins.sh /home/node/clone-plugins.sh | ||
ADD ./repositories/wazuh-dashboard.sh /home/node/repositories/wazuh-dashboard.sh | ||
ADD ./repositories/plugins/wazuh-security-dashboards-plugin.sh /home/node/repositories/plugins/wazuh-security-dashboards-plugin.sh | ||
ADD ./repositories/plugins/wazuh-dashboard-plugins.sh /home/node/repositories/plugins/wazuh-dashboard-plugins.sh | ||
RUN bash /home/node/clone-plugins.sh | ||
|
||
FROM node:${NODE_VERSION} | ||
USER node | ||
COPY --chown=node:node --from=base /home/node/packages /home/node/packages | ||
WORKDIR /home/node/packages |
16 changes: 16 additions & 0 deletions
16
dev-tools/build-packages/base-packages-to-base/clone-plugins.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
base_path_plugins="/home/node/app/plugins" | ||
base_path_repositories_scripts="/home/node/repositories" | ||
base_path_repositories_plugins_scripts="/home/node/repositories/plugins" | ||
plugins=$(ls $base_path_repositories_plugins_scripts) | ||
|
||
mkdir /home/node/packages | ||
echo "Cloning Wazuh dashboards" | ||
source $base_path_repositories_scripts/wazuh-dashboard.sh | ||
|
||
for plugin in $plugins; do | ||
echo "Cloning $plugin" | ||
source $base_path_repositories_plugins_scripts/$plugin | ||
done | ||
|
||
|
||
|
22 changes: 22 additions & 0 deletions
22
dev-tools/build-packages/base-packages-to-base/docker-compose.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
|
||
services: | ||
base: | ||
image: base-${WAZUH_DASHBOARD_BRANCH}-${WAZUH_SECURITY_PLUGIN_BRANCH}-${WAZUH_DASHBOARD_PLUGINS_BRANCH}-${ARCHITECTURE} | ||
build: | ||
context: . | ||
dockerfile: base-packages.Dockerfile | ||
args: | ||
NODE_VERSION: ${NODE_VERSION} | ||
WAZUH_DASHBOARD_BRANCH: ${WAZUH_DASHBOARD_BRANCH} | ||
WAZUH_DASHBOARD_SECURITY_BRANCH: ${WAZUH_SECURITY_PLUGIN_BRANCH} | ||
WAZUH_DASHBOARD_PLUGINS_BRANCH: ${WAZUH_DASHBOARD_PLUGINS_BRANCH} | ||
ARCHITECTURE: ${ARCHITECTURE} | ||
container_name: base-${WAZUH_DASHBOARD_BRANCH}-${WAZUH_SECURITY_PLUGIN_BRANCH}-${WAZUH_DASHBOARD_PLUGINS_BRANCH}-${ARCHITECTURE} | ||
environment: | ||
OPENSEARCH_DASHBOARDS_VERSION: 2.16.0 | ||
volumes: | ||
- ./:/home/node/output | ||
command: > | ||
bash -c ' | ||
cp -r /home/node/packages /home/node/output | ||
' |
17 changes: 17 additions & 0 deletions
17
...ools/build-packages/base-packages-to-base/repositories/plugins/wazuh-dashboard-plugins.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
base_path_plugins="/home/node/app/plugins" | ||
cd $base_path_plugins | ||
git clone --depth 1 --branch ${WAZUH_DASHBOARD_PLUGINS_BRANCH} https://github.com/wazuh/wazuh-dashboard-plugins.git | ||
wazuh_dashboard_plugins=$(ls $base_path_plugins/wazuh-dashboard-plugins/plugins) | ||
mv wazuh-dashboard-plugins/plugins/* ./ | ||
mkdir /home/node/packages/wazuh-dashboard-plugins | ||
for wazuh_dashboard_plugin in $wazuh_dashboard_plugins; do | ||
cd $base_path_plugins/$wazuh_dashboard_plugin | ||
yarn install | ||
echo "Building $wazuh_dashboard_plugin" | ||
yarn build | ||
echo "Copying $wazuh_dashboard_plugin" | ||
package_name=$(jq -r '.id' ./opensearch_dashboards.json) | ||
cp $base_path_plugins/$wazuh_dashboard_plugin/build/$package_name-$OPENSEARCH_DASHBOARDS_VERSION.zip /home/node/packages/wazuh-dashboard-plugins/$package_name-$OPENSEARCH_DASHBOARDS_VERSION.zip | ||
done | ||
cd $base_path_plugins | ||
rm -rf wazuh-dashboard-plugins |
10 changes: 10 additions & 0 deletions
10
...d-packages/base-packages-to-base/repositories/plugins/wazuh-security-dashboards-plugin.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# Clone the Wazuh security plugin | ||
cd /home/node/app/plugins | ||
git clone --depth 1 --branch ${WAZUH_DASHBOARD_SECURITY_BRANCH} https://github.com/wazuh/wazuh-security-dashboards-plugin.git | ||
cd wazuh-security-dashboards-plugin | ||
yarn install | ||
echo "Building Wazuh security plugin" | ||
yarn build | ||
echo "Copying Wazuh security plugin" | ||
mkdir /home/node/packages/wazuh-security-dashboards-plugin | ||
cp -r build/* /home/node/packages/wazuh-security-dashboards-plugin |
13 changes: 13 additions & 0 deletions
13
dev-tools/build-packages/base-packages-to-base/repositories/wazuh-dashboard.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
git clone --depth 1 --branch ${WAZUH_DASHBOARD_BRANCH} https://github.com/wazuh/wazuh-dashboard.git /home/node/app | ||
cd /home/node/app | ||
yarn osd bootstrap --production | ||
echo "Building Wazuh dashboards" | ||
if [ $ENV_ARCHITECTURE == "arm" ]; then | ||
yarn build-platform --linux-arm --skip-os-packages --release | ||
else | ||
yarn build-platform --linux --skip-os-packages --release | ||
fi | ||
mkdir /home/node/packages/wazuh-dashboard | ||
echo "Copying Wazuh dashboards" | ||
ls -la /home/node/app/target | ||
cp -r /home/node/app/target/*.tar.gz /home/node/packages/wazuh-dashboard |
94 changes: 94 additions & 0 deletions
94
dev-tools/build-packages/base-packages-to-base/run-docker-compose.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
#!/bin/bash | ||
|
||
export WAZUH_DASHBOARD_PLUGINS_BRANCH="" | ||
export WAZUH_DASHBOARD_BRANCH="" | ||
export WAZUH_SECURITY_PLUGIN_BRANCH="" | ||
export ARCHITECTURE="amd" | ||
export NODE_VERSION="18.19.0" | ||
|
||
|
||
run_docker_compose() { | ||
echo "WAZUH_DASHBOARD_PLUGINS_BRANCH: $WAZUH_DASHBOARD_PLUGINS_BRANCH" | ||
echo "WAZUH_SECURITY_PLUGIN_BRANCH: $WAZUH_SECURITY_PLUGIN_BRANCH" | ||
echo "WAZUH_DASHBOARD_BRANCH: $WAZUH_DASHBOARD_BRANCH" | ||
echo "ARCHITECTURE: $ARCHITECTURE" | ||
echo "NODE_VERSION: $NODE_VERSION" | ||
docker-compose up -d | ||
} | ||
|
||
help() { | ||
echo | ||
echo "Usage: $0 [OPTIONS]" | ||
echo " -a, --app <url/path> Set the Wazuh plugin branch." | ||
echo " -b, --base <url/path> Set the wazuh-dashboard branch." | ||
echo " -s, --security <url/path> Set the wazuh-security-dashboards-plugin branch." | ||
echo " --arm [Optional] Build for arm64 instead of x64." | ||
echo " --node-version <version> [Optional] Set the node version." | ||
echo " -h, --help Show this help." | ||
echo | ||
exit $1 | ||
} | ||
|
||
# ----------------------------------------------------------------------------- | ||
|
||
main() { | ||
while [ -n "${1}" ]; do | ||
case "${1}" in | ||
"-h" | "--help") | ||
help 0 | ||
;; | ||
"-a" | "--app") | ||
if [ -n "$2" ]; then | ||
WAZUH_DASHBOARD_PLUGINS_BRANCH="$2" | ||
shift 2 | ||
else | ||
help 1 | ||
fi | ||
;; | ||
"-s" | "--security") | ||
if [ -n "${2}" ]; then | ||
WAZUH_SECURITY_PLUGIN_BRANCH="${2}" | ||
shift 2 | ||
else | ||
help 0 | ||
fi | ||
;; | ||
"-b" | "--base") | ||
if [ -n "${2}" ]; then | ||
WAZUH_DASHBOARD_BRANCH="${2}" | ||
shift 2 | ||
else | ||
help 0 | ||
fi | ||
;; | ||
"--arm") | ||
ARCHITECTURE="arm" | ||
shift 1 | ||
;; | ||
"--node-version") | ||
if [ -n "${2}" ]; then | ||
NODE_VERSION="${2}" | ||
shift 2 | ||
else | ||
help 0 | ||
fi | ||
;; | ||
*) | ||
echo "help" | ||
|
||
help 1 | ||
;; | ||
esac | ||
done | ||
|
||
if [ -z "$WAZUH_DASHBOARD_PLUGINS_BRANCH" ] | [ -z "$WAZUH_DASHBOARD_BRANCH" ] | [ -z "$WAZUH_SECURITY_PLUGIN_BRANCH" ]; then | ||
echo "You must specify the app, base, security." | ||
help 1 | ||
fi | ||
|
||
run_docker_compose || exit 1 | ||
|
||
exit 0 | ||
} | ||
|
||
main "$@" |
This file was deleted.
Oops, something went wrong.