CRITICAL FIXES: - Fixed JWT key configuration issue causing HTTP 500 on login - Changed environment variable from JWT_SECRET_KEY to Jwt__Key (double underscore) - Increased JWT key length to >32 bytes (256 bits) as required by HMAC-SHA256 - Fixed ASPNETCORE_URLS configuration (not ASPNETCORE_HTTP_PORTS) DOCUMENTATION CREATED: - TROUBLESHOOTING.md: Complete troubleshooting guide with common issues and solutions - deploy-littleshop.sh: Automated deployment script with working configuration - docker-compose.hostinger.yml: Docker Compose file with all correct environment variables - Updated WORKING_BASELINE_2024-09-24.md: Added HTTP 500 fix details ROOT CAUSES IDENTIFIED: 1. JWT key environment variable naming mismatch (Jwt__Key vs JWT_SECRET_KEY) 2. JWT key too short (was 17 bytes, needs >32 bytes) 3. ASP.NET Core URL configuration issue (ASPNETCORE_URLS vs HTTP_PORTS) 4. Database file permissions (must be owned by UID 1654) WORKING CONFIGURATION: - Jwt__Key with 79-byte key - ASPNETCORE_URLS=http://+:8080 - Proper Docker network configuration (littleshop-network) - SilverPay integration on port 8000 (not 8001) This commit ensures we have a stable, documented baseline for future updates and addresses the concern about "one step forward, two steps back" by providing comprehensive documentation of all fixes. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
101 lines
3.2 KiB
Bash
101 lines
3.2 KiB
Bash
#!/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 "==========================================" |