forked from GeneBO98/tradetally
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathquick-deploy.sh
More file actions
executable file
·99 lines (81 loc) · 3.41 KB
/
quick-deploy.sh
File metadata and controls
executable file
·99 lines (81 loc) · 3.41 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
#!/bin/bash
echo "[DEPLOY] TradeTally Quick Deploy Script"
echo "=================================="
# Check if Docker is installed
if ! command -v docker &> /dev/null; then
echo "[ERROR] Docker is not installed. Please install Docker first."
echo "Visit: https://docs.docker.com/get-docker/"
exit 1
fi
# Check if Docker Compose is installed
if ! command -v docker-compose &> /dev/null; then
echo "[ERROR] Docker Compose is not installed. Please install Docker Compose first."
echo "Visit: https://docs.docker.com/compose/install/"
exit 1
fi
echo "[OK] Docker is installed"
# Create deployment directory
DEPLOY_DIR="tradetally-deployment"
if [ -d "$DEPLOY_DIR" ]; then
echo "[INFO] Directory $DEPLOY_DIR already exists. Using existing directory."
cd "$DEPLOY_DIR"
else
echo "[INFO] Creating deployment directory: $DEPLOY_DIR"
mkdir "$DEPLOY_DIR"
cd "$DEPLOY_DIR"
fi
# Download required files
echo "[INFO] Downloading deployment files..."
curl -s -o docker-compose.yml https://raw.githubusercontent.com/YOUR_USERNAME/trader-vue/main/docker-compose.production.yaml
curl -s -o .env.example https://raw.githubusercontent.com/YOUR_USERNAME/trader-vue/main/.env.production.example
curl -s -o schema.sql https://raw.githubusercontent.com/YOUR_USERNAME/trader-vue/main/schema.sql
# Create .env if it doesn't exist
if [ ! -f .env ]; then
echo "[CONFIG] Creating .env file from template..."
cp .env.example .env
# Generate a random JWT secret
JWT_SECRET=$(openssl rand -base64 32 2>/dev/null || echo "CHANGE_THIS_JWT_SECRET_$(date +%s)")
sed -i.bak "s/your_super_secure_jwt_secret_key_change_this_in_production/${JWT_SECRET}/" .env
# Generate a random database password
DB_PASSWORD=$(openssl rand -base64 16 2>/dev/null || echo "secure_db_pass_$(date +%s)")
sed -i.bak "s/your_secure_database_password_here/${DB_PASSWORD}/" .env
echo "[SECURITY] Generated secure JWT secret and database password"
fi
# Update docker-compose.yml with correct image name
echo "[CONFIG] Please update the Docker image name in docker-compose.yml"
echo "Replace 'YOUR_DOCKERHUB_USERNAME/tradetally:latest' with your actual image name"
read -p "Enter your Docker Hub image name (e.g., username/tradetally:latest): " IMAGE_NAME
if [ ! -z "$IMAGE_NAME" ]; then
sed -i.bak "s|YOUR_DOCKERHUB_USERNAME/tradetally:latest|${IMAGE_NAME}|" docker-compose.yml
echo "[OK] Updated image name to: $IMAGE_NAME"
fi
# Create directories
mkdir -p logs data
# Start deployment
echo "[DEPLOY] Starting TradeTally deployment..."
docker-compose up -d
# Wait for database to be ready
echo "[WAIT] Waiting for database to be ready..."
sleep 10
# Initialize database schema
echo "[DB] Initializing database schema..."
docker exec -i tradetally-db psql -U trader -d tradetally < schema.sql 2>/dev/null || echo "Schema may already exist"
echo ""
echo "[SUCCESS] TradeTally deployment complete!"
echo ""
echo "[INFO] Access your application:"
echo " TradeTally: http://localhost"
echo " Database Admin: http://localhost:8080"
echo ""
echo "[DEMO] Demo Login:"
echo " Email: demo@example.com"
echo " Password: DemoUser25"
echo ""
echo "[CONFIG] To customize settings, edit the .env file and restart:"
echo " docker-compose restart"
echo ""
echo "[COMMANDS] Useful commands:"
echo " View logs: docker-compose logs -f"
echo " Stop: docker-compose down"
echo " Update: docker-compose pull && docker-compose up -d"
echo ""