diff --git a/modules/Tiltfile b/modules/Tiltfile new file mode 100644 index 00000000..54962828 --- /dev/null +++ b/modules/Tiltfile @@ -0,0 +1,52 @@ +# Load env +load('ext://dotenv', 'dotenv') +dotenv(fn='modules/.env') + +# Load env variables +modules = os.getenv("COMPOSE_MODULES", "") +mode_of_operation = os.getenv("MODE_OF_OPERATION") +yaml_file_path = config.main_dir +print(yaml_file_path) + +if config.tilt_subcommand == "up": + # Tilt up + print("==================") + if not modules: + print("ERROR: NO MODULES FOUND") + exit() + else: + for module in modules.split(): + print(module) + print("==================") + + # Run Docker-compose + modules_list = [module for module in modules.split()] + print(modules_list) + + # Work with each compose file + compose_yaml_files = [] + + if mode_of_operation == "deploy" or not mode_of_operation: + for module in modules_list: + # Modify yaml + compose_yaml = read_yaml(module) + + # Test changing up the dictionary to check change compose state + # compose_yaml["services"].pop("py_producer") + # compose_yaml["services"].pop("py_transformer") + + print(compose_yaml) + + # Up the containers + docker_compose(encode_yaml(compose_yaml)) + + elif mode_of_operation == "develop": + print("In develop mode") + +# Tilt down: down ALL containers +if config.tilt_subcommand == "down": + print("Downing docker-compose...") + + # TODO: temp solution use project names, look for better strategy + local('docker compose -p modules down -v --remove-orphans') + exit() \ No newline at end of file diff --git a/watod b/watod index 0b5d1f87..49ab767c 100755 --- a/watod +++ b/watod @@ -24,14 +24,39 @@ function usage { exit 0 } +function tilt_up { + cd modules + echo "Runing tilt up with" $COMPOSE_MODULES + COMPOSE_MODULES=$COMPOSE_MODULES tilt up + cd .. +} + +function tilt_down { + cd modules + echo "Runing tilt down" + COMPOSE_MODULES=$COMPOSE_MODULES tilt down + cd .. +} + function run_compose { cd $MONO_DIR if [ ! -z "$(source $MODULES_DIR/.env && echo $ACTIVE_MODULES)" ] && [ -z "$MODULES" ]; then MODULES="$(source $MODULES_DIR/.env && printf -- " -f $MODULES_DIR/docker-compose.%s.yaml" ${ACTIVE_MODULES[@]})" fi - echo "Running docker compose ${MODULES[@]} $@" - DOCKER_BUILDKIT=${DOCKER_BUILDKIT:-1} docker compose ${MODULES[@]} "$@" + COMPOSE_MODULES="$(printf -- "$MODULES_DIR/docker-compose.%s.yaml " ${ACTIVE_MODULES[@]})" + echo Active Modules are: ${ACTIVE_MODULES[@]} + + echo "$@" + + #DOCKER_BUILDKIT=${DOCKER_BUILDKIT:-1} docker compose ${MODULES[@]} "$@" + if [ "$@" == 'up' ]; then + tilt_up + fi + + if [ "$@" == 'down' ]; then + tilt_down + fi } # in case you need help