Compare commits

...

2 Commits

Author SHA1 Message Date
feedf30be1 env vars
Some checks failed
Build & Deploy KLZ Cables / build-and-deploy (push) Failing after 3m30s
2026-01-26 12:57:06 +01:00
b596c22011 logs 2026-01-26 12:15:34 +01:00
8 changed files with 221 additions and 27 deletions

3
.env
View File

@@ -5,10 +5,11 @@ WORDPRESS_APP_PASSWORD=DlJH 49dp fC3a Itc3 Sl7Z Wz0k'
# Umami Analytics
NEXT_PUBLIC_UMAMI_WEBSITE_ID=59a7db94-0100-4c7e-98ef-99f45b17f9c3
NEXT_PUBLIC_UMAMI_SCRIPT_URL=https://analytics.infra.mintel.me/script.js
UMAMI_SCRIPT_URL=https://analytics.infra.mintel.me/script.js
# GlitchTip (Sentry protocol)
SENTRY_DSN=https://c10957d0182245b1a2a806ac2d34a197@errors.infra.mintel.me/1
NEXT_PUBLIC_SENTRY_DSN=https://c10957d0182245b1a2a806ac2d34a197@klz-cables.com/errors/1
# SMTP Configuration
MAIL_HOST=smtp.eu.mailgun.org

View File

@@ -6,10 +6,11 @@ WORDPRESS_APP_PASSWORD=
# Umami Analytics
NEXT_PUBLIC_UMAMI_WEBSITE_ID=
NEXT_PUBLIC_UMAMI_SCRIPT_URL=https://analytics.infra.mintel.me/script.js
UMAMI_SCRIPT_URL=https://analytics.infra.mintel.me/script.js
# GlitchTip (Sentry protocol)
SENTRY_DSN=
# Client-side DSN should use the proxy path: https://[key]@[domain]/errors/[id]
NEXT_PUBLIC_SENTRY_DSN=
# SMTP Configuration

View File

