refactor: remove snippets feature and n8n project detection
- Remove snippets page, component, API route, Directus types, and setup script - Remove snippets section from About.tsx (card, modal, state) - Remove snippets link from 404 page, simplify layout - Remove n8n Docker event and callback handler workflows (auto project detection) - Remove Gitea runner setup and deploy scripts
This commit is contained in:
@@ -1,136 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Gitea Runner Status Check Script
|
||||
# Prüft den Status des Gitea Runners
|
||||
|
||||
set -e
|
||||
|
||||
# Colors for output
|
||||
RED='\033[0;31m'
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[1;33m'
|
||||
BLUE='\033[0;34m'
|
||||
CYAN='\033[0;36m'
|
||||
NC='\033[0m' # No Color
|
||||
|
||||
echo -e "${BLUE}╔════════════════════════════════════════════════════════════╗${NC}"
|
||||
echo -e "${BLUE}║ Gitea Runner Status Check ║${NC}"
|
||||
echo -e "${BLUE}╚════════════════════════════════════════════════════════════╝${NC}"
|
||||
echo ""
|
||||
|
||||
# Check 1: systemd service
|
||||
echo -e "${CYAN}[1/5] Checking systemd service...${NC}"
|
||||
if systemctl list-units --type=service --all | grep -q "gitea-runner.service"; then
|
||||
echo -e "${GREEN}✓ systemd service found${NC}"
|
||||
systemctl status gitea-runner --no-pager -l || true
|
||||
else
|
||||
echo -e "${YELLOW}⚠ systemd service not found (runner might be running differently)${NC}"
|
||||
fi
|
||||
echo ""
|
||||
|
||||
# Check 2: Running processes
|
||||
echo -e "${CYAN}[2/5] Checking for running runner processes...${NC}"
|
||||
RUNNER_PROCESSES=$(ps aux | grep -E "(gitea|act_runner|woodpecker)" | grep -v grep || echo "")
|
||||
if [ ! -z "$RUNNER_PROCESSES" ]; then
|
||||
echo -e "${GREEN}✓ Found runner processes:${NC}"
|
||||
echo "$RUNNER_PROCESSES" | while read line; do
|
||||
echo " $line"
|
||||
done
|
||||
else
|
||||
echo -e "${RED}✗ No runner processes found${NC}"
|
||||
fi
|
||||
echo ""
|
||||
|
||||
# Check 3: Docker containers (if runner runs in Docker)
|
||||
echo -e "${CYAN}[3/5] Checking for runner Docker containers...${NC}"
|
||||
RUNNER_CONTAINERS=$(docker ps -a --filter "name=runner" --format "{{.Names}}\t{{.Status}}" 2>/dev/null || echo "")
|
||||
if [ ! -z "$RUNNER_CONTAINERS" ]; then
|
||||
echo -e "${GREEN}✓ Found runner containers:${NC}"
|
||||
echo "$RUNNER_CONTAINERS" | while read line; do
|
||||
echo " $line"
|
||||
done
|
||||
else
|
||||
echo -e "${YELLOW}⚠ No runner containers found${NC}"
|
||||
fi
|
||||
echo ""
|
||||
|
||||
# Check 4: Common runner directories
|
||||
echo -e "${CYAN}[4/5] Checking common runner directories...${NC}"
|
||||
RUNNER_DIRS=(
|
||||
"/tmp/gitea-runner"
|
||||
"/opt/gitea-runner"
|
||||
"/home/*/gitea-runner"
|
||||
"~/.gitea-runner"
|
||||
"/usr/local/gitea-runner"
|
||||
)
|
||||
|
||||
FOUND_DIRS=0
|
||||
for dir in "${RUNNER_DIRS[@]}"; do
|
||||
# Expand ~ and wildcards
|
||||
EXPANDED_DIR=$(eval echo "$dir" 2>/dev/null || echo "")
|
||||
if [ -d "$EXPANDED_DIR" ]; then
|
||||
echo -e "${GREEN}✓ Found runner directory: $EXPANDED_DIR${NC}"
|
||||
FOUND_DIRS=$((FOUND_DIRS + 1))
|
||||
# Check for config files
|
||||
if [ -f "$EXPANDED_DIR/.runner" ] || [ -f "$EXPANDED_DIR/config.yml" ]; then
|
||||
echo " → Contains configuration files"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
if [ $FOUND_DIRS -eq 0 ]; then
|
||||
echo -e "${YELLOW}⚠ No runner directories found in common locations${NC}"
|
||||
fi
|
||||
echo ""
|
||||
|
||||
# Check 5: Network connections (check if runner is connecting to Gitea)
|
||||
echo -e "${CYAN}[5/5] Checking network connections to Gitea...${NC}"
|
||||
GITEA_URL="${GITEA_URL:-https://git.dk0.dev}"
|
||||
if command -v netstat >/dev/null 2>&1; then
|
||||
CONNECTIONS=$(netstat -tn 2>/dev/null | grep -E "(git.dk0.dev|3000|3001)" || echo "")
|
||||
elif command -v ss >/dev/null 2>&1; then
|
||||
CONNECTIONS=$(ss -tn 2>/dev/null | grep -E "(git.dk0.dev|3000|3001)" || echo "")
|
||||
fi
|
||||
|
||||
if [ ! -z "$CONNECTIONS" ]; then
|
||||
echo -e "${GREEN}✓ Found connections to Gitea:${NC}"
|
||||
echo "$CONNECTIONS" | head -5
|
||||
else
|
||||
echo -e "${YELLOW}⚠ No active connections to Gitea found${NC}"
|
||||
fi
|
||||
echo ""
|
||||
|
||||
# Summary
|
||||
echo -e "${BLUE}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
|
||||
echo -e "${BLUE}Summary:${NC}"
|
||||
echo ""
|
||||
|
||||
if [ ! -z "$RUNNER_PROCESSES" ] || [ ! -z "$RUNNER_CONTAINERS" ]; then
|
||||
echo -e "${GREEN}✓ Runner appears to be running${NC}"
|
||||
echo ""
|
||||
echo "To check runner status in Gitea:"
|
||||
echo " 1. Go to: https://git.dk0.dev/denshooter/portfolio/settings/actions/runners"
|
||||
echo " 2. Check if runner-01 shows as 'online' or 'idle'"
|
||||
echo ""
|
||||
echo "To view runner logs:"
|
||||
if [ ! -z "$RUNNER_PROCESSES" ]; then
|
||||
echo " - Check process logs or journalctl"
|
||||
fi
|
||||
if [ ! -z "$RUNNER_CONTAINERS" ]; then
|
||||
echo " - docker logs <container-name>"
|
||||
fi
|
||||
else
|
||||
echo -e "${RED}✗ Runner does not appear to be running${NC}"
|
||||
echo ""
|
||||
echo "To start the runner:"
|
||||
echo " 1. Find where the runner binary is located"
|
||||
echo " 2. Check Gitea for registration token"
|
||||
echo " 3. Run: ./act_runner register --config config.yml"
|
||||
echo " 4. Run: ./act_runner daemon --config config.yml"
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo -e "${CYAN}For more information, check:${NC}"
|
||||
echo " - Gitea Runner Docs: https://docs.gitea.com/usage/actions/act-runner"
|
||||
echo " - Runner Status: https://git.dk0.dev/denshooter/portfolio/settings/actions/runners"
|
||||
echo ""
|
||||
@@ -1,225 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Simplified Gitea deployment script for testing
|
||||
# This version doesn't require database dependencies
|
||||
|
||||
set -e
|
||||
|
||||
# Configuration
|
||||
PROJECT_NAME="portfolio"
|
||||
CONTAINER_NAME="portfolio-app-simple"
|
||||
IMAGE_NAME="portfolio-app"
|
||||
PORT=3000
|
||||
BACKUP_PORT=3001
|
||||
LOG_FILE="./logs/gitea-deploy-simple.log"
|
||||
|
||||
# Colors for output
|
||||
RED='\033[0;31m'
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[1;33m'
|
||||
BLUE='\033[0;34m'
|
||||
NC='\033[0m' # No Color
|
||||
|
||||
# Logging function
|
||||
log() {
|
||||
echo -e "${BLUE}[$(date +'%Y-%m-%d %H:%M:%S')]${NC} $1" | tee -a "$LOG_FILE"
|
||||
}
|
||||
|
||||
error() {
|
||||
echo -e "${RED}[ERROR]${NC} $1" | tee -a "$LOG_FILE"
|
||||
}
|
||||
|
||||
success() {
|
||||
echo -e "${GREEN}[SUCCESS]${NC} $1" | tee -a "$LOG_FILE"
|
||||
}
|
||||
|
||||
warning() {
|
||||
echo -e "${YELLOW}[WARNING]${NC} $1" | tee -a "$LOG_FILE"
|
||||
}
|
||||
|
||||
# Check if running as root (skip in CI environments)
|
||||
if [[ $EUID -eq 0 ]] && [[ -z "$CI" ]]; then
|
||||
error "This script should not be run as root (use CI=true to override)"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Check if Docker is running
|
||||
if ! docker info > /dev/null 2>&1; then
|
||||
error "Docker is not running. Please start Docker and try again."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Check if we're in the right directory
|
||||
if [ ! -f "package.json" ] || [ ! -f "Dockerfile" ]; then
|
||||
error "Please run this script from the project root directory"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
log "🚀 Starting simplified Gitea deployment for $PROJECT_NAME"
|
||||
|
||||
# Step 1: Build Application
|
||||
log "🔨 Step 1: Building application..."
|
||||
|
||||
# Build Next.js application
|
||||
log "📦 Building Next.js application..."
|
||||
npm run build || {
|
||||
error "Build failed"
|
||||
exit 1
|
||||
}
|
||||
|
||||
success "✅ Application built successfully"
|
||||
|
||||
# Step 2: Docker Operations
|
||||
log "🐳 Step 2: Docker operations..."
|
||||
|
||||
# Build Docker image
|
||||
log "🏗️ Building Docker image..."
|
||||
docker build -t "$IMAGE_NAME:latest" . || {
|
||||
error "Docker build failed"
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Tag with timestamp
|
||||
TIMESTAMP=$(date +%Y%m%d-%H%M%S)
|
||||
docker tag "$IMAGE_NAME:latest" "$IMAGE_NAME:$TIMESTAMP"
|
||||
|
||||
success "✅ Docker image built successfully"
|
||||
|
||||
# Step 3: Deployment
|
||||
log "🚀 Step 3: Deploying application..."
|
||||
|
||||
# Export environment variables for docker-compose compatibility
|
||||
log "📝 Exporting environment variables..."
|
||||
export NODE_ENV=${NODE_ENV:-production}
|
||||
export NEXT_PUBLIC_BASE_URL=${NEXT_PUBLIC_BASE_URL:-https://dk0.dev}
|
||||
export MY_EMAIL=${MY_EMAIL:-contact@dk0.dev}
|
||||
export MY_INFO_EMAIL=${MY_INFO_EMAIL:-info@dk0.dev}
|
||||
export MY_PASSWORD="${MY_PASSWORD}"
|
||||
export MY_INFO_PASSWORD="${MY_INFO_PASSWORD}"
|
||||
export ADMIN_BASIC_AUTH="${ADMIN_BASIC_AUTH}"
|
||||
export LOG_LEVEL=${LOG_LEVEL:-info}
|
||||
export PORT=${PORT:-3000}
|
||||
|
||||
# Log which variables are set (without revealing secrets)
|
||||
log "Environment variables configured:"
|
||||
log " - NODE_ENV: ${NODE_ENV}"
|
||||
log " - NEXT_PUBLIC_BASE_URL: ${NEXT_PUBLIC_BASE_URL}"
|
||||
log " - MY_EMAIL: ${MY_EMAIL}"
|
||||
log " - MY_INFO_EMAIL: ${MY_INFO_EMAIL}"
|
||||
log " - MY_PASSWORD: [SET]"
|
||||
log " - MY_INFO_PASSWORD: [SET]"
|
||||
log " - ADMIN_BASIC_AUTH: [SET]"
|
||||
log " - LOG_LEVEL: ${LOG_LEVEL}"
|
||||
log " - PORT: ${PORT}"
|
||||
|
||||
# Check if container is running
|
||||
if [ "$(docker inspect -f '{{.State.Running}}' "$CONTAINER_NAME" 2>/dev/null)" = "true" ]; then
|
||||
log "📦 Stopping existing container..."
|
||||
docker stop "$CONTAINER_NAME" || true
|
||||
docker rm "$CONTAINER_NAME" || true
|
||||
fi
|
||||
|
||||
# Check if port is available
|
||||
if lsof -Pi :$PORT -sTCP:LISTEN -t >/dev/null ; then
|
||||
warning "Port $PORT is in use. Trying backup port $BACKUP_PORT"
|
||||
DEPLOY_PORT=$BACKUP_PORT
|
||||
else
|
||||
DEPLOY_PORT=$PORT
|
||||
fi
|
||||
|
||||
# Start new container with minimal environment variables
|
||||
log "🚀 Starting new container on port $DEPLOY_PORT..."
|
||||
docker run -d \
|
||||
--name "$CONTAINER_NAME" \
|
||||
--restart unless-stopped \
|
||||
-p "$DEPLOY_PORT:3000" \
|
||||
-e NODE_ENV=production \
|
||||
-e NEXT_PUBLIC_BASE_URL=https://dk0.dev \
|
||||
-e MY_EMAIL=contact@dk0.dev \
|
||||
-e MY_INFO_EMAIL=info@dk0.dev \
|
||||
-e MY_PASSWORD=test-password \
|
||||
-e MY_INFO_PASSWORD=test-password \
|
||||
-e ADMIN_BASIC_AUTH=admin:test123 \
|
||||
-e LOG_LEVEL=info \
|
||||
"$IMAGE_NAME:latest" || {
|
||||
error "Failed to start container"
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Wait for container to be ready
|
||||
log "⏳ Waiting for container to be ready..."
|
||||
sleep 20
|
||||
|
||||
# Check if container is actually running
|
||||
if [ "$(docker inspect -f '{{.State.Running}}' "$CONTAINER_NAME" 2>/dev/null)" != "true" ]; then
|
||||
error "Container failed to start or crashed"
|
||||
log "Container logs:"
|
||||
docker logs "$CONTAINER_NAME" --tail=50
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Health check
|
||||
log "🏥 Performing health check..."
|
||||
HEALTH_CHECK_TIMEOUT=180
|
||||
HEALTH_CHECK_INTERVAL=5
|
||||
ELAPSED=0
|
||||
|
||||
while [ $ELAPSED -lt $HEALTH_CHECK_TIMEOUT ]; do
|
||||
# Check if container is still running
|
||||
if [ "$(docker inspect -f '{{.State.Running}}' "$CONTAINER_NAME" 2>/dev/null)" != "true" ]; then
|
||||
error "Container stopped during health check"
|
||||
log "Container logs:"
|
||||
docker logs "$CONTAINER_NAME" --tail=50
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Try health check endpoint
|
||||
if curl -f "http://localhost:$DEPLOY_PORT/api/health" > /dev/null 2>&1; then
|
||||
success "✅ Application is healthy!"
|
||||
break
|
||||
fi
|
||||
|
||||
sleep $HEALTH_CHECK_INTERVAL
|
||||
ELAPSED=$((ELAPSED + HEALTH_CHECK_INTERVAL))
|
||||
echo -n "."
|
||||
done
|
||||
|
||||
if [ $ELAPSED -ge $HEALTH_CHECK_TIMEOUT ]; then
|
||||
error "Health check timeout. Application may not be running properly."
|
||||
log "Container status:"
|
||||
docker inspect "$CONTAINER_NAME" --format='{{.State.Status}} - {{.State.Health.Status}}'
|
||||
log "Container logs:"
|
||||
docker logs "$CONTAINER_NAME" --tail=100
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Step 4: Verification
|
||||
log "✅ Step 4: Verifying deployment..."
|
||||
|
||||
# Test main page
|
||||
if curl -f "http://localhost:$DEPLOY_PORT/" > /dev/null 2>&1; then
|
||||
success "✅ Main page is accessible"
|
||||
else
|
||||
error "❌ Main page is not accessible"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Show container status
|
||||
log "📊 Container status:"
|
||||
docker ps --filter "name=$CONTAINER_NAME" --format "table {{.Names}}\t{{.Status}}\t{{.Ports}}"
|
||||
|
||||
# Show resource usage
|
||||
log "📈 Resource usage:"
|
||||
docker stats --no-stream --format "table {{.Container}}\t{{.CPUPerc}}\t{{.MemUsage}}" "$CONTAINER_NAME"
|
||||
|
||||
# Final success message
|
||||
success "🎉 Simplified Gitea deployment completed successfully!"
|
||||
log "🌐 Application is available at: http://localhost:$DEPLOY_PORT"
|
||||
log "🏥 Health check endpoint: http://localhost:$DEPLOY_PORT/api/health"
|
||||
log "📊 Container name: $CONTAINER_NAME"
|
||||
log "📝 Logs: docker logs $CONTAINER_NAME"
|
||||
|
||||
# Update deployment log
|
||||
echo "$(date): Simplified Gitea deployment successful - Port: $DEPLOY_PORT - Image: $IMAGE_NAME:$TIMESTAMP" >> "$LOG_FILE"
|
||||
|
||||
exit 0
|
||||
@@ -1,257 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Gitea-specific deployment script
|
||||
# Optimiert für lokalen Gitea Runner
|
||||
|
||||
set -e
|
||||
|
||||
# Configuration
|
||||
PROJECT_NAME="portfolio"
|
||||
CONTAINER_NAME="portfolio-app"
|
||||
IMAGE_NAME="portfolio-app"
|
||||
PORT=3000
|
||||
BACKUP_PORT=3001
|
||||
LOG_FILE="./logs/gitea-deploy.log"
|
||||
|
||||
# Colors for output
|
||||
RED='\033[0;31m'
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[1;33m'
|
||||
BLUE='\033[0;34m'
|
||||
NC='\033[0m' # No Color
|
||||
|
||||
# Logging function
|
||||
log() {
|
||||
echo -e "${BLUE}[$(date +'%Y-%m-%d %H:%M:%S')]${NC} $1" | tee -a "$LOG_FILE"
|
||||
}
|
||||
|
||||
error() {
|
||||
echo -e "${RED}[ERROR]${NC} $1" | tee -a "$LOG_FILE"
|
||||
}
|
||||
|
||||
success() {
|
||||
echo -e "${GREEN}[SUCCESS]${NC} $1" | tee -a "$LOG_FILE"
|
||||
}
|
||||
|
||||
warning() {
|
||||
echo -e "${YELLOW}[WARNING]${NC} $1" | tee -a "$LOG_FILE"
|
||||
}
|
||||
|
||||
# Check if running as root (skip in CI environments)
|
||||
if [[ $EUID -eq 0 ]] && [[ -z "$CI" ]]; then
|
||||
error "This script should not be run as root (use CI=true to override)"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Check if Docker is running
|
||||
if ! docker info > /dev/null 2>&1; then
|
||||
error "Docker is not running. Please start Docker and try again."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Check if we're in the right directory
|
||||
if [ ! -f "package.json" ] || [ ! -f "Dockerfile" ]; then
|
||||
error "Please run this script from the project root directory"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
log "🚀 Starting Gitea deployment for $PROJECT_NAME"
|
||||
|
||||
# Step 1: Code Quality Checks
|
||||
log "📋 Step 1: Running code quality checks..."
|
||||
|
||||
# Run linting
|
||||
log "🔍 Running ESLint..."
|
||||
npm run lint || {
|
||||
error "ESLint failed. Please fix the issues before deploying."
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Run tests
|
||||
log "🧪 Running tests..."
|
||||
npm run test:production || {
|
||||
error "Tests failed. Please fix the issues before deploying."
|
||||
exit 1
|
||||
}
|
||||
|
||||
success "✅ Code quality checks passed"
|
||||
|
||||
# Step 2: Build Application
|
||||
log "🔨 Step 2: Building application..."
|
||||
|
||||
# Build Next.js application
|
||||
log "📦 Building Next.js application..."
|
||||
npm run build || {
|
||||
error "Build failed"
|
||||
exit 1
|
||||
}
|
||||
|
||||
success "✅ Application built successfully"
|
||||
|
||||
# Step 3: Docker Operations
|
||||
log "🐳 Step 3: Docker operations..."
|
||||
|
||||
# Build Docker image
|
||||
log "🏗️ Building Docker image..."
|
||||
docker build -t "$IMAGE_NAME:latest" . || {
|
||||
error "Docker build failed"
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Tag with timestamp
|
||||
TIMESTAMP=$(date +%Y%m%d-%H%M%S)
|
||||
docker tag "$IMAGE_NAME:latest" "$IMAGE_NAME:$TIMESTAMP"
|
||||
|
||||
success "✅ Docker image built successfully"
|
||||
|
||||
# Step 4: Deployment
|
||||
log "🚀 Step 4: Deploying application..."
|
||||
|
||||
# Export environment variables for docker-compose compatibility
|
||||
log "📝 Exporting environment variables..."
|
||||
export NODE_ENV=${NODE_ENV:-production}
|
||||
export NEXT_PUBLIC_BASE_URL=${NEXT_PUBLIC_BASE_URL:-https://dk0.dev}
|
||||
export MY_EMAIL=${MY_EMAIL:-contact@dk0.dev}
|
||||
export MY_INFO_EMAIL=${MY_INFO_EMAIL:-info@dk0.dev}
|
||||
export MY_PASSWORD="${MY_PASSWORD}"
|
||||
export MY_INFO_PASSWORD="${MY_INFO_PASSWORD}"
|
||||
export ADMIN_BASIC_AUTH="${ADMIN_BASIC_AUTH}"
|
||||
export LOG_LEVEL=${LOG_LEVEL:-info}
|
||||
export PORT=${PORT:-3000}
|
||||
|
||||
# Log which variables are set (without revealing secrets)
|
||||
log "Environment variables configured:"
|
||||
log " - NODE_ENV: ${NODE_ENV}"
|
||||
log " - NEXT_PUBLIC_BASE_URL: ${NEXT_PUBLIC_BASE_URL}"
|
||||
log " - MY_EMAIL: ${MY_EMAIL}"
|
||||
log " - MY_INFO_EMAIL: ${MY_INFO_EMAIL}"
|
||||
log " - MY_PASSWORD: [SET]"
|
||||
log " - MY_INFO_PASSWORD: [SET]"
|
||||
log " - ADMIN_BASIC_AUTH: [SET]"
|
||||
log " - LOG_LEVEL: ${LOG_LEVEL}"
|
||||
log " - PORT: ${PORT}"
|
||||
|
||||
# Check if container is running
|
||||
if [ "$(docker inspect -f '{{.State.Running}}' "$CONTAINER_NAME" 2>/dev/null)" = "true" ]; then
|
||||
log "📦 Stopping existing container..."
|
||||
docker stop "$CONTAINER_NAME" || true
|
||||
docker rm "$CONTAINER_NAME" || true
|
||||
fi
|
||||
|
||||
# Check if port is available
|
||||
if lsof -Pi :$PORT -sTCP:LISTEN -t >/dev/null ; then
|
||||
warning "Port $PORT is in use. Trying backup port $BACKUP_PORT"
|
||||
DEPLOY_PORT=$BACKUP_PORT
|
||||
else
|
||||
DEPLOY_PORT=$PORT
|
||||
fi
|
||||
|
||||
# Start new container with environment variables
|
||||
log "🚀 Starting new container on port $DEPLOY_PORT..."
|
||||
docker run -d \
|
||||
--name "$CONTAINER_NAME" \
|
||||
--restart unless-stopped \
|
||||
-p "$DEPLOY_PORT:3000" \
|
||||
-e NODE_ENV=production \
|
||||
-e NEXT_PUBLIC_BASE_URL=https://dk0.dev \
|
||||
-e MY_EMAIL=contact@dk0.dev \
|
||||
-e MY_INFO_EMAIL=info@dk0.dev \
|
||||
-e MY_PASSWORD="${MY_PASSWORD:-your-email-password}" \
|
||||
-e MY_INFO_PASSWORD="${MY_INFO_PASSWORD:-your-info-email-password}" \
|
||||
-e ADMIN_BASIC_AUTH="${ADMIN_BASIC_AUTH:-admin:your_secure_password_here}" \
|
||||
-e LOG_LEVEL=info \
|
||||
"$IMAGE_NAME:latest" || {
|
||||
error "Failed to start container"
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Wait for container to be ready
|
||||
log "⏳ Waiting for container to be ready..."
|
||||
sleep 15
|
||||
|
||||
# Check if container is actually running
|
||||
if [ "$(docker inspect -f '{{.State.Running}}' "$CONTAINER_NAME" 2>/dev/null)" != "true" ]; then
|
||||
error "Container failed to start or crashed"
|
||||
log "Container logs:"
|
||||
docker logs "$CONTAINER_NAME" --tail=50
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Health check
|
||||
log "🏥 Performing health check..."
|
||||
HEALTH_CHECK_TIMEOUT=120
|
||||
HEALTH_CHECK_INTERVAL=3
|
||||
ELAPSED=0
|
||||
|
||||
while [ $ELAPSED -lt $HEALTH_CHECK_TIMEOUT ]; do
|
||||
# Check if container is still running
|
||||
if [ "$(docker inspect -f '{{.State.Running}}' "$CONTAINER_NAME" 2>/dev/null)" != "true" ]; then
|
||||
error "Container stopped during health check"
|
||||
log "Container logs:"
|
||||
docker logs "$CONTAINER_NAME" --tail=50
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Try health check endpoint
|
||||
if curl -f "http://localhost:$DEPLOY_PORT/api/health" > /dev/null 2>&1; then
|
||||
success "✅ Application is healthy!"
|
||||
break
|
||||
fi
|
||||
|
||||
sleep $HEALTH_CHECK_INTERVAL
|
||||
ELAPSED=$((ELAPSED + HEALTH_CHECK_INTERVAL))
|
||||
echo -n "."
|
||||
done
|
||||
|
||||
if [ $ELAPSED -ge $HEALTH_CHECK_TIMEOUT ]; then
|
||||
error "Health check timeout. Application may not be running properly."
|
||||
log "Container status:"
|
||||
docker inspect "$CONTAINER_NAME" --format='{{.State.Status}} - {{.State.Health.Status}}'
|
||||
log "Container logs:"
|
||||
docker logs "$CONTAINER_NAME" --tail=100
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Step 5: Verification
|
||||
log "✅ Step 5: Verifying deployment..."
|
||||
|
||||
# Test main page
|
||||
if curl -f "http://localhost:$DEPLOY_PORT/" > /dev/null 2>&1; then
|
||||
success "✅ Main page is accessible"
|
||||
else
|
||||
error "❌ Main page is not accessible"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Show container status
|
||||
log "📊 Container status:"
|
||||
docker ps --filter "name=$CONTAINER_NAME" --format "table {{.Names}}\t{{.Status}}\t{{.Ports}}"
|
||||
|
||||
# Show resource usage
|
||||
log "📈 Resource usage:"
|
||||
docker stats --no-stream --format "table {{.Container}}\t{{.CPUPerc}}\t{{.MemUsage}}" "$CONTAINER_NAME"
|
||||
|
||||
# Step 6: Cleanup
|
||||
log "🧹 Step 6: Cleaning up old images..."
|
||||
|
||||
# Remove old images (keep last 3 versions)
|
||||
docker images "$IMAGE_NAME" --format "table {{.Tag}}\t{{.ID}}" | tail -n +2 | head -n -3 | awk '{print $2}' | xargs -r docker rmi || {
|
||||
warning "No old images to remove"
|
||||
}
|
||||
|
||||
# Clean up unused Docker resources
|
||||
docker system prune -f --volumes || {
|
||||
warning "Failed to clean up Docker resources"
|
||||
}
|
||||
|
||||
# Final success message
|
||||
success "🎉 Gitea deployment completed successfully!"
|
||||
log "🌐 Application is available at: http://localhost:$DEPLOY_PORT"
|
||||
log "🏥 Health check endpoint: http://localhost:$DEPLOY_PORT/api/health"
|
||||
log "📊 Container name: $CONTAINER_NAME"
|
||||
log "📝 Logs: docker logs $CONTAINER_NAME"
|
||||
|
||||
# Update deployment log
|
||||
echo "$(date): Gitea deployment successful - Port: $DEPLOY_PORT - Image: $IMAGE_NAME:$TIMESTAMP" >> "$LOG_FILE"
|
||||
|
||||
exit 0
|
||||
@@ -1,192 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Gitea Runner Setup Script
|
||||
# Installiert und konfiguriert einen lokalen Gitea Runner
|
||||
|
||||
set -e
|
||||
|
||||
# Configuration
|
||||
GITEA_URL="${GITEA_URL:-http://localhost:3000}"
|
||||
RUNNER_NAME="${RUNNER_NAME:-portfolio-runner}"
|
||||
RUNNER_LABELS="${RUNNER_LABELS:-ubuntu-latest,self-hosted,portfolio}"
|
||||
RUNNER_WORK_DIR="${RUNNER_WORK_DIR:-/tmp/gitea-runner}"
|
||||
|
||||
# Colors for output
|
||||
RED='\033[0;31m'
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[1;33m'
|
||||
BLUE='\033[0;34m'
|
||||
NC='\033[0m' # No Color
|
||||
|
||||
# Logging function
|
||||
log() {
|
||||
echo -e "${BLUE}[$(date +'%Y-%m-%d %H:%M:%S')]${NC} $1"
|
||||
}
|
||||
|
||||
error() {
|
||||
echo -e "${RED}[ERROR]${NC} $1"
|
||||
}
|
||||
|
||||
success() {
|
||||
echo -e "${GREEN}[SUCCESS]${NC} $1"
|
||||
}
|
||||
|
||||
warning() {
|
||||
echo -e "${YELLOW}[WARNING]${NC} $1"
|
||||
}
|
||||
|
||||
# Check if running as root (skip in CI environments)
|
||||
if [[ $EUID -eq 0 ]] && [[ -z "$CI" ]]; then
|
||||
error "This script should not be run as root (use CI=true to override)"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
log "🚀 Setting up Gitea Runner for Portfolio"
|
||||
|
||||
# Check if Gitea URL is accessible
|
||||
log "🔍 Checking Gitea server accessibility..."
|
||||
if ! curl -f "$GITEA_URL" > /dev/null 2>&1; then
|
||||
error "Cannot access Gitea server at $GITEA_URL"
|
||||
error "Please make sure Gitea is running and accessible"
|
||||
exit 1
|
||||
fi
|
||||
success "✅ Gitea server is accessible"
|
||||
|
||||
# Create runner directory
|
||||
log "📁 Creating runner directory..."
|
||||
mkdir -p "$RUNNER_WORK_DIR"
|
||||
cd "$RUNNER_WORK_DIR"
|
||||
|
||||
# Download Gitea Runner
|
||||
log "📥 Downloading Gitea Runner..."
|
||||
RUNNER_VERSION="latest"
|
||||
RUNNER_ARCH="linux-amd64"
|
||||
|
||||
# Get latest version
|
||||
if [ "$RUNNER_VERSION" = "latest" ]; then
|
||||
RUNNER_VERSION=$(curl -s https://api.github.com/repos/woodpecker-ci/woodpecker/releases/latest | grep -o '"tag_name": "[^"]*' | grep -o '[^"]*$')
|
||||
fi
|
||||
|
||||
RUNNER_URL="https://github.com/woodpecker-ci/woodpecker/releases/download/${RUNNER_VERSION}/woodpecker-agent_${RUNNER_VERSION}_${RUNNER_ARCH}.tar.gz"
|
||||
|
||||
log "Downloading from: $RUNNER_URL"
|
||||
curl -L -o woodpecker-agent.tar.gz "$RUNNER_URL"
|
||||
|
||||
# Extract runner
|
||||
log "📦 Extracting Gitea Runner..."
|
||||
tar -xzf woodpecker-agent.tar.gz
|
||||
chmod +x woodpecker-agent
|
||||
|
||||
success "✅ Gitea Runner downloaded and extracted"
|
||||
|
||||
# Create systemd service
|
||||
log "⚙️ Creating systemd service..."
|
||||
sudo tee /etc/systemd/system/gitea-runner.service > /dev/null <<EOF
|
||||
[Unit]
|
||||
Description=Gitea Runner for Portfolio
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
User=$USER
|
||||
WorkingDirectory=$RUNNER_WORK_DIR
|
||||
ExecStart=$RUNNER_WORK_DIR/woodpecker-agent
|
||||
Restart=always
|
||||
RestartSec=5
|
||||
Environment=WOODPECKER_SERVER=$GITEA_URL
|
||||
Environment=WOODPECKER_AGENT_SECRET=
|
||||
Environment=WOODPECKER_LOG_LEVEL=info
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
EOF
|
||||
|
||||
# Reload systemd
|
||||
sudo systemctl daemon-reload
|
||||
|
||||
success "✅ Systemd service created"
|
||||
|
||||
# Instructions for manual registration
|
||||
log "📋 Manual registration required:"
|
||||
echo ""
|
||||
echo "1. Go to your Gitea instance: $GITEA_URL"
|
||||
echo "2. Navigate to: Settings → Actions → Runners"
|
||||
echo "3. Click 'Create new Runner'"
|
||||
echo "4. Copy the registration token"
|
||||
echo "5. Run the following command:"
|
||||
echo ""
|
||||
echo " cd $RUNNER_WORK_DIR"
|
||||
echo " ./woodpecker-agent register --server $GITEA_URL --token YOUR_TOKEN"
|
||||
echo ""
|
||||
echo "6. After registration, start the service:"
|
||||
echo " sudo systemctl enable gitea-runner"
|
||||
echo " sudo systemctl start gitea-runner"
|
||||
echo ""
|
||||
echo "7. Check status:"
|
||||
echo " sudo systemctl status gitea-runner"
|
||||
echo ""
|
||||
|
||||
# Create helper scripts
|
||||
log "📝 Creating helper scripts..."
|
||||
|
||||
# Start script
|
||||
cat > "$RUNNER_WORK_DIR/start-runner.sh" << 'EOF'
|
||||
#!/bin/bash
|
||||
echo "Starting Gitea Runner..."
|
||||
sudo systemctl start gitea-runner
|
||||
sudo systemctl status gitea-runner
|
||||
EOF
|
||||
|
||||
# Stop script
|
||||
cat > "$RUNNER_WORK_DIR/stop-runner.sh" << 'EOF'
|
||||
#!/bin/bash
|
||||
echo "Stopping Gitea Runner..."
|
||||
sudo systemctl stop gitea-runner
|
||||
EOF
|
||||
|
||||
# Status script
|
||||
cat > "$RUNNER_WORK_DIR/status-runner.sh" << 'EOF'
|
||||
#!/bin/bash
|
||||
echo "Gitea Runner Status:"
|
||||
sudo systemctl status gitea-runner
|
||||
echo ""
|
||||
echo "Logs (last 20 lines):"
|
||||
sudo journalctl -u gitea-runner -n 20 --no-pager
|
||||
EOF
|
||||
|
||||
# Logs script
|
||||
cat > "$RUNNER_WORK_DIR/logs-runner.sh" << 'EOF'
|
||||
#!/bin/bash
|
||||
echo "Gitea Runner Logs:"
|
||||
sudo journalctl -u gitea-runner -f
|
||||
EOF
|
||||
|
||||
chmod +x "$RUNNER_WORK_DIR"/*.sh
|
||||
|
||||
success "✅ Helper scripts created"
|
||||
|
||||
# Create environment file
|
||||
cat > "$RUNNER_WORK_DIR/.env" << EOF
|
||||
# Gitea Runner Configuration
|
||||
GITEA_URL=$GITEA_URL
|
||||
RUNNER_NAME=$RUNNER_NAME
|
||||
RUNNER_LABELS=$RUNNER_LABELS
|
||||
RUNNER_WORK_DIR=$RUNNER_WORK_DIR
|
||||
EOF
|
||||
|
||||
log "📋 Setup Summary:"
|
||||
echo " • Runner Directory: $RUNNER_WORK_DIR"
|
||||
echo " • Gitea URL: $GITEA_URL"
|
||||
echo " • Runner Name: $RUNNER_NAME"
|
||||
echo " • Labels: $RUNNER_LABELS"
|
||||
echo " • Helper Scripts: $RUNNER_WORK_DIR/*.sh"
|
||||
echo ""
|
||||
|
||||
log "🎯 Next Steps:"
|
||||
echo "1. Register the runner in Gitea web interface"
|
||||
echo "2. Enable and start the service"
|
||||
echo "3. Test with a workflow run"
|
||||
echo ""
|
||||
|
||||
success "🎉 Gitea Runner setup completed!"
|
||||
log "📁 All files are in: $RUNNER_WORK_DIR"
|
||||
@@ -1,79 +0,0 @@
|
||||
|
||||
/* eslint-disable @typescript-eslint/no-require-imports */
|
||||
const fetch = require('node-fetch');
|
||||
require('dotenv').config();
|
||||
|
||||
const DIRECTUS_URL = process.env.DIRECTUS_URL || 'https://cms.dk0.dev';
|
||||
const DIRECTUS_TOKEN = process.env.DIRECTUS_STATIC_TOKEN;
|
||||
|
||||
async function setupSnippets() {
|
||||
console.log('📦 Setting up Snippets collection...');
|
||||
|
||||
// 1. Create Collection
|
||||
try {
|
||||
await fetch(`${DIRECTUS_URL}/collections`, {
|
||||
method: 'POST',
|
||||
headers: { 'Authorization': `Bearer ${DIRECTUS_TOKEN}`, 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({
|
||||
collection: 'snippets',
|
||||
meta: { icon: 'terminal', display_template: '{{title}}' },
|
||||
schema: { name: 'snippets' }
|
||||
})
|
||||
});
|
||||
} catch (_e) {}
|
||||
|
||||
// 2. Add Fields
|
||||
const fields = [
|
||||
{ field: 'status', type: 'string', meta: { interface: 'select-dropdown' }, schema: { default_value: 'published' } },
|
||||
{ field: 'title', type: 'string', meta: { interface: 'input' } },
|
||||
{ field: 'category', type: 'string', meta: { interface: 'input' } },
|
||||
{ field: 'code', type: 'text', meta: { interface: 'input-code' } },
|
||||
{ field: 'description', type: 'text', meta: { interface: 'textarea' } },
|
||||
{ field: 'language', type: 'string', meta: { interface: 'input' }, schema: { default_value: 'javascript' } },
|
||||
{ field: 'featured', type: 'boolean', meta: { interface: 'boolean' }, schema: { default_value: false } }
|
||||
];
|
||||
|
||||
for (const f of fields) {
|
||||
try {
|
||||
await fetch(`${DIRECTUS_URL}/fields/snippets`, {
|
||||
method: 'POST',
|
||||
headers: { 'Authorization': `Bearer ${DIRECTUS_TOKEN}`, 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify(f)
|
||||
});
|
||||
} catch (_e) {}
|
||||
}
|
||||
|
||||
// 3. Add Example Data
|
||||
const exampleSnippets = [
|
||||
{
|
||||
title: 'Traefik SSL Config',
|
||||
category: 'Docker',
|
||||
language: 'yaml',
|
||||
featured: true,
|
||||
description: "Meine Standard-Konfiguration für automatisches SSL via Let's Encrypt in Docker Swarm.",
|
||||
code: "labels:\n - \"traefik.enable=true\"\n - \"traefik.http.routers.myapp.rule=Host(`example.com`)\"\n - \"traefik.http.routers.myapp.entrypoints=websecure\"\n - \"traefik.http.routers.myapp.tls.certresolver=myresolver\""
|
||||
},
|
||||
{
|
||||
title: 'Docker Cleanup Alias',
|
||||
category: 'ZSH',
|
||||
language: 'bash',
|
||||
featured: true,
|
||||
description: 'Ein einfacher Alias, um ungenutzte Docker-Container, Images und Volumes schnell zu entfernen.',
|
||||
code: "alias dclean='docker system prune -af --volumes'"
|
||||
}
|
||||
];
|
||||
|
||||
for (const s of exampleSnippets) {
|
||||
try {
|
||||
await fetch(`${DIRECTUS_URL}/items/snippets`, {
|
||||
method: 'POST',
|
||||
headers: { 'Authorization': `Bearer ${DIRECTUS_TOKEN}`, 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify(s)
|
||||
});
|
||||
} catch (_e) {}
|
||||
}
|
||||
|
||||
console.log('✅ Snippets setup complete!');
|
||||
}
|
||||
|
||||
setupSnippets();
|
||||
Reference in New Issue
Block a user