Skip to content

Commit

Permalink
Add compose and script
Browse files Browse the repository at this point in the history
  • Loading branch information
f-galland committed Nov 28, 2024
1 parent dd08f88 commit b277058
Show file tree
Hide file tree
Showing 2 changed files with 91 additions and 0 deletions.
62 changes: 62 additions & 0 deletions docker/builder/builder.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
#!/bin/bash

# Start container with required tools to build packages
# Requires Docker
# Script usage: bash ./builder.sh

set -e

# ====
# Checks that the script is run from the intended location
# ====
function check_project_root_folder() {
current=$(basename "$(pwd)")

if [[ "$0" != "./builder.sh" && "$0" != "builder.sh" ]]; then
echo "Run the script from its location"
usage
exit 1
fi
# Change working directory to the root of the repository
cd ../..
}

# ====
# Displays usage
# ====
function usage() {
echo "Usage: ./builder.sh {up|down|stop}"
}

# ====
# Main function
# ====
function main() {
check_project_root_folder "$@"
compose_file="docker/${current}/compose.yml"
compose_cmd="docker compose -f $compose_file"
REPO_PATH=$(pwd)
VERSION=$(cat VERSION)
export REPO_PATH
export VERSION

case $1 in
up)
# Main folder created here to grant access to both containers
mkdir -p artifacts
$compose_cmd up -d --build
;;
down)
$compose_cmd down -v
;;
stop)
$compose_cmd stop
;;
*)
usage
exit 1
;;
esac
}

main "$@"
29 changes: 29 additions & 0 deletions docker/builder/compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
services:

wazuh-indexer-builder:
image: wazuh-indexer-builder:${VERSION}
container_name: wazuh-indexer-builder_${VERSION}
build:
context: ./../..
dockerfile: ${REPO_PATH}/docker/builder/Dockerfile
volumes:
- ${REPO_PATH}:/home/wazuh-indexer
#entrypoint: ["/bin/bash", "/home/wazuh-indexer/entrypoint.sh"]
entrypoint: ["tail", "-f", "/dev/null"]
user: "1000:1000"
working_dir: /home/wazuh-indexer

# wi-assemble:
# image: wi-assemble:${VERSION}
# container_name: wi-assemble_${VERSION}
# build:
# context: ./../..
# dockerfile: ${REPO_PATH}/docker/builder/Dockerfile
# volumes:
# - ${REPO_PATH}/build-scripts:/home/wazuh-indexer/build-scripts
# - ${REPO_PATH}/artifacts:/home/wazuh-indexer/artifacts
# - ${REPO_PATH}/distribution/packages/src:/home/wazuh-indexer/distribution/packages/src
# - ${REPO_PATH}/buildSrc:/home/wazuh-indexer/buildSrc
# entrypoint: ["tail", "-f", "/dev/null"]
# user: "1000:1000"
# working_dir: /home/wazuh-indexer

0 comments on commit b277058

Please sign in to comment.