BankliPlus/temparea/solarbank/deploy-commands.sh
2025-08-13 18:05:26 +02:00

83 lines
2.7 KiB
Bash
Executable File

#!/bin/bash
# Commands to deploy SolarBank to your server
echo "Step 1: Upload the deployment package to your server"
echo "Run this command and enter the password when prompted:"
echo ""
echo "scp solarbank-deployment.tar.gz root@172.104.237.108:/tmp/"
echo ""
echo "Step 2: SSH to your server"
echo "Run this command and enter the password when prompted:"
echo ""
echo "ssh root@172.104.237.108"
echo ""
echo "Step 3: Once connected to the server, run these commands:"
echo ""
cat << 'EOF'
# Update system and install dependencies
apt update && apt upgrade -y
# Install Docker if not already installed
if ! command -v docker &> /dev/null; then
curl -fsSL https://get.docker.com -o get-docker.sh
sh get-docker.sh
rm get-docker.sh
fi
# Install Docker Compose if not already installed
if ! command -v docker-compose &> /dev/null; then
curl -L "https://github.com/docker/compose/releases/latest/download/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose
fi
# Install other required packages
apt install -y git curl wget htop ufw fail2ban
# Configure firewall
ufw --force reset
ufw default deny incoming
ufw default allow outgoing
ufw allow ssh
ufw allow 80/tcp
ufw allow 443/tcp
ufw --force enable
# Create application directory
mkdir -p /opt/solarbank
cd /opt/solarbank
# Extract application files
tar -xzf /tmp/solarbank-deployment.tar.gz
rm /tmp/solarbank-deployment.tar.gz
# Make scripts executable
chmod +x scripts/*.sh
# Create production environment file
cp environment.prod.example .env.prod
# Generate secure keys
SECRET_KEY=$(python3 -c "import secrets; print(secrets.token_urlsafe(32))")
JWT_SECRET_KEY=$(python3 -c "import secrets; print(secrets.token_urlsafe(32))")
DB_PASSWORD=$(python3 -c "import secrets; print(secrets.token_urlsafe(16))")
DB_ROOT_PASSWORD=$(python3 -c "import secrets; print(secrets.token_urlsafe(16))")
# Update .env.prod with generated values
sed -i "s/SECRET_KEY=.*/SECRET_KEY=$SECRET_KEY/" .env.prod
sed -i "s/JWT_SECRET_KEY=.*/JWT_SECRET_KEY=$JWT_SECRET_KEY/" .env.prod
sed -i "s/POSTGRES_PASSWORD=.*/POSTGRES_PASSWORD=$DB_PASSWORD/" .env.prod
sed -i "s/POSTGRES_INITDB_ROOT_PASSWORD=.*/POSTGRES_INITDB_ROOT_PASSWORD=$DB_ROOT_PASSWORD/" .env.prod
# Update domain configuration (you'll need to change this to your actual domain)
echo ""
echo "IMPORTANT: Edit the .env.prod file to set your domain and email:"
echo "nano .env.prod"
echo ""
echo "Change these values:"
echo "- DOMAIN_NAME=yourdomain.com"
echo "- EMAIL=your-email@domain.com"
echo "- BACKEND_CORS_ORIGINS=[\"https://yourdomain.com\", \"https://www.yourdomain.com\"]"
echo "- REACT_APP_API_URL=https://yourdomain.com/api"
echo ""
echo "After editing, run: ./scripts/deploy.sh"
EOF