Files
michaelschiemer/deployment/docs/guides/deployment-commands.md
Michael Schiemer a52142f304 chore: Update Dockerfiles, Makefile and documentation
- Updated Dockerfile.production
- Updated Makefile
- Updated deployment documentation
- Updated docker/ci/Dockerfile, docker/php/Dockerfile, docker/worker/Dockerfile
- Updated dependency scanning documentation
- Added git-hooks documentation
2025-11-01 21:16:03 +01:00

4.0 KiB

Deployment Commands - Quick Reference

Alle Deployment-Operationen werden über Ansible Playbooks durchgeführt.


🚀 Häufig verwendete Commands

Code deployen (Image-basiert)

cd deployment/ansible
ansible-playbook -i inventory/production.yml \
  playbooks/deploy-update.yml \
  -e "image_tag=abc1234-1696234567" \
  -e "git_commit_sha=$(git rev-parse HEAD)"

Code synchen (Git-basiert)

cd deployment/ansible
ansible-playbook -i inventory/production.yml \
  playbooks/sync-code.yml \
  -e "git_branch=main"

Rollback zu vorheriger Version

cd deployment/ansible
ansible-playbook -i inventory/production.yml \
  playbooks/rollback.yml

Infrastructure Setup (einmalig)

cd deployment/ansible
ansible-playbook -i inventory/production.yml \
  playbooks/setup-infrastructure.yml

System Maintenance (regelmäßig)

cd deployment/ansible
ansible-playbook -i inventory/production.yml \
  playbooks/system-maintenance.yml

📋 Alle verfügbaren Playbooks

Deployment & Updates

  • playbooks/deploy-update.yml - Deployt neues Docker Image
  • playbooks/sync-code.yml - Synchronisiert Code aus Git Repository
  • playbooks/rollback.yml - Rollback zu vorheriger Version

Infrastructure Setup

  • playbooks/setup-infrastructure.yml - Deployed alle Stacks (Traefik, PostgreSQL, Registry, Gitea, Monitoring, Application)
  • playbooks/setup-production-secrets.yml - Deployed Secrets zu Production
  • playbooks/setup-ssl-certificates.yml - SSL Certificate Setup
  • playbooks/sync-stacks.yml - Synchronisiert Stack-Konfigurationen

Troubleshooting & Maintenance

  • playbooks/troubleshoot.yml - Unified Troubleshooting Playbook mit Tags
    # Nur Diagnose
    ansible-playbook ... troubleshoot.yml --tags diagnose
    
    # Health Check prüfen
    ansible-playbook ... troubleshoot.yml --tags health,check
    
    # Health Checks fixen
    ansible-playbook ... troubleshoot.yml --tags health,fix
    
    # Nginx 404 fixen
    ansible-playbook ... troubleshoot.yml --tags nginx,404,fix
    
    # Alles ausführen
    ansible-playbook ... troubleshoot.yml --tags all
    
  • playbooks/system-maintenance.yml - Führt Paket-Updates, Unattended-Upgrades und optional Docker-Pruning aus

VPN

  • playbooks/setup-wireguard.yml - WireGuard VPN Setup
  • playbooks/add-wireguard-client.yml - WireGuard Client hinzufügen

CI/CD

  • playbooks/setup-gitea-runner-ci.yml - Gitea Runner CI Setup

🔧 Ansible Variablen

Häufig verwendete Extra Variables

# Image Tag für Deployment
-e "image_tag=abc1234-1696234567"

# Git Branch für Code Sync
-e "git_branch=main"
-e "git_repo_url=https://git.michaelschiemer.de/michael/michaelschiemer.git"

# Registry Credentials (wenn nicht im Vault)
-e "docker_registry_username=admin"
-e "docker_registry_password=secret"

# Dry Run (Check Mode)
--check

# Verbose Output
-v  # oder -vv, -vvv für mehr Details

📖 Vollständige Dokumentation


💡 Tipps

Vault Passwort setzen

export ANSIBLE_VAULT_PASSWORD_FILE=~/.ansible/vault_pass
# oder
ansible-playbook ... --vault-password-file ~/.ansible/vault_pass

Nur bestimmte Tasks ausführen

ansible-playbook ... --tags "deploy,restart"

Check Mode (Dry Run)

ansible-playbook ... --check --diff

Inventory prüfen

ansible -i inventory/production.yml production -m ping

PHP Version anpassen

# 1. Workflow-Variable aktualisieren (.gitea/workflows/production-deploy.yml)
PHP_VERSION=8.5.0RC4

# 2. Optionale lokale Builds (alle Dockerfiles akzeptieren PHP_VERSION):
docker build --build-arg PHP_VERSION=8.5.0RC4 -f docker/php/Dockerfile .
docker build --build-arg PHP_VERSION=8.5.0RC4 -f docker/ci/Dockerfile .
docker build --build-arg PHP_VERSION=8.5.0RC4 -f docker/worker/Dockerfile .