Skip to content

Commit

Permalink
Update Docker shared volume path
Browse files Browse the repository at this point in the history
  • Loading branch information
QU3B1M committed Nov 26, 2024
1 parent dc6686f commit 1d1566c
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 23 deletions.
8 changes: 4 additions & 4 deletions docker/builder/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,6 @@ ENV PATH=$GRADLE_HOME/bin/$PATH
# Clean up APT when done
RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

# Create volume dir
RUN mkdir -p /artifacts
VOLUME /artifacts

# Create a non-root user and set up permissions
RUN useradd -ms /bin/bash indexer && mkdir -p /home/indexer && chown -R indexer:indexer /home/indexer

Expand All @@ -77,6 +73,10 @@ ADD entrypoint.sh /home/indexer/
# Change file permissions as root
RUN chmod +x /home/indexer/entrypoint.sh

# Create volume dir
RUN mkdir -p /home/indexer/artifacts
VOLUME /home/indexer/artifacts

# Switch to non-root user
USER indexer

Expand Down
38 changes: 19 additions & 19 deletions docker/builder/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ clone_repositories() {
echo "----------------------------------------"
echo "Cloning Repositories"
echo "----------------------------------------"
git clone --branch "$INDEXER_BRANCH" https://github.com/wazuh/wazuh-indexer --depth 1 /home/indexer/wazuh-indexer
git clone --branch "$INDEXER_PLUGINS_BRANCH" https://github.com/wazuh/wazuh-indexer-plugins --depth 1 /home/indexer/wazuh-indexer-plugins
git clone --branch "$INDEXER_REPORTING_BRANCH" https://github.com/wazuh/wazuh-indexer-reporting --depth 1 /home/indexer/wazuh-indexer-reporting
git clone --branch "$INDEXER_BRANCH" https://github.com/wazuh/wazuh-indexer --depth 1 ~/wazuh-indexer
git clone --branch "$INDEXER_PLUGINS_BRANCH" https://github.com/wazuh/wazuh-indexer-plugins --depth 1 ~/wazuh-indexer-plugins
git clone --branch "$INDEXER_REPORTING_BRANCH" https://github.com/wazuh/wazuh-indexer-reporting --depth 1 ~/wazuh-indexer-reporting
}

# Function to build wazuh-indexer-plugins
Expand All @@ -29,10 +29,10 @@ build_plugins() {
echo "----------------------------------------"
local version="$1"
local revision="$2"
cd /home/indexer/wazuh-indexer-plugins/plugins/setup
cd ~/wazuh-indexer-plugins/plugins/setup
echo "Building setup plugin..."
./gradlew build -Dversion="$version" -Drevision="$revision" --no-daemon
cd /home/indexer/wazuh-indexer-plugins/plugins/command-manager
cd ~/wazuh-indexer-plugins/plugins/command-manager
echo "Building command-manager plugin..."
./gradlew build -Dversion="$version" -Drevision="$revision" --no-daemon
}
Expand All @@ -44,7 +44,7 @@ build_reporting() {
echo "----------------------------------------"
local version="$1"
local revision="$2"
cd /home/indexer/wazuh-indexer-reporting
cd ~/wazuh-indexer-reporting
echo "Building reporting..."
./gradlew build -Dversion="$version" -Drevision="$revision" --no-daemon
}
Expand All @@ -56,13 +56,13 @@ copy_builds() {
echo "----------------------------------------"
local version="$1"
local revision="$2"
mkdir -p /home/indexer/wazuh-indexer/artifacts/plugins
mkdir -p ~/wazuh-indexer/artifacts/plugins
echo "Copying setup plugin..."
cp /home/indexer/wazuh-indexer-plugins/plugins/setup/build/distributions/wazuh-indexer-setup-"$version"."$revision".zip /home/indexer/wazuh-indexer/artifacts/plugins
cp ~/wazuh-indexer-plugins/plugins/setup/build/distributions/wazuh-indexer-setup-"$version"."$revision".zip ~/wazuh-indexer/artifacts/plugins
echo "Copying command-manager plugin..."
cp /home/indexer/wazuh-indexer-plugins/plugins/command-manager/build/distributions/wazuh-indexer-command-manager-"$version"."$revision".zip /home/indexer/wazuh-indexer/artifacts/plugins
cp ~/wazuh-indexer-plugins/plugins/command-manager/build/distributions/wazuh-indexer-command-manager-"$version"."$revision".zip ~/wazuh-indexer/artifacts/plugins
echo "Copying reporting..."
cp /home/indexer/wazuh-indexer-reporting/build/distributions/wazuh-indexer-reports-scheduler-"$version"."$revision".zip /home/indexer/wazuh-indexer/artifacts/plugins
cp ~/wazuh-indexer-reporting/build/distributions/wazuh-indexer-reports-scheduler-"$version"."$revision".zip ~/wazuh-indexer/artifacts/plugins
}

# Function for packaging process
Expand All @@ -80,10 +80,10 @@ package_artifacts() {
local package_min_name
local package_name

cd /home/indexer/wazuh-indexer
cd ~/wazuh-indexer

plugins_hash=$(cd /home/indexer/wazuh-indexer-plugins && git rev-parse --short HEAD)
reporting_hash=$(cd /home/indexer/wazuh-indexer-reporting && git rev-parse --short HEAD)
plugins_hash=$(cd ~/wazuh-indexer-plugins && git rev-parse --short HEAD)
reporting_hash=$(cd ~/wazuh-indexer-reporting && git rev-parse --short HEAD)

echo "Creating package minimum name..."
package_min_name=$(bash build-scripts/baptizer.sh -m \
Expand All @@ -108,19 +108,19 @@ package_artifacts() {
echo "Assembling package..."
bash build-scripts/assemble.sh -a "$architecture" -d "$distribution" -r "$revision"

mkdir -p /artifacts/dist/
mkdir -p ~/artifacts/
echo "Moving package to artifacts..."
mv /home/indexer/wazuh-indexer/artifacts/dist/"$package_name" /artifacts/
mv ~/wazuh-indexer/artifacts/dist/"$package_name" ~/artifacts/
}

# Function for cleanup
cleanup() {
echo "----------------------------------------"
echo "Cleaning Up"
echo "----------------------------------------"
rm -rf /home/indexer/wazuh-indexer
rm -rf /home/indexer/wazuh-indexer-plugins
rm -rf /home/indexer/wazuh-indexer-reporting
rm -rf ~/wazuh-indexer
rm -rf ~/wazuh-indexer-plugins
rm -rf ~/wazuh-indexer-reporting
echo "Cleanup completed."
}

Expand All @@ -129,7 +129,7 @@ main() {
echo "---------Starting Build Process---------"
clone_repositories
# Set version env var
VERSION=$(cat /home/indexer/wazuh-indexer/VERSION)
VERSION=$(cat ~/wazuh-indexer/VERSION)
# Build and assemble the package
build_plugins "$VERSION" "$REVISION"
build_reporting "$VERSION" "$REVISION"
Expand Down

0 comments on commit 1d1566c

Please sign in to comment.