diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000000000..36172e2b263aa --- /dev/null +++ b/.dockerignore @@ -0,0 +1,68 @@ +# build files +artifacts/ + +# intellij files +.idea/ +*.iml +*.ipr +*.iws +build-idea/ +out/ + +# include shared intellij config +!.idea/inspectionProfiles/Project_Default.xml +!.idea/runConfigurations/Debug_OpenSearch.xml +!.idea/vcs.xml + +# These files are generated in the main tree by annotation processors +benchmarks/src/main/generated/* +benchmarks/bin/* +benchmarks/build-eclipse-default/* +server/bin/* +server/build-eclipse-default/* +test/framework/build-eclipse-default/* + +# eclipse files +.project +.classpath +.settings +build-eclipse/ + +# netbeans files +nb-configuration.xml +nbactions.xml + +# gradle stuff +.gradle/ +build/ + +# vscode stuff +.vscode/ + +# testing stuff +**/.local* +.vagrant/ +/logs/ + +# osx stuff +.DS_Store + +# default folders in which the create_bwc_index.py expects to find old es versions in +/backwards +/dev-tools/backwards + +# needed in case docs build is run...maybe we can configure doc build to generate files under build? +html_docs + +# random old stuff that we should look at the necessity of... +/tmp/ +eclipse-build + +# projects using testfixtures +testfixtures_shared/ + +# These are generated from .ci/jobs.t +.ci/jobs/ + +# build files generated +doc-tools/missing-doclet/bin/ \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000000000..4bfbb9777772a --- /dev/null +++ b/Dockerfile @@ -0,0 +1,50 @@ +# ========= +# 1st approach +# ========= +# I ran the script from my host machine .It failed due to Javadoc not being +# installed in my machine +# ========= +# bash scripts/build.sh -v 2.11.0 -s false -p linux -a x64 -d rpm + + +# ========= +# 2nd approach +# ========= +# Use a Docker container. It worked and the rpm package was created +# ========= +# docker run -ti --rm \ +# -v .:/usr/share/opensearch \ +# -w /usr/share/opensearch \ +# eclipse-temurin:17 \ +# bash scripts/build.sh -v 2.11.0 -s false -p linux -a x64 -d rpm + + +# ========= +# 3rd approach +# ========= +# Dockerfile +# ========= +# docker build -t wazuh-indexer-builder:4.9.0 . +# docker run wazuh-indexer-builder:4.9.0 +# docker run wazuh-indexer-builder:4.9.0 -v 2.11.0 -s false -p linux -a x64 -d rpm +# docker run -v .:/usr/share/opensearch wazuh-indexer-builder:4.9.0 -v 2.11.0 -s false -p linux -a x64 -d rpm + +# mkdir wazuh-indexer-packages +# cd wazuh-indexer-packages +# docker run -v .:/usr/share/opensearch/artifacts wazuh-indexer-builder:4.9.0 + + +FROM eclipse-temurin:17 AS builder + +# USER 1000:1000 + +ENV JAVA_HOME=/opt/java/openjdk + +# Probably better to use a volume +COPY . /usr/share/opensearch + +WORKDIR /usr/share/opensearch + +CMD ["-v", "2.11.0", "-s", "false", "-p", "linux", "-a", "x64", "-d", "tar"] + +ENTRYPOINT [ "bash", "scripts/build.sh" ] diff --git a/scripts/docker.sh b/scripts/docker.sh new file mode 100644 index 0000000000000..8ac113d44da12 --- /dev/null +++ b/scripts/docker.sh @@ -0,0 +1,28 @@ +#!/bin/bash + +# Attaches the project as a volume to a JDK 17 container +# Requires Docker +# Script usage: bash scripts/docker.sh + +set -e + +# Check the script is being run from the root of the project +if [ ! -f "./scripts/docker.sh" ]; then + echo "Please run this script from the root of the project" + echo "Example: bash scripts/docker.sh" + exit 1 +fi + +# ==== +# Start the container +# ==== +run_docker() { + docker run -ti --rm \ + -v .:/usr/share/opensearch \ + -w /usr/share/opensearch \ + --name wi-dev \ + eclipse-temurin:17 \ + bash +} + +run_docker