Files
mintel.me/deploy.sh
2026-01-13 02:42:03 +01:00

63 lines
1.8 KiB
Bash
Executable File

#!/bin/bash
# Simple deployment script for Hetzner
set -e
# Configuration
DOMAIN=${DOMAIN:-mintel.me}
ADMIN_EMAIL=${ADMIN_EMAIL:-marc@mintel.me}
DEPLOY_HOST=${DEPLOY_HOST:-$1}
DEPLOY_USER=${DEPLOY_USER:-root}
if [ -z "$DEPLOY_HOST" ]; then
echo "Usage: ./deploy.sh <host-ip> or set DEPLOY_HOST env var"
exit 1
fi
echo "🚀 Deploying Mintel Blog to $DEPLOY_HOST..."
# Create deployment directory
ssh $DEPLOY_USER@$DEPLOY_HOST "mkdir -p /opt/mintel"
# Copy files
echo "📦 Copying files..."
scp docker-compose.yml docker/Caddyfile docker/Dockerfile docker/nginx.conf $DEPLOY_USER@$DEPLOY_HOST:/opt/mintel/
# Create environment file
echo "🔧 Setting up environment..."
if [ -f .env ]; then
echo "Using local .env file..."
scp .env $DEPLOY_USER@$DEPLOY_HOST:/opt/mintel/
else
echo "Creating .env from variables..."
ssh $DEPLOY_USER@$DEPLOY_HOST "cat > /opt/mintel/.env << EOF
DOMAIN=${DOMAIN:-mintel.me}
ADMIN_EMAIL=${ADMIN_EMAIL:-admin@mintel.me}
REDIS_URL=${REDIS_URL:-redis://redis:6379}
PLAUSIBLE_DOMAIN=${PLAUSIBLE_DOMAIN:-$DOMAIN}
PLAUSIBLE_SCRIPT_URL=${PLAUSIBLE_SCRIPT_URL:-https://plausible.yourdomain.com/js/script.js}
EOF"
fi
# Deploy
echo "🚀 Starting services..."
ssh $DEPLOY_USER@$DEPLOY_HOST "
cd /opt/mintel &&
docker-compose down &&
docker-compose pull &&
docker-compose up -d --build &&
docker system prune -f
"
echo "✅ Deployment complete!"
echo "🌐 Website: https://$DOMAIN"
echo "📊 Health check: https://$DOMAIN/health"
# Wait for health check
echo "⏳ Waiting for health check..."
sleep 10
if curl -f https://$DOMAIN/health > /dev/null 2>&1; then
echo "✅ Health check passed!"
else
echo "⚠️ Health check failed. Check logs with: ssh $DEPLOY_USER@$DEPLOY_HOST 'docker logs mintel-website'"
fi