-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathentrypoint.sh
More file actions
executable file
·89 lines (73 loc) · 2.72 KB
/
entrypoint.sh
File metadata and controls
executable file
·89 lines (73 loc) · 2.72 KB
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#!/bin/bash
set -e
# Signal handling for graceful shutdown
cleanup() {
echo "Received shutdown signal, cleaning up..."
# Send SIGTERM to all child processes
if [ -n "$MAIN_PID" ]; then
echo "Terminating main process (PID: $MAIN_PID)"
kill -TERM "$MAIN_PID" 2>/dev/null || true
wait "$MAIN_PID" 2>/dev/null || true
fi
echo "Cleanup completed"
exit 0
}
# Set up signal handlers
trap cleanup SIGTERM SIGINT
echo "=== AI DevTeam Starting ==="
echo "Container init process: tini (zombie process reaper enabled)"
echo "Node.js version: $(node --version)"
echo "npm version: $(npm --version)"
echo "Git version: $(git --version)"
# Check if GitHub CLI is available and configure authentication
if command -v gh &> /dev/null; then
echo "GitHub CLI version: $(gh --version | head -n1)"
# Configure GitHub CLI authentication using token
if [ ! -z "$GITHUB_TOKEN" ]; then
echo "Configuring GitHub CLI authentication..."
# Set the token as environment variable for gh CLI
export GH_TOKEN="$GITHUB_TOKEN"
# Test authentication without interactive login
if gh auth status >/dev/null 2>&1; then
echo "GitHub CLI authentication configured successfully"
else
echo "Warning: GitHub CLI authentication test failed, but token is set"
fi
else
echo "Warning: GITHUB_TOKEN not provided - GitHub CLI will not be authenticated"
fi
else
echo "Warning: GitHub CLI not found"
fi
# Check if Claude CLI is available
if command -v claude &> /dev/null; then
echo "Claude CLI is available"
else
echo "Warning: Claude CLI not found - will need manual installation or API integration"
fi
# Initialize git config if not set (using environment variables)
if [ ! -z "$GIT_USER_NAME" ]; then
git config --global user.name "$GIT_USER_NAME"
fi
if [ ! -z "$GIT_USER_EMAIL" ]; then
git config --global user.email "$GIT_USER_EMAIL"
fi
if [ ! -z "$GITHUB_TOKEN" ] && [ ! -z "$GIT_USER_NAME" ]; then
echo "https://$GIT_USER_NAME:$GITHUB_TOKEN@github.com" > ~/.git-credentials
git config --global credential.helper store
fi
# Set git to accept any host key (for automated cloning)
if [ ! -z "$GIT_ACCEPT_HOST_KEY" ] && [ "$GIT_ACCEPT_HOST_KEY" = "true" ]; then
git config --global core.sshCommand "ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no"
fi
echo "=== Configuration Complete ==="
echo "Starting application with PID tracking..."
# Execute the main application in background and track PID
"$@" &
MAIN_PID=$!
echo "Main application started (PID: $MAIN_PID)"
# Wait for the main process to complete
wait "$MAIN_PID"
EXIT_CODE=$?
echo "Main application exited with code: $EXIT_CODE"
exit $EXIT_CODE