Compare commits

..

14 Commits

Author SHA1 Message Date
denshooter
b34deb3c81 Optimize CI/CD pipeline - remove redundant builds
Some checks failed
CI/CD Pipeline (Simple) / test-and-build (push) Has been cancelled
CI/CD Pipeline (Simple) / production (push) Has been cancelled
CI/CD Pipeline / test (push) Successful in 8m40s
Security Scan / security (push) Successful in 7m47s
CI/CD Pipeline / security (push) Successful in 5m14s
CI/CD Pipeline / build (push) Successful in 4m1s
CI/CD Pipeline / deploy (push) Failing after 24s
- Replace inefficient multi-job pipeline with simple single-job approach
- Eliminate duplicate builds (npm build + docker build)
- Reduce pipeline complexity and execution time
- Keep old pipeline as backup (ci-cd-old.yml)
- Simple pipeline: Install → Lint → Test → Build → Security → Deploy (production only)
- Non-production branches: Install → Lint → Test → Build → Security
2025-09-12 23:28:11 +02:00
denshooter
a4c61172f6 Fix Gitea Actions compatibility and improve container configuration
Some checks failed
CI/CD Pipeline / test (push) Successful in 9m19s
CI/CD Pipeline / security (push) Has been cancelled
CI/CD Pipeline / build (push) Has been cancelled
CI/CD Pipeline / deploy (push) Has been cancelled
Security Scan / security (push) Has been cancelled
- Update all GitHub Actions to v3 for Gitea compatibility
- Fix artifact upload/download actions (v4 -> v3)
- Remove GitHub-specific features (GITHUB_STEP_SUMMARY)
- Add complete Docker Compose configuration with PostgreSQL and Redis
- Add environment secrets support for all workflows
- Add debug workflow for secrets verification
- Add comprehensive documentation for secrets setup
- Improve container networking and health checks
2025-09-12 23:18:01 +02:00
denshooter
f7e0172111 Refactor security scanning and database setup
Some checks failed
CI/CD Pipeline / test (push) Successful in 10m54s
Security Scan / security (push) Failing after 5m21s
CI/CD Pipeline / security (push) Successful in 5m25s
CI/CD Pipeline / build (push) Failing after 2m27s
CI/CD Pipeline / deploy (push) Has been skipped
- Update security scan workflow to utilize a dedicated script for checking secrets, improving detection accuracy.
- Modify database connection setup in multiple scripts to use an environment variable fallback for DATABASE_URL, enhancing flexibility in different environments.
2025-09-11 11:17:35 +02:00
denshooter
c4bc27273e Implement security scanning workflows and scripts
Some checks failed
CI/CD Pipeline / test (push) Successful in 10m59s
Security Scan / security (push) Failing after 5m27s
CI/CD Pipeline / security (push) Successful in 5m57s
CI/CD Pipeline / build (push) Failing after 3m3s
CI/CD Pipeline / deploy (push) Has been skipped
- Update CI/CD workflow to use specific Trivy version and change output format for vulnerability results.
- Add fallback npm audit step in case Trivy scan fails.
- Create a new security scan workflow that runs on push and pull request events, including scheduled scans.
- Introduce a security scan script to perform npm audit, Trivy scans, and check for potential secrets in the codebase.
- Ensure results are uploaded as artifacts for review and maintain retention policies for scan results.
2025-09-11 10:44:03 +02:00
denshooter
519ca43168 Update Dockerfile and Next.js configuration; enhance contact components
Some checks failed
CI/CD Pipeline / test (push) Successful in 10m55s
CI/CD Pipeline / security (push) Failing after 5m20s
CI/CD Pipeline / build (push) Has been skipped
CI/CD Pipeline / deploy (push) Has been skipped
- Modify Dockerfile to install curl without recommended packages for a leaner image.
- Update Next.js configuration to set outputFileTracingRoot for better Docker compatibility.
- Revise contact components to improve messaging and clarity, changing "Get In Touch" to "Contact Me" and enhancing descriptions for collaboration opportunities.
- Clean up Prisma schema by removing unnecessary comments and restructuring the Project model for clarity.
2025-09-11 10:13:35 +02:00
denshooter
09d925745d Update Docker configuration and add Gitea CI/CD workflows
Some checks failed
CI/CD Pipeline / test (push) Successful in 12m0s
CI/CD Pipeline / security (push) Failing after 6m6s
CI/CD Pipeline / build (push) Has been skipped
CI/CD Pipeline / deploy (push) Has been skipped
- Change Docker image in docker-compose.prod.yml to use 'portfolio-app:latest'.
- Add new scripts for Gitea deployment and setup of Gitea runner.
- Introduce CI/CD workflows for automated testing, security scanning, and deployment in Gitea.
- Enhance package.json with new deployment scripts for Gitea integration.
2025-09-10 15:14:55 +02:00
denshooter
07cf999a9e Fix Docker deployment - use built image instead of building locally
- Change docker-compose.prod.yml to use ghcr.io image instead of building
- Add --force-recreate flag to ensure new container is created
- Add docker image prune to remove old images
- This should fix the issue where old container version is served
2025-09-10 12:01:56 +02:00
denshooter
8ea4fc3fd3 Fix caching issues - disable static generation and add cache-busting headers
- Disable generateStaticParams to prevent static generation
- Add Cache-Control headers to force revalidation
- This should fix the issue where new routes are not available after deployment
2025-09-10 11:46:52 +02:00
denshooter
0bcba1643e Trigger deployment - force rebuild 2025-09-10 11:44:43 +02:00
denshooter
24ecc720c5 Fix final merge conflict marker in email/respond/route.tsx 2025-09-10 11:14:20 +02:00
denshooter
690d9e1cfb Fix remaining merge conflicts and linter errors
- Remove merge conflict markers from AnalyticsDashboard.tsx
- Fix merge conflicts in email/respond/route.tsx
- Use dev versions of EmailManager and ModernAdminDashboard
- Add eslint-disable for Image icon in editor
2025-09-10 11:13:27 +02:00
denshooter
b44250fe0e Merge dev branch into production - resolve conflicts
- Updated admin URLs from /admin to /manage
- Integrated new admin dashboard and email management features
- Added authentication system and project management
- Resolved conflicts in DEV-SETUP.md, README.md, email routes, and components
- Removed old admin page in favor of new manage page
2025-09-10 11:06:36 +02:00
denshooter
0af21d6fc6 Dev (#51)
* update

* cleanup

* fixing linting and tests errors

* Refactor API Parameter Handling and Update Email Transport

 Updated API Route Parameters:
- Changed parameter type from `{ id: string }` to `Promise<{ id: string }>` in PUT and DELETE methods for better async handling.

 Fixed Email Transport Creation:
- Updated `nodemailer.createTransporter` to `nodemailer.createTransport` for correct transport configuration.

 Refactored AnalyticsDashboard Component:
- Changed export from default to named export for better modularity.

 Enhanced Email Responder Toast:
- Updated toast structure to include additional properties for better user feedback.

🎯 Overall Improvements:
- Improved async handling in API routes.
- Ensured correct usage of nodemailer.
- Enhanced component exports and user notifications.

* 🔧 Update Redis Configuration in Docker Compose

 Changed Redis URL:
- Updated the Redis connection string in docker-compose.prod.yml to use the new shared Redis service.

 Removed Redis Dependency Check:
- Eliminated the health check dependency for the Redis service as it is no longer required.

🎯 Improvements:
- Streamlined Redis configuration for production deployment.
2025-09-08 08:53:07 +02:00
denshooter
a842cb04f3 Dev (#50)
* update

* cleanup

* fixing linting and tests errors

* Refactor API Parameter Handling and Update Email Transport

 Updated API Route Parameters:
- Changed parameter type from `{ id: string }` to `Promise<{ id: string }>` in PUT and DELETE methods for better async handling.

 Fixed Email Transport Creation:
- Updated `nodemailer.createTransporter` to `nodemailer.createTransport` for correct transport configuration.

 Refactored AnalyticsDashboard Component:
- Changed export from default to named export for better modularity.

 Enhanced Email Responder Toast:
- Updated toast structure to include additional properties for better user feedback.

🎯 Overall Improvements:
- Improved async handling in API routes.
- Ensured correct usage of nodemailer.
- Enhanced component exports and user notifications.
2025-09-08 08:36:16 +02:00
27 changed files with 1531 additions and 106 deletions

View File

@@ -0,0 +1,169 @@
name: CI/CD Pipeline
on:
push:
branches: [ main, production ]
pull_request:
branches: [ main, production ]
env:
NODE_VERSION: '20'
DOCKER_IMAGE: portfolio-app
CONTAINER_NAME: portfolio-app
jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Run linting
run: npm run lint
- name: Run tests
run: npm run test
- name: Build application
run: npm run build
security:
runs-on: ubuntu-latest
needs: test
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Run Trivy vulnerability scanner
uses: aquasecurity/trivy-action@0.30.0
with:
scan-type: 'fs'
scan-ref: '.'
format: 'table'
output: 'trivy-results.txt'
timeout: '10m'
ignore-unfixed: true
severity: 'CRITICAL,HIGH'
continue-on-error: true
- name: Run npm audit as fallback
if: failure()
run: |
echo "Trivy failed, running npm audit as fallback..."
npm audit --audit-level=high || true
echo "Security scan completed with fallback method"
- name: Upload Trivy scan results
uses: actions/upload-artifact@v3
if: always()
with:
name: trivy-results
path: trivy-results.txt
retention-days: 7
build:
runs-on: ubuntu-latest
needs: test
if: github.ref == 'refs/heads/production'
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Build Docker image
run: |
docker build -t ${{ env.DOCKER_IMAGE }}:latest .
docker tag ${{ env.DOCKER_IMAGE }}:latest ${{ env.DOCKER_IMAGE }}:$(date +%Y%m%d-%H%M%S)
- name: Save Docker image
run: |
docker save ${{ env.DOCKER_IMAGE }}:latest | gzip > ${{ env.DOCKER_IMAGE }}.tar.gz
- name: Upload Docker image artifact
uses: actions/upload-artifact@v3
with:
name: docker-image
path: ${{ env.DOCKER_IMAGE }}.tar.gz
retention-days: 7
deploy:
runs-on: ubuntu-latest
needs: build
if: github.ref == 'refs/heads/production'
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Download Docker image artifact
uses: actions/download-artifact@v3
with:
name: docker-image
path: ./
- name: Load Docker image
run: |
gunzip -c ${{ env.DOCKER_IMAGE }}.tar.gz | docker load
- name: Stop existing services
run: |
docker-compose -f docker-compose.workflow.yml down || true
- name: Verify secrets before deployment
run: |
echo "🔍 Verifying secrets..."
if [ -z "${{ secrets.NEXT_PUBLIC_BASE_URL }}" ]; then
echo "❌ NEXT_PUBLIC_BASE_URL secret is missing!"
exit 1
fi
if [ -z "${{ secrets.MY_EMAIL }}" ]; then
echo "❌ MY_EMAIL secret is missing!"
exit 1
fi
if [ -z "${{ secrets.ADMIN_BASIC_AUTH }}" ]; then
echo "❌ ADMIN_BASIC_AUTH secret is missing!"
exit 1
fi
echo "✅ All required secrets are present"
- name: Start services with Docker Compose
run: |
docker-compose -f docker-compose.workflow.yml up -d
env:
NEXT_PUBLIC_BASE_URL: ${{ secrets.NEXT_PUBLIC_BASE_URL }}
MY_EMAIL: ${{ secrets.MY_EMAIL }}
MY_INFO_EMAIL: ${{ secrets.MY_INFO_EMAIL }}
MY_PASSWORD: ${{ secrets.MY_PASSWORD }}
MY_INFO_PASSWORD: ${{ secrets.MY_INFO_PASSWORD }}
ADMIN_BASIC_AUTH: ${{ secrets.ADMIN_BASIC_AUTH }}
- name: Verify container environment
run: |
echo "🔍 Checking container environment variables..."
sleep 10
docker exec portfolio-app sh -c 'echo "NODE_ENV: $NODE_ENV" && echo "DATABASE_URL: $DATABASE_URL" && echo "REDIS_URL: $REDIS_URL" && echo "NEXT_PUBLIC_BASE_URL: $NEXT_PUBLIC_BASE_URL" && echo "MY_EMAIL: $MY_EMAIL" && echo "ADMIN_BASIC_AUTH: [HIDDEN]"'
- name: Wait for container to be ready
run: |
sleep 10
timeout 60 bash -c 'until curl -f http://localhost:3000/api/health; do sleep 2; done'
- name: Health check
run: |
curl -f http://localhost:3000/api/health
echo "✅ Deployment successful!"
- name: Cleanup old images
run: |
docker image prune -f
docker system prune -f

127
.gitea/workflows/ci-cd.yml Normal file
View File

@@ -0,0 +1,127 @@
name: CI/CD Pipeline (Simple)
on:
push:
branches: [ main, production ]
pull_request:
branches: [ main, production ]
env:
NODE_VERSION: '20'
DOCKER_IMAGE: portfolio-app
CONTAINER_NAME: portfolio-app
jobs:
# Single job that does everything for non-production branches
test-and-build:
runs-on: ubuntu-latest
if: github.ref != 'refs/heads/production'
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Run linting
run: npm run lint
- name: Run tests
run: npm run test
- name: Build application
run: npm run build
- name: Run security scan
run: |
echo "🔍 Running npm audit..."
npm audit --audit-level=high || echo "⚠️ Some vulnerabilities found, but continuing..."
# Production deployment pipeline
production:
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/production'
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Run linting
run: npm run lint
- name: Run tests
run: npm run test
- name: Build application
run: npm run build
- name: Run security scan
run: |
echo "🔍 Running npm audit..."
npm audit --audit-level=high || echo "⚠️ Some vulnerabilities found, but continuing..."
- name: Build Docker image
run: |
docker build -t ${{ env.DOCKER_IMAGE }}:latest .
docker tag ${{ env.DOCKER_IMAGE }}:latest ${{ env.DOCKER_IMAGE }}:$(date +%Y%m%d-%H%M%S)
- name: Stop existing services
run: |
docker-compose -f docker-compose.workflow.yml down || true
- name: Verify secrets before deployment
run: |
echo "🔍 Verifying secrets..."
if [ -z "${{ secrets.NEXT_PUBLIC_BASE_URL }}" ]; then
echo "❌ NEXT_PUBLIC_BASE_URL secret is missing!"
exit 1
fi
if [ -z "${{ secrets.MY_EMAIL }}" ]; then
echo "❌ MY_EMAIL secret is missing!"
exit 1
fi
if [ -z "${{ secrets.ADMIN_BASIC_AUTH }}" ]; then
echo "❌ ADMIN_BASIC_AUTH secret is missing!"
exit 1
fi
echo "✅ All required secrets are present"
- name: Start services with Docker Compose
run: |
docker-compose -f docker-compose.workflow.yml up -d
env:
NEXT_PUBLIC_BASE_URL: ${{ secrets.NEXT_PUBLIC_BASE_URL }}
MY_EMAIL: ${{ secrets.MY_EMAIL }}
MY_INFO_EMAIL: ${{ secrets.MY_INFO_EMAIL }}
MY_PASSWORD: ${{ secrets.MY_PASSWORD }}
MY_INFO_PASSWORD: ${{ secrets.MY_INFO_PASSWORD }}
ADMIN_BASIC_AUTH: ${{ secrets.ADMIN_BASIC_AUTH }}
- name: Wait for container to be ready
run: |
sleep 10
timeout 60 bash -c 'until curl -f http://localhost:3000/api/health; do sleep 2; done'
- name: Health check
run: |
curl -f http://localhost:3000/api/health
echo "✅ Deployment successful!"
- name: Cleanup old images
run: |
docker image prune -f
docker system prune -f

View File

@@ -0,0 +1,126 @@
name: Debug Secrets
on:
workflow_dispatch:
push:
branches: [ main ]
jobs:
debug-secrets:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Debug Environment Variables
run: |
echo "🔍 Checking if secrets are available..."
echo ""
# Check each secret (without revealing values)
if [ -n "${{ secrets.NEXT_PUBLIC_BASE_URL }}" ]; then
echo "✅ NEXT_PUBLIC_BASE_URL: Set (length: ${#NEXT_PUBLIC_BASE_URL})"
else
echo "❌ NEXT_PUBLIC_BASE_URL: Not set"
fi
if [ -n "${{ secrets.MY_EMAIL }}" ]; then
echo "✅ MY_EMAIL: Set (length: ${#MY_EMAIL})"
else
echo "❌ MY_EMAIL: Not set"
fi
if [ -n "${{ secrets.MY_INFO_EMAIL }}" ]; then
echo "✅ MY_INFO_EMAIL: Set (length: ${#MY_INFO_EMAIL})"
else
echo "❌ MY_INFO_EMAIL: Not set"
fi
if [ -n "${{ secrets.MY_PASSWORD }}" ]; then
echo "✅ MY_PASSWORD: Set (length: ${#MY_PASSWORD})"
else
echo "❌ MY_PASSWORD: Not set"
fi
if [ -n "${{ secrets.MY_INFO_PASSWORD }}" ]; then
echo "✅ MY_INFO_PASSWORD: Set (length: ${#MY_INFO_PASSWORD})"
else
echo "❌ MY_INFO_PASSWORD: Not set"
fi
if [ -n "${{ secrets.ADMIN_BASIC_AUTH }}" ]; then
echo "✅ ADMIN_BASIC_AUTH: Set (length: ${#ADMIN_BASIC_AUTH})"
else
echo "❌ ADMIN_BASIC_AUTH: Not set"
fi
echo ""
echo "📋 Summary:"
echo "Total secrets checked: 6"
echo "Set secrets: $(echo "${{ secrets.NEXT_PUBLIC_BASE_URL }}${{ secrets.MY_EMAIL }}${{ secrets.MY_INFO_EMAIL }}${{ secrets.MY_PASSWORD }}${{ secrets.MY_INFO_PASSWORD }}${{ secrets.ADMIN_BASIC_AUTH }}" | grep -o . | wc -l)"
env:
NEXT_PUBLIC_BASE_URL: ${{ secrets.NEXT_PUBLIC_BASE_URL }}
MY_EMAIL: ${{ secrets.MY_EMAIL }}
MY_INFO_EMAIL: ${{ secrets.MY_INFO_EMAIL }}
MY_PASSWORD: ${{ secrets.MY_PASSWORD }}
MY_INFO_PASSWORD: ${{ secrets.MY_INFO_PASSWORD }}
ADMIN_BASIC_AUTH: ${{ secrets.ADMIN_BASIC_AUTH }}
- name: Test Docker Environment
run: |
echo "🐳 Testing Docker environment with secrets..."
# Create a test container to verify environment variables
docker run --rm \
-e NODE_ENV=production \
-e DATABASE_URL=postgresql://portfolio_user:portfolio_pass@postgres:5432/portfolio_db?schema=public \
-e REDIS_URL=redis://redis:6379 \
-e NEXT_PUBLIC_BASE_URL="${{ secrets.NEXT_PUBLIC_BASE_URL }}" \
-e MY_EMAIL="${{ secrets.MY_EMAIL }}" \
-e MY_INFO_EMAIL="${{ secrets.MY_INFO_EMAIL }}" \
-e MY_PASSWORD="${{ secrets.MY_PASSWORD }}" \
-e MY_INFO_PASSWORD="${{ secrets.MY_INFO_PASSWORD }}" \
-e ADMIN_BASIC_AUTH="${{ secrets.ADMIN_BASIC_AUTH }}" \
alpine:latest sh -c '
echo "Environment variables in container:"
echo "NODE_ENV: $NODE_ENV"
echo "DATABASE_URL: $DATABASE_URL"
echo "REDIS_URL: $REDIS_URL"
echo "NEXT_PUBLIC_BASE_URL: $NEXT_PUBLIC_BASE_URL"
echo "MY_EMAIL: $MY_EMAIL"
echo "MY_INFO_EMAIL: $MY_INFO_EMAIL"
echo "MY_PASSWORD: [HIDDEN - length: ${#MY_PASSWORD}]"
echo "MY_INFO_PASSWORD: [HIDDEN - length: ${#MY_INFO_PASSWORD}]"
echo "ADMIN_BASIC_AUTH: [HIDDEN - length: ${#ADMIN_BASIC_AUTH}]"
'
- name: Validate Secret Formats
run: |
echo "🔐 Validating secret formats..."
# Check NEXT_PUBLIC_BASE_URL format
if [[ "${{ secrets.NEXT_PUBLIC_BASE_URL }}" =~ ^https?:// ]]; then
echo "✅ NEXT_PUBLIC_BASE_URL: Valid URL format"
else
echo "❌ NEXT_PUBLIC_BASE_URL: Invalid URL format (should start with http:// or https://)"
fi
# Check email formats
if [[ "${{ secrets.MY_EMAIL }}" =~ ^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$ ]]; then
echo "✅ MY_EMAIL: Valid email format"
else
echo "❌ MY_EMAIL: Invalid email format"
fi
if [[ "${{ secrets.MY_INFO_EMAIL }}" =~ ^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$ ]]; then
echo "✅ MY_INFO_EMAIL: Valid email format"
else
echo "❌ MY_INFO_EMAIL: Invalid email format"
fi
# Check ADMIN_BASIC_AUTH format (should be username:password)
if [[ "${{ secrets.ADMIN_BASIC_AUTH }}" =~ ^[^:]+:.+$ ]]; then
echo "✅ ADMIN_BASIC_AUTH: Valid format (username:password)"
else
echo "❌ ADMIN_BASIC_AUTH: Invalid format (should be username:password)"
fi

View File

@@ -0,0 +1,78 @@
name: Quick Deploy
on:
push:
branches: [ main ]
workflow_dispatch:
env:
NODE_VERSION: '20'
DOCKER_IMAGE: portfolio-app
CONTAINER_NAME: portfolio-app
jobs:
quick-deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Build application
run: npm run build
- name: Build Docker image
run: |
docker build -t ${{ env.DOCKER_IMAGE }}:latest .
- name: Stop existing services
run: |
docker-compose -f docker-compose.workflow.yml down || true
- name: Verify secrets before deployment
run: |
echo "🔍 Verifying secrets..."
if [ -z "${{ secrets.NEXT_PUBLIC_BASE_URL }}" ]; then
echo "❌ NEXT_PUBLIC_BASE_URL secret is missing!"
exit 1
fi
if [ -z "${{ secrets.MY_EMAIL }}" ]; then
echo "❌ MY_EMAIL secret is missing!"
exit 1
fi
if [ -z "${{ secrets.ADMIN_BASIC_AUTH }}" ]; then
echo "❌ ADMIN_BASIC_AUTH secret is missing!"
exit 1
fi
echo "✅ All required secrets are present"
- name: Start services with Docker Compose
run: |
docker-compose -f docker-compose.workflow.yml up -d
env:
NEXT_PUBLIC_BASE_URL: ${{ secrets.NEXT_PUBLIC_BASE_URL }}
MY_EMAIL: ${{ secrets.MY_EMAIL }}
MY_INFO_EMAIL: ${{ secrets.MY_INFO_EMAIL }}
MY_PASSWORD: ${{ secrets.MY_PASSWORD }}
MY_INFO_PASSWORD: ${{ secrets.MY_INFO_PASSWORD }}
ADMIN_BASIC_AUTH: ${{ secrets.ADMIN_BASIC_AUTH }}
- name: Verify container environment
run: |
echo "🔍 Checking container environment variables..."
sleep 10
docker exec portfolio-app sh -c 'echo "NODE_ENV: $NODE_ENV" && echo "DATABASE_URL: $DATABASE_URL" && echo "REDIS_URL: $REDIS_URL" && echo "NEXT_PUBLIC_BASE_URL: $NEXT_PUBLIC_BASE_URL" && echo "MY_EMAIL: $MY_EMAIL" && echo "ADMIN_BASIC_AUTH: [HIDDEN]"'
- name: Health check
run: |
sleep 10
curl -f http://localhost:3000/api/health
echo "✅ Quick deployment successful!"

View File

@@ -0,0 +1,78 @@
name: Security Scan
on:
push:
branches: [ main, production ]
pull_request:
branches: [ main, production ]
schedule:
- cron: '0 2 * * 1' # Weekly on Monday at 2 AM
jobs:
security:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: '20'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Run npm audit
run: |
echo "🔍 Running npm audit for dependency vulnerabilities..."
npm audit --audit-level=high --json > npm-audit-results.json || true
npm audit --audit-level=high || echo "⚠️ Some vulnerabilities found, but continuing..."
- name: Run Trivy (with fallback)
run: |
echo "🔍 Attempting Trivy scan..."
# Try to install and run Trivy directly
wget -qO- https://raw.githubusercontent.com/aquasecurity/trivy/main/contrib/install.sh | sh -s -- -b /usr/local/bin
trivy fs --scanners vuln,secret --format table . > trivy-results.txt 2>&1 || {
echo "⚠️ Trivy scan failed, but continuing with other checks..."
echo "Trivy scan failed due to network issues" > trivy-results.txt
}
- name: Check for secrets
run: |
echo "🔍 Checking for potential secrets..."
chmod +x scripts/check-secrets.sh
if ./scripts/check-secrets.sh; then
echo "✅ No secrets found in code"
else
echo "❌ Secrets detected - please review"
exit 1
fi
- name: Upload security scan results
uses: actions/upload-artifact@v3
if: always()
with:
name: security-scan-results
path: |
npm-audit-results.json
trivy-results.txt
retention-days: 30
- name: Security scan summary
run: |
echo "## Security Scan Summary"
echo "### NPM Audit Results"
if [ -f npm-audit-results.json ]; then
echo "✅ NPM audit completed"
else
echo "❌ NPM audit failed"
fi
echo "### Trivy Results"
if [ -f trivy-results.txt ]; then
echo "✅ Trivy scan completed"
else
echo "❌ Trivy scan failed"
fi

View File

@@ -190,8 +190,11 @@ jobs:
# Stop and remove old container
docker compose -f $COMPOSE_FILE down || true
# Start new container
docker compose -f $COMPOSE_FILE up -d
# Remove old images to force using new one
docker image prune -f
# Start new container with force recreate
docker compose -f $COMPOSE_FILE up -d --force-recreate
# Wait for health check
echo "Waiting for application to be healthy..."

29
.secretsignore Normal file
View File

@@ -0,0 +1,29 @@
# Ignore patterns for secret detection
# These are legitimate authentication patterns, not actual secrets
# Authentication-related code patterns
*password*
*username*
*credentials*
*csrf*
*session*
*token*
*key*
*auth*
# Environment variable references
process.env.*
# Cache and Redis patterns
*cache*
*redis*
# Rate limiting patterns
*rateLimit*
# Next.js build artifacts
.next/
# Generated files
*.d.ts
*.js.map

View File

@@ -4,7 +4,7 @@ FROM node:20 AS base
# Install dependencies only when needed
FROM base AS deps
# Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed.
RUN apt-get update && apt-get install -y curl && rm -rf /var/lib/apt/lists/*
RUN apt-get update && apt-get install -y --no-install-recommends curl && rm -rf /var/lib/apt/lists/*
WORKDIR /app
# Install dependencies based on the preferred package manager

56
GITEA-SECRETS-SETUP.md Normal file
View File

@@ -0,0 +1,56 @@
# Gitea Secrets Setup
Um die GitHub Actions Workflows korrekt zu verwenden, müssen die folgenden Secrets in deinem Gitea Repository konfiguriert werden:
## Secrets konfigurieren
1. Gehe zu deinem Repository in Gitea
2. Klicke auf **Settings****Secrets**
3. Füge die folgenden Secrets hinzu:
### Erforderliche Secrets:
| Secret Name | Beschreibung | Beispiel |
|-------------|--------------|----------|
| `NEXT_PUBLIC_BASE_URL` | Die öffentliche URL deiner Website | `https://dk0.dev` |
| `MY_EMAIL` | Haupt-Email-Adresse für Kontaktformular | `contact@dk0.dev` |
| `MY_INFO_EMAIL` | Info-Email-Adresse | `info@dk0.dev` |
| `MY_PASSWORD` | Passwort für Haupt-Email | `dein_email_passwort` |
| `MY_INFO_PASSWORD` | Passwort für Info-Email | `dein_info_email_passwort` |
| `ADMIN_BASIC_AUTH` | Admin-Basic-Auth für geschützte Bereiche | `admin:dein_sicheres_passwort` |
## Docker Compose Setup
Die Workflows verwenden jetzt `docker-compose.workflow.yml` für eine vollständige Service-Konfiguration:
- **PostgreSQL**: Datenbank für die Anwendung
- **Redis**: Caching und Session-Management
- **Portfolio App**: Die Hauptanwendung
## Netzwerk-Konfiguration
Die Services sind im `portfolio_net` Netzwerk konfiguriert, damit sie miteinander kommunizieren können.
## Health Checks
Alle Services haben Health Checks konfiguriert:
- PostgreSQL: `pg_isready`
- Redis: `redis-cli ping`
- Portfolio App: HTTP Health Check auf `/api/health`
## Troubleshooting
Falls die Workflows fehlschlagen:
1. **Secrets prüfen**: Stelle sicher, dass alle Secrets korrekt konfiguriert sind
2. **Netzwerk prüfen**: Überprüfe, ob das `portfolio_net` Netzwerk existiert
3. **Ports prüfen**: Stelle sicher, dass Port 3000 frei ist
4. **Logs prüfen**: Schaue in die Container-Logs für Fehlermeldungen
```bash
# Container-Logs anzeigen
docker-compose -f docker-compose.workflow.yml logs
# Services-Status prüfen
docker-compose -f docker-compose.workflow.yml ps
```

105
SECRETS-VERIFICATION.md Normal file
View File

@@ -0,0 +1,105 @@
# Secrets Verification Guide
## Wie du überprüfst, ob Secrets korrekt geladen werden
### 1. **Debug-Workflow ausführen**
Ich habe einen speziellen Debug-Workflow erstellt (`.gitea/workflows/debug-secrets.yml`):
1. Gehe zu deinem Repository in Gitea
2. Klicke auf **Actions****Debug Secrets**
3. Klicke auf **Run workflow****Run workflow**
4. Der Workflow wird dir zeigen:
- ✅ Welche Secrets gesetzt sind
- ❌ Welche Secrets fehlen
- 🔐 Ob die Formate korrekt sind
### 2. **Secrets in Gitea überprüfen**
**Manuell in Gitea:**
1. Gehe zu **Settings****Secrets**
2. Überprüfe, ob alle Secrets vorhanden sind:
- `NEXT_PUBLIC_BASE_URL`
- `MY_EMAIL`
- `MY_INFO_EMAIL`
- `MY_PASSWORD`
- `MY_INFO_PASSWORD`
- `ADMIN_BASIC_AUTH`
### 3. **Workflow-Logs überprüfen**
Nach dem Ausführen eines Workflows:
1. Gehe zu **Actions****Workflow runs**
2. Klicke auf den neuesten Run
3. Schaue dir die Logs an, besonders:
- "Verify secrets before deployment"
- "Verify container environment"
### 4. **Container direkt überprüfen**
Falls der Container läuft, kannst du ihn direkt überprüfen:
```bash
# Container-Environment anzeigen
docker exec portfolio-app env | grep -E "(NEXT_PUBLIC_BASE_URL|MY_EMAIL|ADMIN_BASIC_AUTH)"
# Container-Logs anzeigen
docker logs portfolio-app
# Services-Status prüfen
docker-compose -f docker-compose.workflow.yml ps
```
### 5. **Häufige Probleme**
**❌ Secret nicht gesetzt:**
- Gehe zu Gitea → Settings → Secrets
- Füge das fehlende Secret hinzu
**❌ Falsches Format:**
- `NEXT_PUBLIC_BASE_URL`: Muss mit `http://` oder `https://` beginnen
- `MY_EMAIL`: Muss eine gültige Email-Adresse sein
- `ADMIN_BASIC_AUTH`: Muss Format `username:password` haben
**❌ Container kann nicht starten:**
- Überprüfe die Docker-Logs
- Stelle sicher, dass alle Services (PostgreSQL, Redis) laufen
### 6. **Test-Schritte**
1. **Führe den Debug-Workflow aus**
2. **Überprüfe die Ausgabe**
3. **Korrigiere fehlende/falsche Secrets**
4. **Führe einen normalen Workflow aus**
5. **Überprüfe die Container-Environment**
### 7. **Erwartete Ausgabe**
**Bei korrekten Secrets:**
```
✅ NEXT_PUBLIC_BASE_URL: Set (length: 15)
✅ MY_EMAIL: Set (length: 20)
✅ MY_INFO_EMAIL: Set (length: 18)
✅ MY_PASSWORD: Set (length: 12)
✅ MY_INFO_PASSWORD: Set (length: 12)
✅ ADMIN_BASIC_AUTH: Set (length: 15)
```
**Bei fehlenden Secrets:**
```
❌ NEXT_PUBLIC_BASE_URL: Not set
❌ MY_EMAIL: Not set
```
### 8. **Schnelltest**
Führe diesen Befehl aus, um schnell zu testen:
```bash
# Debug-Workflow manuell ausführen
curl -X POST "https://your-gitea-instance.com/api/v1/repos/your-username/portfolio/actions/workflows/debug-secrets.yml/dispatches" \
-H "Authorization: token YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{"ref":"main"}'
```

View File

@@ -93,10 +93,10 @@ const Contact = () => {
className="text-center mb-16"
>
<h2 className="text-4xl md:text-5xl font-bold mb-6 gradient-text">
Get In Touch
Contact Me
</h2>
<p className="text-xl text-gray-400 max-w-2xl mx-auto">
Have a project in mind or want to collaborate? I would love to hear from you!
Interested in working together or have questions about my projects? Feel free to reach out!
</p>
</motion.div>
@@ -111,11 +111,11 @@ const Contact = () => {
>
<div>
<h3 className="text-2xl font-bold text-white mb-6">
Let&apos;s Connect
Get In Touch
</h3>
<p className="text-gray-400 leading-relaxed">
I&apos;m always open to discussing new opportunities, interesting projects,
or just having a chat about technology and innovation.
I&apos;m always available to discuss new opportunities, interesting projects,
or simply chat about technology and innovation.
</p>
</div>

View File

@@ -216,7 +216,7 @@ const Hero = () => {
whileTap={{ scale: 0.95 }}
className="px-8 py-4 text-lg font-semibold border-2 border-gray-600 text-gray-300 hover:text-white hover:border-gray-500 rounded-lg transition-all duration-200"
>
Get In Touch
Contact Me
</motion.a>
</motion.div>

View File

@@ -567,6 +567,7 @@ function EditorPageContent() {
className="p-2 rounded-lg text-gray-300"
title="Image"
>
{/* eslint-disable-next-line jsx-a11y/alt-text */}
<Image className="w-4 h-4" />
</button>
</div>

View File

@@ -42,7 +42,7 @@ export const metadata: Metadata = {
authors: [{name: "Dennis Konkol", url: "https://dk0.dev"}],
openGraph: {
title: "Dennis Konkol | Portfolio",
description: "Explore my projects and get in touch!",
description: "Explore my projects and contact me for collaboration opportunities!",
url: "https://dk0.dev",
siteName: "Dennis Konkol Portfolio",
images: [

View File

@@ -1,8 +1,6 @@
services:
portfolio:
build:
context: .
dockerfile: Dockerfile
image: portfolio-app:latest
container_name: portfolio-app
restart: unless-stopped
ports:

View File

@@ -0,0 +1,81 @@
# Docker Compose configuration for GitHub Actions workflows
# This ensures all required services are running before deployment
services:
portfolio:
image: portfolio-app:latest
container_name: portfolio-app
restart: unless-stopped
ports:
- "3000:3000"
environment:
- NODE_ENV=production
- DATABASE_URL=postgresql://portfolio_user:portfolio_pass@postgres:5432/portfolio_db?schema=public
- REDIS_URL=redis://redis:6379
- NEXT_PUBLIC_BASE_URL=${NEXT_PUBLIC_BASE_URL}
- MY_EMAIL=${MY_EMAIL}
- MY_INFO_EMAIL=${MY_INFO_EMAIL}
- MY_PASSWORD=${MY_PASSWORD}
- MY_INFO_PASSWORD=${MY_INFO_PASSWORD}
- ADMIN_BASIC_AUTH=${ADMIN_BASIC_AUTH}
volumes:
- portfolio_data:/app/.next/cache
networks:
- portfolio_net
depends_on:
postgres:
condition: service_healthy
redis:
condition: service_healthy
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:3000/api/health"]
interval: 30s
timeout: 10s
retries: 3
start_period: 40s
postgres:
image: postgres:16-alpine
container_name: portfolio-postgres
restart: unless-stopped
environment:
- POSTGRES_DB=portfolio_db
- POSTGRES_USER=portfolio_user
- POSTGRES_PASSWORD=portfolio_pass
volumes:
- postgres_data:/var/lib/postgresql/data
networks:
- portfolio_net
healthcheck:
test: ["CMD-SHELL", "pg_isready -U portfolio_user -d portfolio_db"]
interval: 10s
timeout: 5s
retries: 5
start_period: 30s
redis:
image: redis:7-alpine
container_name: portfolio-redis
restart: unless-stopped
volumes:
- redis_data:/data
networks:
- portfolio_net
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 10s
timeout: 5s
retries: 5
start_period: 30s
volumes:
portfolio_data:
driver: local
postgres_data:
driver: local
redis_data:
driver: local
networks:
portfolio_net:
driver: bridge

View File

@@ -8,6 +8,7 @@ dotenv.config({ path: path.resolve(__dirname, '.env') });
const nextConfig: NextConfig = {
// Enable standalone output for Docker
output: 'standalone',
outputFileTracingRoot: path.join(__dirname, '../../'),
// Optimize for production
compress: true,
@@ -41,6 +42,23 @@ const nextConfig: NextConfig = {
formats: ['image/webp', 'image/avif'],
minimumCacheTTL: 60,
},
// Dynamic routes are handled automatically by Next.js
// Add cache-busting headers
async headers() {
return [
{
source: '/(.*)',
headers: [
{
key: 'Cache-Control',
value: 'public, max-age=0, must-revalidate',
},
],
},
];
},
};
import bundleAnalyzer from "@next/bundle-analyzer";

View File

@@ -32,6 +32,8 @@
"deploy": "./scripts/deploy.sh",
"auto-deploy": "./scripts/auto-deploy.sh",
"quick-deploy": "./scripts/quick-deploy.sh",
"gitea-deploy": "./scripts/gitea-deploy.sh",
"setup-gitea-runner": "./scripts/setup-gitea-runner.sh",
"monitor": "./scripts/monitor.sh",
"health": "curl -f http://localhost:3000/api/health"
},

View File

@@ -1,6 +1,3 @@
// This is your Prisma schema file,
// learn more about it in the docs: https://pris.ly/d/prisma-schema
generator client {
provider = "prisma-client-js"
}
@@ -11,46 +8,37 @@ datasource db {
}
model Project {
id Int @id @default(autoincrement())
title String @db.VarChar(255)
description String @db.Text
content String @db.Text
tags String[] @default([])
featured Boolean @default(false)
category String @db.VarChar(100)
date String @db.VarChar(10)
github String? @db.VarChar(500)
live String? @db.VarChar(500)
published Boolean @default(true)
imageUrl String? @db.VarChar(500)
metaDescription String? @db.Text
keywords String? @db.Text
ogImage String? @db.VarChar(500)
schema Json?
id Int @id @default(autoincrement())
title String @db.VarChar(255)
description String
content String
tags String[] @default([])
featured Boolean @default(false)
category String @db.VarChar(100)
date String @db.VarChar(10)
github String? @db.VarChar(500)
live String? @db.VarChar(500)
published Boolean @default(true)
imageUrl String? @db.VarChar(500)
metaDescription String?
keywords String?
ogImage String? @db.VarChar(500)
schema Json?
difficulty Difficulty @default(INTERMEDIATE)
timeToComplete String? @db.VarChar(100)
technologies String[] @default([])
challenges String[] @default([])
lessonsLearned String[] @default([])
futureImprovements String[] @default([])
demoVideo String? @db.VarChar(500)
screenshots String[] @default([])
colorScheme String @default("Dark") @db.VarChar(100)
accessibility Boolean @default(true)
performance Json @default("{\"loadTime\": \"1.5s\", \"bundleSize\": \"50KB\", \"lighthouse\": 90}")
analytics Json @default("{\"likes\": 0, \"views\": 0, \"shares\": 0}")
createdAt DateTime @default(now()) @map("created_at")
updatedAt DateTime @updatedAt @map("updated_at")
// Advanced features
difficulty Difficulty @default(INTERMEDIATE)
timeToComplete String? @db.VarChar(100)
technologies String[] @default([])
challenges String[] @default([])
lessonsLearned String[] @default([])
futureImprovements String[] @default([])
demoVideo String? @db.VarChar(500)
screenshots String[] @default([])
colorScheme String @db.VarChar(100) @default("Dark")
accessibility Boolean @default(true)
// Performance metrics
performance Json @default("{\"lighthouse\": 90, \"bundleSize\": \"50KB\", \"loadTime\": \"1.5s\"}")
// Analytics
analytics Json @default("{\"views\": 0, \"likes\": 0, \"shares\": 0}")
// Timestamps
createdAt DateTime @default(now()) @map("created_at")
updatedAt DateTime @updatedAt @map("updated_at")
// Indexes for performance
@@index([category])
@@index([featured])
@@index([published])
@@ -59,6 +47,49 @@ model Project {
@@index([tags])
}
model PageView {
id Int @id @default(autoincrement())
projectId Int? @map("project_id")
page String @db.VarChar(100)
ip String? @db.VarChar(45)
userAgent String? @map("user_agent")
referrer String? @db.VarChar(500)
timestamp DateTime @default(now())
@@index([projectId])
@@index([timestamp])
@@index([page])
}
model UserInteraction {
id Int @id @default(autoincrement())
projectId Int @map("project_id")
type InteractionType
ip String? @db.VarChar(45)
userAgent String? @map("user_agent")
timestamp DateTime @default(now())
@@index([projectId])
@@index([type])
@@index([timestamp])
}
model Contact {
id Int @id @default(autoincrement())
name String @db.VarChar(255)
email String @db.VarChar(255)
subject String @db.VarChar(500)
message String
responded Boolean @default(false)
responseTemplate String? @map("response_template") @db.VarChar(50)
createdAt DateTime @default(now()) @map("created_at")
updatedAt DateTime @updatedAt @map("updated_at")
@@index([email])
@@index([responded])
@@index([createdAt])
}
enum Difficulty {
BEGINNER
INTERMEDIATE
@@ -66,55 +97,9 @@ enum Difficulty {
EXPERT
}
// Analytics tracking
model PageView {
id Int @id @default(autoincrement())
projectId Int? @map("project_id")
page String @db.VarChar(100)
ip String? @db.VarChar(45)
userAgent String? @db.Text @map("user_agent")
referrer String? @db.VarChar(500)
timestamp DateTime @default(now())
@@index([projectId])
@@index([timestamp])
@@index([page])
}
// User interactions
model UserInteraction {
id Int @id @default(autoincrement())
projectId Int @map("project_id")
type InteractionType
ip String? @db.VarChar(45)
userAgent String? @db.Text @map("user_agent")
timestamp DateTime @default(now())
@@index([projectId])
@@index([type])
@@index([timestamp])
}
enum InteractionType {
LIKE
SHARE
BOOKMARK
COMMENT
}
// Contact form submissions
model Contact {
id Int @id @default(autoincrement())
name String @db.VarChar(255)
email String @db.VarChar(255)
subject String @db.VarChar(500)
message String @db.Text
responded Boolean @default(false)
responseTemplate String? @db.VarChar(50) @map("response_template")
createdAt DateTime @default(now()) @map("created_at")
updatedAt DateTime @updatedAt @map("updated_at")
@@index([email])
@@index([responded])
@@index([createdAt])
}

85
scripts/check-secrets.sh Executable file
View File

@@ -0,0 +1,85 @@
#!/bin/bash
# Advanced Secret Detection Script
# This script checks for actual secrets, not legitimate authentication code
set -e
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color
print_status() {
echo -e "${GREEN}$1${NC}"
}
print_warning() {
echo -e "${YELLOW}⚠️ $1${NC}"
}
print_error() {
echo -e "${RED}$1${NC}"
}
echo "🔍 Advanced secret detection..."
SECRETS_FOUND=false
# Check for hardcoded secrets (more specific patterns)
echo "Checking for hardcoded secrets..."
# Check for actual API keys, tokens, passwords (not variable names)
if grep -r -E "(api[_-]?key|secret[_-]?key|private[_-]?key|access[_-]?token|bearer[_-]?token)\s*[:=]\s*['\"][^'\"]{20,}" \
--include="*.js" --include="*.ts" --include="*.json" --include="*.env*" . | \
grep -v node_modules | grep -v ".git" | grep -v ".next/" | grep -v "test"; then
print_error "Hardcoded API keys or tokens found!"
SECRETS_FOUND=true
fi
# Check for database connection strings with credentials (excluding .env files)
if grep -r -E "(postgresql|mysql|mongodb)://[^:]+:[^@]+@" \
--include="*.js" --include="*.ts" --include="*.json" . | \
grep -v node_modules | grep -v ".git" | grep -v ".next/" | grep -v "test" | \
grep -v ".env"; then
print_error "Database connection strings with credentials found in source code!"
SECRETS_FOUND=true
fi
# Check for AWS/cloud service credentials
if grep -r -E "(aws[_-]?access[_-]?key[_-]?id|aws[_-]?secret[_-]?access[_-]?key|azure[_-]?account[_-]?key|gcp[_-]?service[_-]?account)" \
--include="*.js" --include="*.ts" --include="*.json" --include="*.env*" . | \
grep -v node_modules | grep -v ".git" | grep -v ".next/" | grep -v "test"; then
print_error "Cloud service credentials found!"
SECRETS_FOUND=true
fi
# Check for .env files in git (should be in .gitignore)
if git ls-files | grep -E "\.env$|\.env\."; then
print_error ".env files found in git repository!"
SECRETS_FOUND=true
fi
# Check for common secret file patterns
if find . -name "*.pem" -o -name "*.key" -o -name "*.p12" -o -name "*.pfx" | grep -v node_modules | grep -v ".git"; then
print_error "Certificate or key files found in repository!"
SECRETS_FOUND=true
fi
# Check for JWT secrets or signing keys
if grep -r -E "(jwt[_-]?secret|signing[_-]?key|encryption[_-]?key)\s*[:=]\s*['\"][^'\"]{32,}" \
--include="*.js" --include="*.ts" --include="*.json" --include="*.env*" . | \
grep -v node_modules | grep -v ".git" | grep -v ".next/" | grep -v "test"; then
print_error "JWT secrets or signing keys found!"
SECRETS_FOUND=true
fi
if [ "$SECRETS_FOUND" = false ]; then
print_status "No actual secrets found in code"
else
print_error "Potential secrets detected - please review and remove"
exit 1
fi
echo "🔍 Secret detection completed!"

View File

@@ -51,7 +51,7 @@ exec('docker-compose --version', (error) => {
shell: isWindows,
env: {
...process.env,
DATABASE_URL: 'postgresql://portfolio_user:portfolio_dev_pass@localhost:5432/portfolio_dev?schema=public',
DATABASE_URL: process.env.DATABASE_URL || 'postgresql://portfolio_user:portfolio_dev_pass@localhost:5432/portfolio_dev?schema=public',
REDIS_URL: 'redis://localhost:6379',
NODE_ENV: 'development'
}

View File

@@ -12,7 +12,7 @@ console.log('💡 For full development environment with DB, use: npm run dev:ful
const env = {
...process.env,
NODE_ENV: 'development',
DATABASE_URL: 'postgresql://portfolio_user:portfolio_dev_pass@localhost:5432/portfolio_dev?schema=public',
DATABASE_URL: process.env.DATABASE_URL || 'postgresql://portfolio_user:portfolio_dev_pass@localhost:5432/portfolio_dev?schema=public',
REDIS_URL: 'redis://localhost:6379',
NEXT_PUBLIC_BASE_URL: 'http://localhost:3000'
};

207
scripts/gitea-deploy.sh Executable file
View File

@@ -0,0 +1,207 @@
#!/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
if [[ $EUID -eq 0 ]]; then
error "This script should not be run as root"
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 || {
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..."
# 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
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 \
"$IMAGE_NAME:latest" || {
error "Failed to start container"
exit 1
}
# Wait for container to be ready
log "⏳ Waiting for container to be ready..."
sleep 10
# Health check
log "🏥 Performing health check..."
HEALTH_CHECK_TIMEOUT=60
HEALTH_CHECK_INTERVAL=2
ELAPSED=0
while [ $ELAPSED -lt $HEALTH_CHECK_TIMEOUT ]; do
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 logs:"
docker logs "$CONTAINER_NAME" --tail=50
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

85
scripts/security-scan.sh Executable file
View File

@@ -0,0 +1,85 @@
#!/bin/bash
# Security Scan Script
# This script runs various security checks on the portfolio project
set -e
echo "🔒 Starting security scan..."
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color
# Function to print colored output
print_status() {
echo -e "${GREEN}$1${NC}"
}
print_warning() {
echo -e "${YELLOW}⚠️ $1${NC}"
}
print_error() {
echo -e "${RED}$1${NC}"
}
# Check if we're in the right directory
if [ ! -f "package.json" ]; then
print_error "Please run this script from the project root directory"
exit 1
fi
# 1. NPM Audit
echo "🔍 Running npm audit..."
if npm audit --audit-level=high; then
print_status "NPM audit passed - no high/critical vulnerabilities found"
else
print_warning "NPM audit found vulnerabilities - check the output above"
fi
# 2. Trivy scan (if available)
echo "🔍 Running Trivy vulnerability scan..."
if command -v trivy &> /dev/null; then
if trivy fs --scanners vuln,secret --format table .; then
print_status "Trivy scan completed successfully"
else
print_warning "Trivy scan found issues - check the output above"
fi
else
print_warning "Trivy not installed - skipping Trivy scan"
echo "To install Trivy: brew install trivy"
fi
# 3. Check for secrets using advanced detection
echo "🔍 Checking for potential secrets in code..."
if ./scripts/check-secrets.sh; then
print_status "No secrets found in code"
else
print_error "Secrets detected - please review"
fi
# 4. Check for outdated dependencies
echo "🔍 Checking for outdated dependencies..."
if npm outdated; then
print_status "All dependencies are up to date"
else
print_warning "Some dependencies are outdated - consider updating"
fi
# 5. Check for known vulnerable packages
echo "🔍 Checking for known vulnerable packages..."
if npm audit --audit-level=moderate; then
print_status "No moderate+ vulnerabilities found"
else
print_warning "Some vulnerabilities found - run 'npm audit fix' to attempt fixes"
fi
echo ""
echo "🔒 Security scan completed!"
echo "For more detailed security analysis, consider:"
echo " - Running 'npm audit fix' to fix vulnerabilities"
echo " - Installing Trivy for comprehensive vulnerability scanning"
echo " - Using tools like Snyk or GitHub Dependabot for ongoing monitoring"

View File

@@ -6,7 +6,7 @@ const { exec } = require('child_process');
console.log('🗄️ Setting up database...');
// Set environment variables for development
process.env.DATABASE_URL = 'postgresql://portfolio_user:portfolio_dev_pass@localhost:5432/portfolio_dev?schema=public';
process.env.DATABASE_URL = process.env.DATABASE_URL || 'postgresql://portfolio_user:portfolio_dev_pass@localhost:5432/portfolio_dev?schema=public';
// Function to run command and return promise
function runCommand(command) {

192
scripts/setup-gitea-runner.sh Executable file
View File

@@ -0,0 +1,192 @@
#!/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
if [[ $EUID -eq 0 ]]; then
error "This script should not be run as root"
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"