-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathreload.sh
More file actions
executable file
·107 lines (90 loc) · 3.79 KB
/
Copy pathreload.sh
File metadata and controls
executable file
·107 lines (90 loc) · 3.79 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
#!/bin/bash
# ==============================================================================
# 🔄 Next.js Frontend Starter - Quick Reload Script
# ==============================================================================
# For full deployment with testing, use: ./deploy.sh
# This script is for quick reloads without full testing
# ==============================================================================
set -e
# Colors
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
CYAN='\033[0;36m'
NC='\033[0m'
# Function to prompt with timeout
prompt_with_timeout() {
local prompt_message=$1
local default_choice=$2
local timeout=$3
local user_input
read -t "$timeout" -p "$prompt_message" user_input || user_input="$default_choice"
echo "$user_input"
}
echo ""
echo -e "${CYAN}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
echo -e "${CYAN} 🔄 Next.js Frontend Starter - Quick Reload${NC}"
echo -e "${CYAN}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
echo ""
# Check if network exists, create if not
NETWORK_NAME="nextjs_frontend_network"
if ! docker network inspect "$NETWORK_NAME" &> /dev/null; then
echo -e "${YELLOW}Creating Docker network: $NETWORK_NAME${NC}"
docker network create "$NETWORK_NAME"
fi
# Ask for no-cache build
choice=$(prompt_with_timeout "Build with --no-cache? (y/N) [auto-skip in 5s]: " "n" 5)
echo ""
if [[ "$choice" =~ ^[Yy]([Ee][Ss])?$ ]]; then
echo -e "${BLUE}🔧 Building with --no-cache...${NC}"
docker compose build --no-cache
else
echo -e "${YELLOW}⏭ Skipping no-cache build...${NC}"
fi
# Ask to push to Docker Hub (only if build was selected)
if [[ "$choice" =~ ^[Yy]([Ee][Ss])?$ ]]; then
push_choice=$(prompt_with_timeout "Push to Docker Hub? (y/N) [auto-skip in 5s]: " "n" 5)
echo ""
if [[ "$push_choice" =~ ^[Yy]([Ee][Ss])?$ ]]; then
echo -e "${BLUE}📤 Pushing Docker images...${NC}"
docker compose push
else
echo -e "${YELLOW}⏭ Skipping Docker Hub push...${NC}"
fi
fi
# Bring down existing containers
echo -e "${BLUE}📦 Stopping containers...${NC}"
docker compose down --remove-orphans
# Start containers
echo -e "${BLUE}🚀 Starting containers...${NC}"
docker compose up -d
# Quick health check
echo ""
echo -e "${CYAN}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
echo -e "${CYAN} 📊 Container Status${NC}"
echo -e "${CYAN}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
echo ""
docker compose ps
echo ""
echo -e "${GREEN}✅ Reload complete!${NC}"
echo ""
echo -e "${YELLOW}Quick commands:${NC}"
echo -e " ./deploy.sh - Full deployment with testing"
echo -e " make logs - View all logs"
echo -e " make logs-app - View app logs only"
echo -e " make db-shell - Open PostgreSQL shell"
echo -e " docker compose logs -f - Follow all logs"
echo ""
echo -e "${CYAN}Access Points:${NC}"
echo -e " App: http://localhost:3000"
echo -e " pgAdmin: http://localhost:5050"
echo -e " Database: localhost:5432"
echo ""
# Ask to follow logs
log_choice=$(prompt_with_timeout "Follow logs? (y/N) [auto-skip in 3s]: " "n" 3)
echo ""
if [[ "$log_choice" =~ ^[Yy]([Ee][Ss])?$ ]]; then
echo -e "${BLUE}📜 Following logs... (Ctrl+C to exit)${NC}"
docker compose logs -f
fi