Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hepromark/tilt #99

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 52 additions & 0 deletions modules/Tiltfile
Original file line number Diff line number Diff line change
@@ -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()
29 changes: 27 additions & 2 deletions watod
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,39 @@ function usage {
exit 0
}

function tilt_up {
cd modules
echo "Runing tilt up with" $COMPOSE_MODULES
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

running

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
Expand Down
Loading