Files
MyClub/deploy-directory.sh
T
Tomas Dvorak dfc079288f hot fix #1
2026-01-26 08:13:18 +01:00

89 lines
3.1 KiB
Bash

#!/bin/bash
# Deployment script for MyClub Central Directory Service
# Deploys to error.sportcreative.eu
echo "🚀 Deploying MyClub Central Directory Service..."
# Build the central directory service
echo "📍 Step 1: Building central directory service"
cd /home/tdvorak/Desktop/PROG+HTML/Fotbal/fotbal-club/cmd/central-directory
go build -o central-directory .
if [ $? -eq 0 ]; then
echo "✅ Build successful"
else
echo "❌ Build failed"
exit 1
fi
# Create deployment package
echo "📍 Step 2: Creating deployment package"
cd /home/tdvorak/Desktop/PROG+HTML/Fotbal/fotbal-club
tar -czf central-directory-deploy.tar.gz \
cmd/central-directory/central-directory \
cmd/central-directory/go.mod \
cmd/central-directory/go.sum \
central-directory/README.md
echo "✅ Deployment package created: central-directory-deploy.tar.gz"
# Show deployment instructions
echo ""
echo "📋 Deployment Instructions:"
echo "=========================="
echo ""
echo "1. Upload the package to the server:"
echo " scp central-directory-deploy.tar.gz user@error.sportcreative.eu:/tmp/"
echo ""
echo "2. Extract on the server:"
echo " ssh user@error.sportcreative.eu"
echo " cd /tmp"
echo " tar -xzf central-directory-deploy.tar.gz"
echo " cd cmd/central-directory"
echo ""
echo "3. Set environment variables:"
echo " export PORT=8083"
echo " export DIRECTORY_TOKEN=directory-registration-secure-token-2025"
echo ""
echo "4. Run the service:"
echo " ./central-directory"
echo ""
echo "5. Set up systemd service (optional):"
echo " sudo cp central-directory.service /etc/systemd/system/"
echo " sudo systemctl enable central-directory"
echo " sudo systemctl start central-directory"
echo ""
echo "6. Test the deployment:"
echo " curl https://error.sportcreative.eu/api/v1/health"
echo " curl https://error.sportcreative.eu/api/v1/clubs"
echo ""
echo "🔧 Configuration:"
echo "=================="
echo " - Service runs on port 8083"
echo " - Token: directory-registration-secure-token-2025"
echo " - Base URL: https://error.sportcreative.eu/api/v1"
echo " - Registration endpoint: /api/v1/directory/register"
echo " - Clubs endpoint: /api/v1/clubs"
echo ""
echo "🌐 Endpoints:"
echo "============"
echo " GET /api/v1/health - Service health check"
echo " GET /api/v1/clubs - List all clubs"
echo " GET /api/v1/clubs/:id - Get specific club"
echo " GET /api/v1/stats - Directory statistics"
echo " POST /api/v1/directory/register - Register club (protected)"
echo " POST /api/v1/directory/heartbeat - Club heartbeat (protected)"
echo ""
echo "🔐 Authentication:"
echo "=================="
echo " - Use X-Directory-Token header"
echo " - Token: directory-registration-secure-token-2025"
echo " - Example: curl -H 'X-Directory-Token: directory-registration-secure-token-2025'"
echo ""
echo "📱 Mobile App Integration:"
echo "========================"
echo " - Mobile app will query: https://error.sportcreative.eu/api/v1/clubs"
echo " - Clubs will auto-register to: https://error.sportcreative.eu/api/v1/directory/register"
echo " - Fallback to local data if central service is unavailable"