-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-test.sh
More file actions
executable file
·99 lines (86 loc) · 2.01 KB
/
docker-test.sh
File metadata and controls
executable file
·99 lines (86 loc) · 2.01 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
90
91
92
93
94
95
96
97
98
99
#!/usr/bin/env bash
# Docker testing helper for chezmoi dotfiles
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
cd "$SCRIPT_DIR"
usage() {
cat <<EOF
Usage: $0 <command>
Commands:
build Build the dotfiles container
run Build and run interactive shell
test Build and run chezmoi verify
clean Remove container and image
shell Run shell in existing container
logs Show build logs
Examples:
$0 build # Build the container
$0 run # Build and start interactive fish shell
$0 test # Quick verification test
$0 clean # Clean up everything
EOF
}
build() {
echo "🔨 Building dotfiles container..."
docker compose build
}
run_interactive() {
echo "🚀 Starting interactive dotfiles container..."
build
docker compose run --rm dotfiles
}
test_dotfiles() {
echo "🧪 Testing dotfiles installation..."
build
docker compose run --rm dotfiles fish -c "
echo '=== Chezmoi Status ==='
chezmoi verify
echo ''
echo '=== Fish Shell ==='
fish --version
echo ''
echo '=== Git Config ==='
git config --global --list | head -5 || echo 'No git config found'
"
}
clean() {
echo "🧹 Cleaning up containers and images..."
docker compose down --rmi all --volumes --remove-orphans
}
shell() {
echo "🐚 Opening shell in dotfiles container..."
docker compose exec dotfiles fish
}
logs() {
echo "📋 Showing container logs..."
docker compose logs --tail=50 dotfiles
}
case "${1:-}" in
build)
build
;;
run)
run_interactive
;;
test)
test_dotfiles
;;
clean)
clean
;;
shell)
shell
;;
logs)
logs
;;
-h|--help|help)
usage
;;
*)
echo "Error: Unknown command '${1:-}'"
echo ""
usage
exit 1
;;
esac