-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathdocker-start.sh
More file actions
executable file
·97 lines (85 loc) · 2.23 KB
/
docker-start.sh
File metadata and controls
executable file
·97 lines (85 loc) · 2.23 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
#!/bin/bash
# Start Template Doctor in Docker containers
# Usage: ./docker-start.sh [--build] [--logs]
set -e
cd "$(dirname "$0")"
# Colors for output
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
RED='\033[0;31m'
NC='\033[0m' # No Color
echo -e "${GREEN}🐳 Template Doctor - Docker Startup${NC}"
echo
# Check if .env exists
if [ ! -f .env ]; then
echo -e "${RED}❌ Error: .env file not found${NC}"
echo "Please create a .env file with your configuration."
echo "You can copy .env.example as a starting point."
exit 1
fi
# Build the server first (needed for Docker)
echo -e "${YELLOW}📦 Building Express server...${NC}"
cd packages/server
npm run build
cd ../..
echo -e "${GREEN}✅ Server built${NC}"
echo
# Build the frontend (needed for Docker)
echo -e "${YELLOW}📦 Building frontend app...${NC}"
cd packages/app
npm run build
cd ../..
echo -e "${GREEN}✅ Frontend built${NC}"
echo
# Parse arguments
BUILD_FLAG=""
LOGS_FLAG=""
while [[ $# -gt 0 ]]; do
case $1 in
--build)
BUILD_FLAG="--build"
shift
;;
--logs)
LOGS_FLAG="--follow"
shift
;;
*)
echo "Unknown option: $1"
echo "Usage: $0 [--build] [--logs]"
exit 1
;;
esac
done
# Start containers
if [ -n "$BUILD_FLAG" ]; then
echo -e "${YELLOW}🔨 Building and starting containers...${NC}"
docker-compose up -d --build
else
echo -e "${YELLOW}🚀 Starting containers...${NC}"
docker-compose up -d
fi
echo
echo -e "${GREEN}✅ Containers started!${NC}"
echo
echo "Services:"
echo -e " ${GREEN}🖥️ Frontend:${NC} http://localhost:4000"
echo -e " ${GREEN}⚙️ Backend:${NC} http://localhost:3001"
echo -e " ${GREEN}❤️ Health:${NC} http://localhost:3001/api/health"
echo
echo "Commands:"
echo " View logs: docker-compose logs -f"
echo " Stop: docker-compose down"
echo " Restart: docker-compose restart"
echo " Rebuild: ./docker-start.sh --build"
echo
# Show logs if requested
if [ -n "$LOGS_FLAG" ]; then
echo -e "${YELLOW}📋 Showing logs (Ctrl+C to exit)...${NC}"
echo
docker-compose logs -f
else
echo "Checking container health..."
sleep 3
docker-compose ps
fi