@@ -11,49 +11,240 @@ jobs:
runs-on: docker
steps:
# ═══════════════════════════════════════════════════════════════════════════════
# LOGGING: Workflow Start - Full Transparency
# ═══════════════════════════════════════════════════════════════════════════════
- name: 📋 Log Workflow Start
run: |
echo "╔══════════════════════════════════════════════════════════════════════════════╗"
echo "║ KLZ Cables Deployment Workflow Started ║"
echo "╚══════════════════════════════════════════════════════════════════════════════╝"
echo ""
echo "📋 Workflow Information:"
echo " • Repository: ${{ github.repository }}"
echo " • Branch: ${{ github.ref }}"
echo " • Commit: ${{ github.sha }}"
echo " • Actor: ${{ github.actor }}"
echo " • Run ID: ${{ github.run_id }}"
echo " • Timestamp: $(date -u +'%Y-%m-%d %H:%M:%S UTC')"
echo ""
echo "🔍 Environment Details:"
echo " • Runner OS: ${{ runner.os }}"
echo " • Workspace: ${{ github.workspace }}"
echo ""
- name: Checkout repository
uses: actions/checkout@v4
- name: Login to private registry
# ═══════════════════════════════════════════════════════════════════════════════
# LOGGING: Registry Login Phase
# ═══════════════════════════════════════════════════════════════════════════════
- name: 🔐 Login to private registry
run: |
echo "${{ secrets.REGISTRY_PASS }}" | \
docker login registry.infra.mintel.me \
-u "${{ secrets.REGISTRY_USER }}" --password-stdin
echo "╔══════════════════════════════════════════════════════════════════════════════╗"
echo "║ Step: Registry Login ║"
echo "╚══════════════════════════════════════════════════════════════════════════════╝"
echo ""
echo "🔐 Authenticating with private registry..."
echo " Registry: registry.infra.mintel.me"
echo " User: ${{ secrets.REGISTRY_USER != '' && '***' || 'NOT SET' }}"
echo ""
# Execute login with error handling
if echo "${{ secrets.REGISTRY_PASS }}" | docker login registry.infra.mintel.me -u "${{ secrets.REGISTRY_USER }}" --password-stdin 2>&1; then
echo "✅ Registry login successful"
else
echo "❌ Registry login failed"
exit 1
fi
echo ""
- name: Build Docker image
# ═══════════════════════════════════════════════════════════════════════════════
# LOGGING: Build Phase
# ═══════════════════════════════════════════════════════════════════════════════
- name: 🏗️ Build Docker image
run: |
echo "╔══════════════════════════════════════════════════════════════════════════════╗"
echo "║ Step: Build Docker Image ║"
echo "╚══════════════════════════════════════════════════════════════════════════════╝"
echo ""
echo "🏗️ Building Docker image with buildx..."
echo " Platform: linux/arm64"
echo " Target: registry.infra.mintel.me/mintel/klz-cables.com:latest"
echo ""
echo "📦 Build Arguments:"
echo " • NEXT_PUBLIC_UMAMI_WEBSITE_ID: ${{ secrets.NEXT_PUBLIC_UMAMI_WEBSITE_ID != '' && '***' || 'NOT SET' }}"
echo " • NEXT_PUBLIC_SENTRY_DSN: ${{ secrets.SENTRY_DSN != '' && '***' || 'NOT SET' }}"
echo ""
echo "⏱️ Build started at: $(date -u +'%Y-%m-%d %H:%M:%S UTC')"
echo ""
# Execute build with detailed logging
set -e
docker buildx build \
--pull \
--platform linux/arm64 \
--build-arg NEXT_PUBLIC_UMAMI_WEBSITE_ID="${{ secrets.NEXT_PUBLIC_UMAMI_WEBSITE_ID }}" \
--build-arg NEXT_PUBLIC_UMAMI_SCRIPT_URL="${{ secrets.NEXT_PUBLIC_UMAMI_SCRIPT_URL }}" \
--build-arg NEXT_PUBLIC_SENTRY_DSN="${{ secrets.SENTRY_DSN }}" \
-t registry.infra.mintel.me/mintel/klz-cables.com:latest \
--push .
BUILD_EXIT_CODE=$?
if [ $BUILD_EXIT_CODE -eq 0 ]; then
echo ""
echo "✅ Build completed successfully at: $(date -u +'%Y-%m-%d %H:%M:%S UTC')"
echo ""
echo "📊 Image Details:"
docker inspect registry.infra.mintel.me/mintel/klz-cables.com:latest --format=' • Size: {{.Size | div 1024 | div 1024}}MB'
docker inspect registry.infra.mintel.me/mintel/klz-cables.com:latest --format=' • Created: {{.Created}}'
docker inspect registry.infra.mintel.me/mintel/klz-cables.com:latest --format=' • Architecture: {{.Architecture}}'
else
echo ""
echo "❌ Build failed with exit code: $BUILD_EXIT_CODE"
exit $BUILD_EXIT_CODE
fi
echo ""
# Alternative ohne Buildx (wenn du kein Multi-Platform brauchst):
# docker build \
# --pull \
# --build-arg ... \
# -t registry.infra.mintel.me/mintel/klz-cables.com:latest .
# docker push registry.infra.mintel.me/mintel/klz-cables.com:latest
- name: Deploy to production server
# ═══════════════════════════════════════════════════════════════════════════════
# LOGGING: Deployment Phase
# ═══════════════════════════════════════════════════════════════════════════════
- name: 🚀 Deploy to production server
run: |
echo "╔══════════════════════════════════════════════════════════════════════════════╗"
echo "║ Step: Deploy to Production Server ║"
echo "╚══════════════════════════════════════════════════════════════════════════════╝"
echo ""
echo "🚀 Starting deployment process..."
echo " Target Server: alpha.mintel.me"
echo " Deploy User: deploy"
echo " Target Path: /home/deploy/sites/klz-cables.com"
echo ""
# Setup SSH with logging
echo "🔐 Setting up SSH connection..."
mkdir -p ~/.ssh
echo "${{ secrets.ALPHA_SSH_KEY }}" > ~/.ssh/id_ed25519
chmod 600 ~/.ssh/id_ed25519
echo "🔑 Adding host to known_hosts..."
ssh-keyscan -H alpha.mintel.me >> ~/.ssh/known_hosts 2>/dev/null
# Use SSH with connection keepalive and execute commands directly
if [ $? -eq 0 ]; then
echo "✅ Host key added successfully"
else
echo "⚠️ Warning: Could not add host key"
fi
echo ""
# Execute deployment commands with detailed logging
echo "📡 Connecting to server and executing deployment commands..."
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
# Execute remote commands with error handling and logging
ssh -o StrictHostKeyChecking=accept-new \
-o ServerAliveInterval=30 \
-o ServerAliveCountMax=3 \
-o ConnectTimeout=10 \
deploy@alpha.mintel.me \
"echo '${{ secrets.REGISTRY_PASS }}' | docker login registry.infra.mintel.me -u '${{ secrets.REGISTRY_USER }}' --password-stdin && \
cd /home/deploy/sites/klz-cables.com && \
docker compose pull && \
docker compose up -d --force-recreate --remove-orphans && \
docker image prune -f"
"set -e
echo '━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━'
echo '📡 Remote Deployment Started'
echo '━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━'
echo ''
echo '🔐 Logging into registry on remote server...'
echo '${{ secrets.REGISTRY_PASS }}' | docker login registry.infra.mintel.me -u '${{ secrets.REGISTRY_USER }}' --password-stdin
if [ \$? -eq 0 ]; then
echo '✅ Remote registry login successful'
else
echo '❌ Remote registry login failed'
exit 1
fi
echo ''
echo '📂 Changing to deployment directory...'
cd /home/deploy/sites/klz-cables.com
echo '✅ Current directory: \$(pwd)'
echo ''
echo '📥 Pulling latest images...'
docker compose pull
if [ \$? -eq 0 ]; then
echo '✅ Image pull completed'
else
echo '❌ Image pull failed'
exit 1
fi
echo ''
echo '🔄 Starting containers with force-recreate...'
docker compose up -d --force-recreate --remove-orphans
if [ \$? -eq 0 ]; then
echo '✅ Containers started successfully'
else
echo '❌ Container startup failed'
exit 1
fi
echo ''
echo '🧹 Cleaning up old images...'
docker image prune -f
echo '✅ Cleanup completed'
echo ''
echo '📊 Container Status:'
docker compose ps --format 'table {{.Name}}\t{{.State}}\t{{.Status}}'
echo ''
echo '━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━'
echo '✅ Remote Deployment Completed Successfully'
echo '━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━'
" 2>&1
DEPLOY_EXIT_CODE=$?
echo ""
if [ $DEPLOY_EXIT_CODE -eq 0 ]; then
echo "✅ Deployment completed successfully at: $(date -u +'%Y-%m-%d %H:%M:%S UTC')"
else
echo "❌ Deployment failed with exit code: $DEPLOY_EXIT_CODE"
echo ""
echo "🔍 Troubleshooting Tips:"
echo " • Check server connectivity: ping alpha.mintel.me"
echo " • Verify SSH key permissions on server"
echo " • Check disk space on target server"
echo " • Review docker compose configuration"
exit $DEPLOY_EXIT_CODE
fi
echo ""
# ═══════════════════════════════════════════════════════════════════════════════
# LOGGING: Workflow Summary
# ═══════════════════════════════════════════════════════════════════════════════
- name: 📊 Workflow Summary
if: always()
run: |
echo "╔══════════════════════════════════════════════════════════════════════════════╗"
echo "║ Workflow Summary ║"
echo "╚══════════════════════════════════════════════════════════════════════════════╝"
echo ""
echo "📊 Final Status:"
echo " • Workflow: ${{ job.status }}"
echo " • Completed: $(date -u +'%Y-%m-%d %H:%M:%S UTC')"
echo ""
echo "🎯 Deployment Target:"
echo " • Image: registry.infra.mintel.me/mintel/klz-cables.com:latest"
echo " • Server: alpha.mintel.me"
echo " • Service: klz-cables.com"
echo ""
echo "🔐 Security Notes:"
echo " • All secrets are masked (*** ) in logs"
echo " • SSH keys are created with 600 permissions"
echo " • Passwords are never displayed in plain text"
echo ""
echo "╔══════════════════════════════════════════════════════════════════════════════╗"
if [ "${{ job.status }}" == "success" ]; then
echo "║ ✅ DEPLOYMENT SUCCESSFUL ║"
else
echo "║ ❌ DEPLOYMENT FAILED ║"
fi
echo "╚══════════════════════════════════════════════════════════════════════════════╝"

