Initial commit: Add HomeBase application with Docker support, deployment scripts, and health check endpoint
Some checks failed
Deploy to BeePC / deploy (push) Has been cancelled
Some checks failed
Deploy to BeePC / deploy (push) Has been cancelled
This commit is contained in:
82
scripts/deploy.ps1
Normal file
82
scripts/deploy.ps1
Normal file
@@ -0,0 +1,82 @@
|
||||
# PowerShell deployment script for HomeBase
|
||||
# Run this from the project root directory: .\scripts\deploy.ps1
|
||||
|
||||
$ErrorActionPreference = "Stop"
|
||||
|
||||
$REMOTE_USER = "spencer"
|
||||
$REMOTE_HOST = "beepc"
|
||||
$REMOTE_DIR = "/home/spencer/homebase"
|
||||
|
||||
Write-Host "🚀 Starting deployment to $REMOTE_USER@$REMOTE_HOST..." -ForegroundColor Cyan
|
||||
|
||||
# Create remote directory
|
||||
Write-Host "📁 Ensuring remote directory exists..." -ForegroundColor Yellow
|
||||
ssh $REMOTE_USER@$REMOTE_HOST "mkdir -p $REMOTE_DIR"
|
||||
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
Write-Host "❌ Failed to create remote directory" -ForegroundColor Red
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Copy files to remote server
|
||||
Write-Host "📦 Copying files to remote server..." -ForegroundColor Yellow
|
||||
$files = @(
|
||||
"Dockerfile",
|
||||
"docker-compose.yml",
|
||||
"package.json",
|
||||
"server.js",
|
||||
".dockerignore",
|
||||
"homebase.service"
|
||||
)
|
||||
|
||||
foreach ($file in $files) {
|
||||
Write-Host " Copying $file..." -ForegroundColor Gray
|
||||
scp $file "${REMOTE_USER}@${REMOTE_HOST}:${REMOTE_DIR}/"
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
Write-Host "❌ Failed to copy $file" -ForegroundColor Red
|
||||
exit 1
|
||||
}
|
||||
}
|
||||
|
||||
# Deploy and start the application
|
||||
Write-Host "🐳 Deploying application..." -ForegroundColor Yellow
|
||||
$deployScript = @'
|
||||
cd /home/spencer/homebase
|
||||
|
||||
echo "⏹️ Stopping existing container..."
|
||||
docker compose down 2>/dev/null || true
|
||||
|
||||
echo "🔨 Building and starting container..."
|
||||
docker compose up -d --build
|
||||
|
||||
echo "⚙️ Setting up systemd service..."
|
||||
sudo cp homebase.service /etc/systemd/system/homebase.service 2>/dev/null || echo "Note: Could not set up systemd service (may need manual setup)"
|
||||
sudo systemctl daemon-reload 2>/dev/null || true
|
||||
sudo systemctl enable homebase.service 2>/dev/null || true
|
||||
sudo systemctl start homebase.service 2>/dev/null || true
|
||||
|
||||
echo "⏳ Waiting for container to start..."
|
||||
sleep 5
|
||||
|
||||
echo "✅ Checking container status..."
|
||||
docker compose ps
|
||||
docker compose logs --tail=20
|
||||
|
||||
if docker ps | grep -q homebase; then
|
||||
echo "✅ Container is running!"
|
||||
exit 0
|
||||
else
|
||||
echo "❌ Container failed to start!"
|
||||
exit 1
|
||||
fi
|
||||
'@
|
||||
|
||||
ssh $REMOTE_USER@$REMOTE_HOST $deployScript
|
||||
|
||||
if ($LASTEXITCODE -eq 0) {
|
||||
Write-Host "✅ Deployment successful!" -ForegroundColor Green
|
||||
Write-Host "🌐 App should be available at http://homebase.sketchferret.com" -ForegroundColor Cyan
|
||||
} else {
|
||||
Write-Host "❌ Deployment failed!" -ForegroundColor Red
|
||||
exit 1
|
||||
}
|
||||
Reference in New Issue
Block a user