-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathbuild.sh
executable file
·75 lines (65 loc) · 2.28 KB
/
build.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#!/bin/bash
# Run configuration
source ./configure-environment.sh "$@"
if [ $? -ne 0 ]; then
echo "❌ Configuration failed"
exit 1
fi
# Source the environment file
source ".env-${FULL_NAMESPACE}"
# Set image tag based on git branch
GIT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
if [ "$GIT_BRANCH" = "dockerify" ]; then
export IMAGE_TAG="dockerify"
else
export IMAGE_TAG="latest"
fi
echo "🏗️ Building image with tag ${IMAGE_TAG}"
# Run collector test
if [ "$NO_COLLECTOR" = "true" ]; then
echo "🤔 Skipping collector check (--no-collector flag)"
COLLECTOR_PROFILE_STRING=""
else
./collector_test.sh --env-file ".env-${FULL_NAMESPACE}"
test_result=$?
if [ $test_result -eq 101 ]; then
echo "ℹ️ Starting new collector instance"
COLLECTOR_PROFILE_STRING="--profile local-collector"
elif [ $test_result -eq 100 ]; then
echo "✅ Using existing collector instance"
COLLECTOR_PROFILE_STRING=""
else
echo "❌ Collector check failed (exit code: $test_result)"
exit 1
fi
fi
# Create lowercase versions of namespace variables
PROJECT_NAME="snapshotter-lite-v2-${SLOT_ID}-${FULL_NAMESPACE}"
PROJECT_NAME_LOWER=$(echo "$PROJECT_NAME" | tr '[:upper:]' '[:lower:]')
FULL_NAMESPACE_LOWER=$(echo "$FULL_NAMESPACE" | tr '[:upper:]' '[:lower:]')
export CRON_RESTART=${CRON_RESTART:-false}
# Export the lowercase version for docker-compose
export FULL_NAMESPACE_LOWER
# Check if running in Windows Subsystem for Linux (WSL)
check_wsl() {
if grep -qi microsoft /proc/version; then
echo "🐧🪆 Running in WSL environment"
return 0 # true in shell
fi
return 1 # false in shell
}
# Configure Docker Compose profiles based on WSL environment
if check_wsl; then
# WSL environment - disable autoheal
COMPOSE_PROFILES="${COLLECTOR_PROFILE_STRING}"
export AUTOHEAL_LABEL=""
else
# Non-WSL environment - enable autoheal
COMPOSE_PROFILES="${COLLECTOR_PROFILE_STRING} --profile autoheal"
export AUTOHEAL_LABEL="autoheal-${SLOT_ID}-${FULL_NAMESPACE}=true"
fi
# Modify the deploy-services call to use the profiles
./deploy-services.sh --env-file ".env-${FULL_NAMESPACE}" \
--project-name "$PROJECT_NAME_LOWER" \
--collector-profile "$COMPOSE_PROFILES" \
--image-tag "$IMAGE_TAG"