forked from opensearch-project/OpenSearch
-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add script to execute the ECS generator tool
- Loading branch information
Showing
2 changed files
with
54 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
#!/bin/bash | ||
|
||
# Run the ECS generator tool container. | ||
# Requirements: | ||
# - Docker | ||
# - Docker Compose | ||
|
||
set -e | ||
|
||
# The container is built only if needed, the tool can be executed several times | ||
# for different modules in the same build since the script runs as entrypoint | ||
|
||
# ==== | ||
# Checks that the script is run from the intended location | ||
# ==== | ||
function check_project_root_folder() { | ||
current=$(basename "$(pwd)") | ||
|
||
if [[ "$0" != "./ecs.sh" && "$0" != "ecs.sh" ]]; then | ||
echo "Run the script from its location" | ||
usage | ||
exit 1 | ||
fi | ||
# Change working directory to the root of the repository | ||
cd ../.. | ||
} | ||
|
||
function main() { | ||
export REPO_PATH="$2" | ||
export ECS_MODULE="$3" | ||
local compose_filename="docker/${current}/ecs.yml" | ||
local compose_cmd="docker compose run -f $compose_filename" | ||
|
||
case $1 in | ||
up) | ||
# Main folder created here to grant access to both containers | ||
mkdir -p artifacts | ||
$compose_cmd up -d | ||
;; | ||
down) | ||
$compose_cmd down | ||
;; | ||
stop) | ||
$compose_cmd stop | ||
;; | ||
*) | ||
usage | ||
exit 1 | ||
;; | ||
esac | ||
} | ||
|
||
main "$@" |
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 |
---|---|---|
|
@@ -8,4 +8,4 @@ services: | |
volumes: | ||
- ${REPO_PATH}/ecs:/source/ecs | ||
environment: | ||
- ECS_MODULE=alerts | ||
- ECS_MODULE=${ECS_MODULE} |