-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdeploy.sh
More file actions
95 lines (73 loc) · 2.3 KB
/
Copy pathdeploy.sh
File metadata and controls
95 lines (73 loc) · 2.3 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
#!/bin/bash
# =============================================================================
# Payment Engine - Deployment Script
# =============================================================================
# Usage:
# First time: ./deploy.sh setup
# Deploy: ./deploy.sh deploy
# SSL: ./deploy.sh ssl yourdomain.com
# Logs: ./deploy.sh logs
# Status: ./deploy.sh status
# =============================================================================
set -e
COMPOSE_FILE="docker-compose.yml"
COMPOSE_PROD="docker-compose.prod.yml"
case "$1" in
setup)
echo "=== Setting up Payment Engine ==="
# Create .env if not exists
if [ ! -f .env ]; then
cp .env.example .env
echo "Created .env file - EDIT IT WITH YOUR VALUES!"
exit 1
fi
# Create nginx directories
mkdir -p backend/nginx/ssl backend/nginx/certbot
# Build and start
docker compose -f $COMPOSE_FILE up -d --build
echo "=== Setup complete! ==="
echo "API running at http://localhost:3500"
;;
deploy)
echo "=== Deploying Payment Engine ==="
# Pull latest changes
git pull origin main
# Rebuild and restart
docker compose -f $COMPOSE_FILE -f $COMPOSE_PROD up -d --build
echo "=== Deployment complete! ==="
;;
ssl)
DOMAIN=$2
if [ -z "$DOMAIN" ]; then
echo "Usage: ./deploy.sh ssl yourdomain.com"
exit 1
fi
echo "=== Setting up SSL for $DOMAIN ==="
# Get certificate
docker compose -f $COMPOSE_FILE -f $COMPOSE_PROD run --rm certbot \
certonly --webroot --webroot-path=/var/www/certbot \
--email admin@$DOMAIN --agree-tos --no-eff-email \
-d $DOMAIN
# Update nginx config
sed -i "s/yourdomain.com/$DOMAIN/g" backend/nginx/nginx.conf
# Reload nginx
docker compose -f $COMPOSE_FILE -f $COMPOSE_PROD exec nginx nginx -s reload
echo "=== SSL setup complete for $DOMAIN ==="
;;
logs)
docker compose -f $COMPOSE_FILE logs -f payment-engine
;;
status)
docker compose -f $COMPOSE_FILE ps
;;
stop)
docker compose -f $COMPOSE_FILE -f $COMPOSE_PROD down
;;
restart)
docker compose -f $COMPOSE_FILE -f $COMPOSE_PROD restart payment-engine
;;
*)
echo "Usage: ./deploy.sh {setup|deploy|ssl|logs|status|stop|restart}"
exit 1
;;
esac