-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathdocker-run.sh
More file actions
executable file
·126 lines (107 loc) · 2.75 KB
/
Copy pathdocker-run.sh
File metadata and controls
executable file
·126 lines (107 loc) · 2.75 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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
#!/usr/bin/env bash
# ============================================================
# docker-run.sh — Helper script for Docker operations
# Usage: ./docker-run.sh [command]
# ============================================================
set -e
COMPOSE="docker compose"
SVC="app"
case "$1" in
# ---------------------
# Environment setup
# ---------------------
setup)
echo "→ Copying .env.example to .env..."
cp -n .env.example .env || true
echo "→ Building image..."
$COMPOSE build --no-cache
echo "→ Starting container..."
$COMPOSE up -d
echo "→ Waiting for services to be ready..."
sleep 10
echo "→ Running migrations..."
$COMPOSE exec $SVC php artisan migrate --force --seed
echo "✓ Setup complete! App is running at http://localhost"
;;
# ---------------------
# Start
# ---------------------
up)
$COMPOSE up -d
;;
# ---------------------
# Stop
# ---------------------
down)
$COMPOSE down
;;
# ---------------------
# Rebuild image
# ---------------------
build)
$COMPOSE build "${@:2}"
;;
# ---------------------
# Artisan commands
# ---------------------
artisan)
$COMPOSE exec $SVC php artisan "${@:2}"
;;
# ---------------------
# Composer commands
# ---------------------
composer)
$COMPOSE exec $SVC composer "${@:2}"
;;
# ---------------------
# Shell
# ---------------------
shell)
$COMPOSE exec $SVC sh
;;
# ---------------------
# Logs
# ---------------------
logs)
$COMPOSE logs -f "${@:2}"
;;
# ---------------------
# Tests
# ---------------------
test)
$COMPOSE exec $SVC php artisan test --compact "${@:2}"
;;
# ---------------------
# PHP Pint
# ---------------------
pint)
$COMPOSE exec $SVC vendor/bin/pint "${@:2}"
;;
# ---------------------
# Full reset (remove volumes)
# ---------------------
reset)
echo "⚠ This will destroy all data. Press Ctrl+C to cancel..."
sleep 3
$COMPOSE down -v
echo "✓ Container and volumes removed."
;;
*)
echo "WebTopup Docker Helper"
echo ""
echo "Usage: ./docker-run.sh <command>"
echo ""
echo "Commands:"
echo " setup First-time setup (copy .env, build, migrate)"
echo " up Start container"
echo " down Stop container"
echo " build Rebuild Docker image"
echo " artisan Run php artisan commands"
echo " composer Run composer commands"
echo " shell Open shell inside container"
echo " logs Tail container logs"
echo " test Run Pest tests"
echo " pint Run PHP Pint linter"
echo " reset Remove container and all volumes (destructive!)"
;;
esac