mirror of
https://github.com/Memo-2023/mana-monorepo.git
synced 2026-05-14 22:21:10 +02:00
feat: add multi-arch Docker builds and Mac Mini deployment
- CI: Build Docker images for linux/amd64 + linux/arm64 - CI: Add manacore-web to build matrix - Add docker-compose.macmini.yml for Mac Mini deployment - Add cloudflared-config.yml for Cloudflare Tunnel routing - Add Mac Mini deployment scripts and documentation - Configure Cloudflared as launchd service for auto-start Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
e02a94a29c
commit
4ebe3ec574
8 changed files with 823 additions and 0 deletions
113
scripts/mac-mini/deploy.sh
Executable file
113
scripts/mac-mini/deploy.sh
Executable file
|
|
@ -0,0 +1,113 @@
|
|||
#!/bin/bash
|
||||
# Mac Mini Deployment Script
|
||||
# Pulls latest images and starts all containers
|
||||
|
||||
set -e
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
PROJECT_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
|
||||
COMPOSE_FILE="$PROJECT_ROOT/docker-compose.macmini.yml"
|
||||
ENV_FILE="$PROJECT_ROOT/.env.macmini"
|
||||
|
||||
echo "=== ManaCore Mac Mini Deployment ==="
|
||||
echo ""
|
||||
echo "Project root: $PROJECT_ROOT"
|
||||
echo "Compose file: $COMPOSE_FILE"
|
||||
echo ""
|
||||
|
||||
# Check if env file exists
|
||||
if [ ! -f "$ENV_FILE" ]; then
|
||||
echo "Warning: $ENV_FILE not found"
|
||||
echo "Creating from template..."
|
||||
cat > "$ENV_FILE" << 'EOF'
|
||||
# Mac Mini Production Environment
|
||||
# Copy this to .env.macmini and fill in the values
|
||||
|
||||
# Database
|
||||
POSTGRES_PASSWORD=your-secure-password
|
||||
|
||||
# Redis
|
||||
REDIS_PASSWORD=your-redis-password
|
||||
|
||||
# JWT Keys (from mana-core-auth)
|
||||
JWT_SECRET=your-jwt-secret
|
||||
JWT_PUBLIC_KEY=
|
||||
JWT_PRIVATE_KEY=
|
||||
|
||||
# Supabase (if needed)
|
||||
SUPABASE_URL=
|
||||
SUPABASE_SERVICE_ROLE_KEY=
|
||||
|
||||
# Azure OpenAI (for chat)
|
||||
AZURE_OPENAI_ENDPOINT=
|
||||
AZURE_OPENAI_API_KEY=
|
||||
EOF
|
||||
echo ""
|
||||
echo "Please edit $ENV_FILE with your values and run this script again."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Login to GitHub Container Registry
|
||||
echo "=== Logging into GitHub Container Registry ==="
|
||||
echo "Please enter your GitHub Personal Access Token (with read:packages scope):"
|
||||
read -s GITHUB_TOKEN
|
||||
echo "$GITHUB_TOKEN" | docker login ghcr.io -u memo-2023 --password-stdin
|
||||
|
||||
echo ""
|
||||
echo "=== Pulling latest images ==="
|
||||
docker compose -f "$COMPOSE_FILE" --env-file "$ENV_FILE" pull
|
||||
|
||||
echo ""
|
||||
echo "=== Starting containers ==="
|
||||
docker compose -f "$COMPOSE_FILE" --env-file "$ENV_FILE" up -d
|
||||
|
||||
echo ""
|
||||
echo "=== Waiting for services to start (30s) ==="
|
||||
sleep 30
|
||||
|
||||
echo ""
|
||||
echo "=== Container Status ==="
|
||||
docker compose -f "$COMPOSE_FILE" ps
|
||||
|
||||
echo ""
|
||||
echo "=== Creating databases ==="
|
||||
docker compose -f "$COMPOSE_FILE" exec -T postgres psql -U postgres -c "CREATE DATABASE manacore_auth;" 2>/dev/null || echo "manacore_auth exists"
|
||||
docker compose -f "$COMPOSE_FILE" exec -T postgres psql -U postgres -c "CREATE DATABASE chat;" 2>/dev/null || echo "chat exists"
|
||||
docker compose -f "$COMPOSE_FILE" exec -T postgres psql -U postgres -c "CREATE DATABASE todo;" 2>/dev/null || echo "todo exists"
|
||||
docker compose -f "$COMPOSE_FILE" exec -T postgres psql -U postgres -c "CREATE DATABASE calendar;" 2>/dev/null || echo "calendar exists"
|
||||
docker compose -f "$COMPOSE_FILE" exec -T postgres psql -U postgres -c "CREATE DATABASE clock;" 2>/dev/null || echo "clock exists"
|
||||
|
||||
echo ""
|
||||
echo "=== Health Checks ==="
|
||||
check_health() {
|
||||
local name=$1
|
||||
local url=$2
|
||||
if curl -s -o /dev/null -w "%{http_code}" "$url" | grep -q "200"; then
|
||||
echo " $name: OK"
|
||||
else
|
||||
echo " $name: FAILED"
|
||||
fi
|
||||
}
|
||||
|
||||
check_health "Auth API" "http://localhost:3001/api/v1/health"
|
||||
check_health "ManaCore Web" "http://localhost:5173/health"
|
||||
check_health "Chat Backend" "http://localhost:3002/api/v1/health"
|
||||
check_health "Chat Web" "http://localhost:3000/health"
|
||||
check_health "Todo Backend" "http://localhost:3018/api/health"
|
||||
check_health "Todo Web" "http://localhost:5188/health"
|
||||
check_health "Calendar Backend" "http://localhost:3016/api/v1/health"
|
||||
check_health "Calendar Web" "http://localhost:5186/health"
|
||||
check_health "Clock Backend" "http://localhost:3017/api/v1/health"
|
||||
check_health "Clock Web" "http://localhost:5187/health"
|
||||
|
||||
echo ""
|
||||
echo "=== Deployment Complete ==="
|
||||
echo ""
|
||||
echo "URLs via Cloudflare Tunnel:"
|
||||
echo " https://mana.how - Dashboard"
|
||||
echo " https://auth.mana.how - Auth API"
|
||||
echo " https://chat.mana.how - Chat"
|
||||
echo " https://todo.mana.how - Todo"
|
||||
echo " https://calendar.mana.how - Calendar"
|
||||
echo " https://clock.mana.how - Clock"
|
||||
echo ""
|
||||
79
scripts/mac-mini/setup-cloudflared-service.sh
Executable file
79
scripts/mac-mini/setup-cloudflared-service.sh
Executable file
|
|
@ -0,0 +1,79 @@
|
|||
#!/bin/bash
|
||||
# Setup Cloudflared as a launchd service on macOS
|
||||
# Run this script once on the Mac Mini to enable auto-start
|
||||
|
||||
set -e
|
||||
|
||||
TUNNEL_ID="bb0ea86d-8253-4a54-838b-107bb7945be9"
|
||||
CONFIG_FILE="$HOME/projects/manacore-monorepo/cloudflared-config.yml"
|
||||
CREDENTIALS_FILE="$HOME/.cloudflared/${TUNNEL_ID}.json"
|
||||
PLIST_FILE="$HOME/Library/LaunchAgents/com.cloudflare.cloudflared.plist"
|
||||
|
||||
echo "=== Cloudflared Service Setup ==="
|
||||
echo ""
|
||||
|
||||
# Check if credentials exist
|
||||
if [ ! -f "$CREDENTIALS_FILE" ]; then
|
||||
echo "Error: Credentials file not found: $CREDENTIALS_FILE"
|
||||
echo "Run 'cloudflared tunnel login' first"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Check if config exists
|
||||
if [ ! -f "$CONFIG_FILE" ]; then
|
||||
echo "Error: Config file not found: $CONFIG_FILE"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Create LaunchAgents directory if needed
|
||||
mkdir -p ~/Library/LaunchAgents
|
||||
|
||||
# Create the plist file
|
||||
cat > "$PLIST_FILE" << EOF
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>Label</key>
|
||||
<string>com.cloudflare.cloudflared</string>
|
||||
<key>ProgramArguments</key>
|
||||
<array>
|
||||
<string>/opt/homebrew/bin/cloudflared</string>
|
||||
<string>tunnel</string>
|
||||
<string>--config</string>
|
||||
<string>${CONFIG_FILE}</string>
|
||||
<string>run</string>
|
||||
</array>
|
||||
<key>RunAtLoad</key>
|
||||
<true/>
|
||||
<key>KeepAlive</key>
|
||||
<true/>
|
||||
<key>StandardOutPath</key>
|
||||
<string>/tmp/cloudflared.log</string>
|
||||
<key>StandardErrorPath</key>
|
||||
<string>/tmp/cloudflared.error.log</string>
|
||||
</dict>
|
||||
</plist>
|
||||
EOF
|
||||
|
||||
echo "Created plist: $PLIST_FILE"
|
||||
|
||||
# Unload if already loaded
|
||||
launchctl unload "$PLIST_FILE" 2>/dev/null || true
|
||||
|
||||
# Load the service
|
||||
launchctl load "$PLIST_FILE"
|
||||
|
||||
echo ""
|
||||
echo "=== Service Status ==="
|
||||
launchctl list | grep cloudflared || echo "Service loaded"
|
||||
|
||||
echo ""
|
||||
echo "Cloudflared is now running as a service."
|
||||
echo ""
|
||||
echo "Useful commands:"
|
||||
echo " Check status: launchctl list | grep cloudflared"
|
||||
echo " View logs: tail -f /tmp/cloudflared.log"
|
||||
echo " Stop service: launchctl unload $PLIST_FILE"
|
||||
echo " Start service: launchctl load $PLIST_FILE"
|
||||
echo ""
|
||||
Loading…
Add table
Add a link
Reference in a new issue