View File

@@ -76,7 +76,7 @@ export class UmamiAnalyticsService implements AnalyticsService {
if (typeof window === 'undefined') {
const { getServerAppServices } = require('../create-services.server');
const websiteId = process.env.NEXT_PUBLIC_UMAMI_WEBSITE_ID;
const umamiUrl = process.env.NEXT_PUBLIC_UMAMI_SCRIPT_URL?.replace('/script.js', '') || 'https://analytics.infra.mintel.me';
const umamiUrl = process.env.UMAMI_SCRIPT_URL?.replace('/script.js', '') || 'https://analytics.infra.mintel.me';
if (!websiteId) return;

View File

@@ -21,6 +21,7 @@ export function getServerAppServices(): AppServices {
NEXT_PUBLIC_UMAMI_WEBSITE_ID: process.env.NEXT_PUBLIC_UMAMI_WEBSITE_ID
? `***${process.env.NEXT_PUBLIC_UMAMI_WEBSITE_ID.slice(-4)}`
: 'not set',
UMAMI_SCRIPT_URL: process.env.UMAMI_SCRIPT_URL ?? 'not set',
SENTRY_DSN: process.env.SENTRY_DSN
? `***${process.env.SENTRY_DSN.slice(-4)}`
: 'not set',

View File

@@ -80,6 +80,7 @@ export function getAppServices(): AppServices {
NEXT_PUBLIC_UMAMI_WEBSITE_ID: process.env.NEXT_PUBLIC_UMAMI_WEBSITE_ID
? `***${process.env.NEXT_PUBLIC_UMAMI_WEBSITE_ID.slice(-4)}`
: 'not set',
UMAMI_SCRIPT_URL: process.env.UMAMI_SCRIPT_URL ?? 'not set',
NEXT_PUBLIC_SENTRY_DSN: process.env.NEXT_PUBLIC_SENTRY_DSN
? `***${process.env.NEXT_PUBLIC_SENTRY_DSN.slice(-4)}`
: 'not set',

View File

@@ -343,7 +343,7 @@ const nextConfig = {
contentSecurityPolicy: "default-src 'self'; script-src 'none'; sandbox;",
},
async rewrites() {
const umamiUrl = process.env.NEXT_PUBLIC_UMAMI_SCRIPT_URL?.replace('/script.js', '') || 'https://analytics.infra.mintel.me';
const umamiUrl = (process.env.UMAMI_SCRIPT_URL || 'https://analytics.infra.mintel.me').replace('/script.js', '');
const glitchtipUrl = process.env.SENTRY_DSN ? new URL(process.env.SENTRY_DSN).origin : 'https://errors.infra.mintel.me';
return [

View File

@@ -1,10 +1,9 @@
import * as Sentry from '@sentry/nextjs';
const dsn = process.env.NEXT_PUBLIC_SENTRY_DSN || 'https://c10957d0182245b1a2a806ac2d34a197@klz-cables.com/errors/1';
const dsn = process.env.NEXT_PUBLIC_SENTRY_DSN;
Sentry.init({
dsn,
tunnel: '/errors/tunnel',
enabled: Boolean(dsn),
tracesSampleRate: 0,
});