Skip to content

Commit

Permalink
Add script to execute the ECS generator tool
Browse files Browse the repository at this point in the history
  • Loading branch information
QU3B1M committed Dec 12, 2024
1 parent 76fade9 commit 368315d
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 1 deletion.
53 changes: 53 additions & 0 deletions docker/ecs/ecs.sh
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 "$@"
2 changes: 1 addition & 1 deletion docker/ecs/ecs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ services:
volumes:
- ${REPO_PATH}/ecs:/source/ecs
environment:
- ECS_MODULE=alerts
- ECS_MODULE=${ECS_MODULE}

0 comments on commit 368315d

Please sign in to comment.