#!/bin/bash # LittleShop Deployment Script - Hostinger Server # This script ensures consistent deployment with all working configurations set -e # Exit on error echo "==========================================" echo "LittleShop Deployment Script" echo "==========================================" echo "" # Configuration REPO_URL="https://e6b941bdc9c51ef811e0b13f6014a1dbc0309e2d@git.silverlabs.uk/SilverLABS/LittleShop.git" WORK_DIR="/opt/LittleShop" # Step 1: Update code echo "1. Updating source code..." if [ ! -d "$WORK_DIR" ]; then echo " Cloning repository..." sudo git clone $REPO_URL $WORK_DIR else echo " Pulling latest changes..." cd $WORK_DIR sudo git pull origin main fi # Step 2: Build Docker image echo "" echo "2. Building Docker image..." cd $WORK_DIR/LittleShop sudo docker build -t littleshop:latest -t localhost:5000/littleshop:latest . # Step 3: Stop old container echo "" echo "3. Stopping old container..." docker stop littleshop-admin 2>/dev/null || echo " Container not running" docker rm littleshop-admin 2>/dev/null || echo " Container doesn't exist" # Step 4: Fix permissions echo "" echo "4. Setting correct permissions..." sudo mkdir -p /opt/littleshop/{data,logs,uploads} sudo chown -R 1654:1654 /opt/littleshop/data/ sudo chown -R 1654:1654 /opt/littleshop/logs/ sudo chown -R 1654:1654 /opt/littleshop/uploads/ # Step 5: Start new container with EXACT working configuration echo "" echo "5. Starting new container..." docker run -d \ --name littleshop-admin \ --restart unless-stopped \ --network littleshop-network \ -p 127.0.0.1:5100:8080 \ -v /opt/littleshop/data:/app/data \ -v /opt/littleshop/logs:/app/logs \ -v /opt/littleshop/uploads:/app/wwwroot/uploads \ -e ASPNETCORE_ENVIRONMENT=Production \ -e ASPNETCORE_URLS="http://+:8080" \ -e ConnectionStrings__DefaultConnection="Data Source=/app/data/littleshop-production.db" \ -e Jwt__Key="ThisIsAVeryLongSecretKeyThatIsDefinitelyLongerThan32BytesForSure123456789ABCDEF" \ -e SilverPay__BaseUrl="http://silverpay-api:8000" \ -e SilverPay__ApiKey="7703aa7a62fa4b40a87e9cfd867f5407147515c0986116ea54fc00c0a0bc30d8" \ -e SilverPay__WebhookSecret="Thefa1r1esd1d1twebhooks2024" \ littleshop:latest # Step 6: Verify deployment echo "" echo "6. Waiting for container to start..." sleep 15 echo "" echo "7. Verifying deployment..." echo " Container status:" docker ps --format "table {{.Names}}\t{{.Status}}" | grep -E "NAME|littleshop-admin" echo "" echo " Testing health endpoint:" curl -s -o /dev/null -w " HTTP Status: %{http_code}\n" http://localhost:5100/health echo "" echo " Testing login page:" curl -s -o /dev/null -w " HTTP Status: %{http_code}\n" http://localhost:5100/Admin/Account/Login echo "" echo " Recent logs:" docker logs --tail 10 littleshop-admin echo "" echo "==========================================" echo "Deployment Complete!" echo "" echo "Access the admin panel at:" echo "https://admin.thebankofdebbie.giize.com" echo "" echo "If login fails with HTTP 500, check:" echo "1. Jwt__Key environment variable (double underscore!)" echo "2. JWT key length (must be > 32 bytes)" echo "3. Database permissions (UID 1654)" echo "=========================================="