Skip to content

Commit

Permalink
Add very basic Docker environment
Browse files Browse the repository at this point in the history
That will do for now
  • Loading branch information
AlexRuiz7 committed Nov 24, 2023
1 parent 458b4cf commit 93a0e31
Show file tree
Hide file tree
Showing 3 changed files with 146 additions and 0 deletions.
68 changes: 68 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -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/
50 changes: 50 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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" ]
28 changes: 28 additions & 0 deletions scripts/docker.sh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 93a0e31

Please sign in to comment.