-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeploy.sh
More file actions
executable file
·107 lines (90 loc) · 2.46 KB
/
deploy.sh
File metadata and controls
executable file
·107 lines (90 loc) · 2.46 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
#
# Postgresus Quick Deploy Script
# Usage: ./deploy.sh [start|stop|restart|logs|status|update|backup]
#
set -e
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
COMPOSE_FILE="$SCRIPT_DIR/docker-compose.yml"
# Colors
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m'
log_info() { echo -e "${GREEN}[INFO]${NC} $1"; }
log_warn() { echo -e "${YELLOW}[WARN]${NC} $1"; }
log_error() { echo -e "${RED}[ERROR]${NC} $1"; }
check_docker() {
if ! command -v docker &> /dev/null; then
log_error "Docker is not installed. Please install Docker first."
exit 1
fi
if ! docker info &> /dev/null; then
log_error "Docker daemon is not running or you don't have permissions."
log_info "Try: sudo usermod -aG docker \$USER && newgrp docker"
exit 1
fi
}
start() {
log_info "Starting Postgresus..."
docker compose -f "$COMPOSE_FILE" up -d
log_info "Waiting for startup..."
sleep 5
status
log_info "Postgresus is available at: https://$(hostname -I | awk '{print $1}')"
}
stop() {
log_info "Stopping Postgresus..."
docker compose -f "$COMPOSE_FILE" down
log_info "Stopped."
}
restart() {
stop
start
}
logs() {
docker compose -f "$COMPOSE_FILE" logs -f
}
status() {
log_info "Container status:"
docker compose -f "$COMPOSE_FILE" ps
echo ""
log_info "Health check:"
if curl -sk https://localhost/health > /dev/null 2>&1; then
echo -e "${GREEN}✓ Postgresus is healthy${NC}"
else
echo -e "${RED}✗ Postgresus is not responding${NC}"
fi
}
update() {
log_info "Updating Postgresus..."
docker compose -f "$COMPOSE_FILE" pull
docker compose -f "$COMPOSE_FILE" up -d
log_info "Update complete."
status
}
backup() {
BACKUP_FILE="postgresus-backup-$(date +%Y%m%d-%H%M%S).tar.gz"
log_info "Creating backup: $BACKUP_FILE"
docker compose -f "$COMPOSE_FILE" stop
docker run --rm \
-v postgresus-data:/data \
-v "$(pwd)":/backup \
alpine tar czvf "/backup/$BACKUP_FILE" /data
docker compose -f "$COMPOSE_FILE" start
log_info "Backup created: $(pwd)/$BACKUP_FILE"
}
check_docker
case "${1:-start}" in
start) start ;;
stop) stop ;;
restart) restart ;;
logs) logs ;;
status) status ;;
update) update ;;
backup) backup ;;
*)
echo "Usage: $0 {start|stop|restart|logs|status|update|backup}"
exit 1
;;
esac