#!/bin/bash # LittleShop Deployment to Hostinger VPS (with BTCPay Server) # Server: srv1002428.hstgr.cloud (thebankofdebbie.giize.com) # Updated: 2025-09-19 set -e # Colors for output RED='\033[0;31m' GREEN='\033[0;32m' YELLOW='\033[1;33m' NC='\033[0m' # No Color # Configuration HOSTINGER_HOST="srv1002428.hstgr.cloud" HOSTINGER_PORT="2255" HOSTINGER_USER="root" echo -e "${GREEN}═══════════════════════════════════════════════════${NC}" echo -e "${GREEN} LittleShop Deployment to Hostinger VPS${NC}" echo -e "${GREEN} BTCPay Server: thebankofdebbie.giize.com${NC}" echo -e "${GREEN}═══════════════════════════════════════════════════${NC}" echo "" # Create deployment archives echo -e "${YELLOW}📦 Creating deployment archives...${NC}" cd /mnt/c/Production/Source/LittleShop # Create tar archives tar -czf littleshop-release.tar.gz -C publish littleshop tar -czf telebot-release.tar.gz -C publish telebot # Copy production configuration files cp -f docker-compose.prod.yml docker-compose.yml.deploy cp -f Dockerfile Dockerfile.deploy cp -f .env.production.template .env.template echo -e "${GREEN}✅ Archives created${NC}" # Upload to Hostinger echo -e "${YELLOW}📤 Uploading to Hostinger VPS...${NC}" echo -e " Server: ${HOSTINGER_HOST}" echo -e " Port: ${HOSTINGER_PORT}" sshpass -p 'Phenom12#.' scp -P $HOSTINGER_PORT -o StrictHostKeyChecking=no \ littleshop-release.tar.gz \ telebot-release.tar.gz \ docker-compose.yml.deploy \ Dockerfile.deploy \ .env.template \ $HOSTINGER_USER@$HOSTINGER_HOST:/tmp/ echo -e "${GREEN}✅ Files uploaded${NC}" # Deploy on server echo -e "${YELLOW}🚀 Deploying on server...${NC}" sshpass -p 'Phenom12#.' ssh -p $HOSTINGER_PORT -o StrictHostKeyChecking=no $HOSTINGER_USER@$HOSTINGER_HOST << 'ENDSSH' set -e # Colors GREEN='\033[0;32m' YELLOW='\033[1;33m' NC='\033[0m' echo -e "${YELLOW}Setting up deployment directories...${NC}" # Create deployment directories mkdir -p /opt/littleshop mkdir -p /opt/telebot mkdir -p /var/lib/littleshop mkdir -p /var/log/littleshop # Backup current deployment if exists if [ -d "/opt/littleshop/littleshop" ]; then echo "Creating backup..." mkdir -p /backups/littleshop tar -czf /backups/littleshop/backup-$(date +%Y%m%d-%H%M%S).tar.gz -C /opt/littleshop littleshop || true fi # Stop existing Docker containers echo -e "${YELLOW}Stopping existing services...${NC}" cd /opt/littleshop docker-compose down 2>/dev/null || true # Extract new deployment echo -e "${YELLOW}Extracting new deployment...${NC}" tar -xzf /tmp/littleshop-release.tar.gz -C /opt/littleshop tar -xzf /tmp/telebot-release.tar.gz -C /opt/telebot # Copy Docker files cp /tmp/docker-compose.yml.deploy /opt/littleshop/docker-compose.yml cp /tmp/Dockerfile.deploy /opt/littleshop/Dockerfile # Setup environment file if [ ! -f /opt/littleshop/.env ]; then echo -e "${YELLOW}Setting up environment configuration...${NC}" cp /tmp/.env.template /opt/littleshop/.env # Update with BTCPay Server details cat >> /opt/littleshop/.env << 'EOF' # BTCPay Server Configuration (Hostinger VPS) BTCPAY_SERVER_URL=https://thebankofdebbie.giize.com BTCPAY_STORE_ID=CvdvHoncGLM7TdMYRAG6Z15YuxQfxeMWRYwi9gvPhh5R BTCPAY_API_KEY=3ff1f1e8c488ab9bb19b0c979c8fa2f1bf5e8dc5 BTCPAY_WEBHOOK_SECRET=your-webhook-secret-here # TeleBot Configuration TELEBOT_API_URL=http://localhost:8081 TELEBOT_API_KEY=development-key-replace-in-production # Web Push VAPID Keys (already configured) WEBPUSH_VAPID_PUBLIC_KEY=BMc6fFJZ8oIQKQzcl3kMnP9tTsjrm3oI_VxLt3lAGYUMWGInzDKn7jqclEoZzjvXy1QXGFb3dIun8mVBwh-QuS4 WEBPUSH_VAPID_PRIVATE_KEY=sX5KHgb5LRd-FV8XYTWN6p8TpMZcQ2y3mcKwKe50NeE EOF fi # Create Docker network if not exists docker network create littleshop-network 2>/dev/null || true # Build and start containers echo -e "${YELLOW}Starting Docker containers...${NC}" cd /opt/littleshop docker-compose up -d --build # Wait for services to start echo -e "${YELLOW}Waiting for services to start...${NC}" sleep 15 # Check service health echo -e "${YELLOW}Checking service health...${NC}" if curl -f -s http://localhost:8080/api/push/vapid-key > /dev/null; then echo -e "${GREEN}✅ LittleShop API is running${NC}" else echo -e "⚠️ LittleShop API health check failed" fi # Setup nginx reverse proxy if needed if ! [ -f /etc/nginx/sites-available/littleshop ]; then echo -e "${YELLOW}Configuring nginx...${NC}" cat > /etc/nginx/sites-available/littleshop << 'NGINX' server { listen 80; server_name littleshop.silverlabs.uk; location / { proxy_pass http://localhost:8080; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; } } NGINX ln -sf /etc/nginx/sites-available/littleshop /etc/nginx/sites-enabled/ nginx -t && systemctl reload nginx fi # Clean up rm -f /tmp/littleshop-release.tar.gz rm -f /tmp/telebot-release.tar.gz rm -f /tmp/docker-compose.yml.deploy rm -f /tmp/Dockerfile.deploy rm -f /tmp/.env.template echo -e "${GREEN}✅ Deployment complete!${NC}" # Show container status docker ps --filter "name=littleshop" # Show recent logs echo "" echo "Recent logs:" docker logs --tail 10 littleshop_web_1 2>&1 || echo "Container not yet started" ENDSSH # Clean up local files rm -f littleshop-release.tar.gz rm -f telebot-release.tar.gz rm -f docker-compose.yml.deploy rm -f Dockerfile.deploy rm -f .env.template echo "" echo -e "${GREEN}═══════════════════════════════════════════════════${NC}" echo -e "${GREEN} Deployment Complete!${NC}" echo -e "${GREEN}═══════════════════════════════════════════════════${NC}" echo "" echo "📌 Service URLs:" echo " - LittleShop: https://littleshop.silverlabs.uk" echo " - Admin Panel: https://littleshop.silverlabs.uk/admin" echo " - BTCPay Server: https://thebankofdebbie.giize.com" echo "" echo "🔧 Useful Commands:" echo " Check status: sshpass -p 'Phenom12#.' ssh -p 2255 root@srv1002428.hstgr.cloud docker ps" echo " View logs: sshpass -p 'Phenom12#.' ssh -p 2255 root@srv1002428.hstgr.cloud docker logs littleshop_web_1" echo "" echo "⚠️ Important:" echo " 1. Update BTCPAY_WEBHOOK_SECRET in /opt/littleshop/.env on server" echo " 2. Configure BTCPay webhook URL: https://littleshop.silverlabs.uk/api/orders/payments/webhook" echo " 3. Test TeleBot connection after deployment"