Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
11 changes: 6 additions & 5 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,24 +20,25 @@ echo "🏗️ Building setup container..."
docker build -f Dockerfile.setup -t snapshotter-lite-setup:latest .

# Create a temporary file to capture the env file path from setup
SETUP_RESULT_FILE=$(mktemp)
SETUP_RESULT_DIR=$(mktemp -d "$(pwd)/setup_result.XXXXXX")
SETUP_RESULT_FILE="$SETUP_RESULT_DIR/setup_result"

# Run setup container directly
echo "🔧 Running setup container to configure environment..."
docker run --rm -it \
-v "$(pwd):/app" \
-v "$SETUP_RESULT_FILE:/tmp/setup_result" \
-v "$SETUP_RESULT_DIR:/tmp/setup_result_dir" \
-w /app \
snapshotter-lite-setup:latest \
bash -c "./configure-environment.sh $SETUP_ARGS --docker-mode"
bash -c "./configure-environment.sh $SETUP_ARGS --docker-mode --result-file /tmp/setup_result_dir/setup_result"

# Remove the setup container image
docker rmi snapshotter-lite-setup:latest

# Check if setup was successful by reading the result file
if [ -f "$SETUP_RESULT_FILE" ] && [ -s "$SETUP_RESULT_FILE" ]; then
SELECTED_ENV_FILE=$(cat "$SETUP_RESULT_FILE")
rm -f "$SETUP_RESULT_FILE"
rm -rf "$SETUP_RESULT_DIR"

if [ -n "$SELECTED_ENV_FILE" ] && [ -f "$SELECTED_ENV_FILE" ]; then
echo "ℹ️ Setup container configured: $SELECTED_ENV_FILE"
Expand All @@ -49,7 +50,7 @@ if [ -f "$SETUP_RESULT_FILE" ] && [ -s "$SETUP_RESULT_FILE" ]; then
fi
else
echo "❌ Setup container did not complete successfully or failed to report results."
rm -f "$SETUP_RESULT_FILE"
rm -rf "$SETUP_RESULT_DIR"
exit 1
fi

Expand Down
12 changes: 9 additions & 3 deletions configure-environment.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ NO_COLLECTOR=false
OVERRIDE_DEFAULTS_SCRIPT_FLAG=false
DEVNET_MODE=false
DOCKER_MODE=false
RESULT_FILE=""

# GitHub configuration URL
MARKETS_CONFIG_URL="https://raw.githubusercontent.com/powerloom/curated-datamarkets/main/sources.json"
Expand Down Expand Up @@ -425,6 +426,10 @@ parse_arguments() {
DOCKER_MODE=true
shift
;;
--result-file)
RESULT_FILE=$2
shift 2
;;
*)
shift
;;
Expand Down Expand Up @@ -862,6 +867,7 @@ set_default_optional_variables() {
"STREAM_WRITE_TIMEOUT_MS:5000"
"MAX_WRITE_RETRIES:3"
"MAX_CONCURRENT_WRITES:4"
"TELEGRAM_MESSAGE_THREAD_ID:<telegram-thread-id>"
)

for var_def in "${optional_vars[@]}"; do
Expand Down Expand Up @@ -956,9 +962,9 @@ main() {
if [ "$SETUP_COMPLETE" = true ]; then
echo "✅ Configuration complete. Environment file ready at $ENV_FILE_PATH"

# Write the env file path to the result file for the build script (if result file exists)
if [ -n "$ENV_FILE_PATH" ] && [ -w "/tmp/setup_result" ] 2>/dev/null; then
echo "$ENV_FILE_PATH" > /tmp/setup_result
# Write the env file path to the result file for the build script
if [ -n "$RESULT_FILE" ]; then
echo "$ENV_FILE_PATH" > "$RESULT_FILE"
echo "🔗 Reported env file to build script: $ENV_FILE_PATH"
fi
else
Expand Down