test: CI/CD pipeline staging test - Repository Setup automatisiert
This commit is contained in:
@@ -92,15 +92,48 @@ deployment/
|
||||
|
||||
## Getting Started
|
||||
|
||||
### 🧪 Pipeline-Tests vorbereiten
|
||||
|
||||
**Vor dem ersten Deployment:**
|
||||
|
||||
1. **Prerequisites prüfen:**
|
||||
```bash
|
||||
./deployment/scripts/test-pipeline-prerequisites.sh
|
||||
```
|
||||
|
||||
2. **Test-Anleitung lesen:**
|
||||
- [Pipeline Test Checklist](docs/guides/pipeline-test-checklist.md) ⭐ - Schritt-für-Schritt Anleitung
|
||||
- [Pipeline Testing Guide](docs/guides/pipeline-testing-guide.md) - Übersicht und Troubleshooting
|
||||
|
||||
3. **Backup-Test durchführen:**
|
||||
```bash
|
||||
./deployment/scripts/test-backup.sh
|
||||
```
|
||||
|
||||
### 🚀 Quick Start: Code deployen
|
||||
|
||||
**Einfachste Methode:**
|
||||
**Empfohlener Workflow (Staging → Production):**
|
||||
|
||||
1. **Push auf `staging` Branch** (Standard für Entwicklung)
|
||||
```bash
|
||||
git add .
|
||||
git commit -m "feat: Add new feature"
|
||||
git push origin main # → Automatisches Deployment!
|
||||
git push origin staging # → Automatisches Deployment zu Staging
|
||||
```
|
||||
|
||||
2. **Testen auf Staging**
|
||||
- Staging URL: `https://staging.michaelschiemer.de`
|
||||
- Tests durchführen und verifizieren
|
||||
|
||||
3. **Merge nach `main`** (nur nach erfolgreichem Test)
|
||||
```bash
|
||||
git checkout main
|
||||
git merge staging
|
||||
git push origin main # → Automatisches Deployment zu Production
|
||||
```
|
||||
|
||||
**⚠️ Wichtig:** Niemals direkt auf `main` pushen - immer erst auf `staging` testen!
|
||||
|
||||
**Pipeline-Status:** `https://git.michaelschiemer.de/michael/michaelschiemer/actions`
|
||||
|
||||
**📖 Vollständige Anleitung:** Siehe [docs/guides/quick-start.md](docs/guides/quick-start.md) oder [docs/guides/code-change-workflow.md](docs/guides/code-change-workflow.md)
|
||||
@@ -134,7 +167,26 @@ Dieses Playbook deployed alle Stacks:
|
||||
- Docker Registry (Private Registry)
|
||||
- Gitea (Git Server)
|
||||
- Monitoring (Portainer, Grafana, Prometheus)
|
||||
- **Application Stack** (PHP Application + Nginx + Redis + Queue Workers)
|
||||
- **Production Stack** (PHP Application + Nginx + Redis + Queue Workers)
|
||||
|
||||
**Gitea Initial Setup (nach Infrastructure Deployment):**
|
||||
```bash
|
||||
# Automatische Initial Setup via Ansible
|
||||
cd deployment/ansible
|
||||
|
||||
# 1. Gitea Initial Configuration (Admin-User erstellen)
|
||||
ansible-playbook -i inventory/production.yml \
|
||||
playbooks/setup-gitea-initial-config.yml \
|
||||
--vault-password-file secrets/.vault_pass
|
||||
|
||||
# 2. Repository in Gitea erstellen und Git-Remote konfigurieren
|
||||
ansible-playbook -i inventory/production.yml \
|
||||
playbooks/setup-gitea-repository.yml \
|
||||
--vault-password-file secrets/.vault_pass \
|
||||
-e "repo_name=michaelschiemer" \
|
||||
-e "repo_owner=michael" \
|
||||
-e "repo_private=false"
|
||||
```
|
||||
|
||||
**📖 Vollständige Setup-Anleitung:** Siehe [SETUP-GUIDE.md](SETUP-GUIDE.md)
|
||||
|
||||
@@ -145,33 +197,28 @@ Each stack has its own README with detailed configuration:
|
||||
- [Traefik](stacks/traefik/README.md) - Reverse proxy setup
|
||||
- [Gitea](stacks/gitea/README.md) - Git server configuration
|
||||
- [Registry](stacks/registry/README.md) - Private registry setup
|
||||
- [Application](stacks/application/README.md) - Application deployment
|
||||
- [Production](stacks/production/README.md) - Production application deployment
|
||||
- [PostgreSQL](stacks/postgresql/README.md) - Database configuration
|
||||
- [Monitoring](stacks/monitoring/README.md) - Monitoring stack
|
||||
|
||||
## Deployment Commands
|
||||
|
||||
### Code deployen (Image-basiert)
|
||||
### Automatisches Deployment (Empfohlen)
|
||||
|
||||
**Standard-Workflow: Staging → Production**
|
||||
|
||||
1. **Push auf `staging`** (Standard für Entwicklung)
|
||||
```bash
|
||||
cd deployment/ansible
|
||||
ansible-playbook -i inventory/production.yml \
|
||||
playbooks/deploy-update.yml \
|
||||
-e "image_tag=abc1234-1696234567"
|
||||
git add .
|
||||
git commit -m "feat: Add new feature"
|
||||
git push origin staging # → Deployt zu Staging
|
||||
```
|
||||
|
||||
### Code synchen (Git-basiert)
|
||||
2. **Testen auf Staging**, dann **Merge nach `main`**
|
||||
```bash
|
||||
cd deployment/ansible
|
||||
ansible-playbook -i inventory/production.yml \
|
||||
playbooks/sync-code.yml \
|
||||
-e "git_branch=main"
|
||||
```
|
||||
|
||||
### Rollback zu vorheriger Version
|
||||
```bash
|
||||
cd deployment/ansible
|
||||
ansible-playbook -i inventory/production.yml \
|
||||
playbooks/rollback.yml
|
||||
git checkout main
|
||||
git merge staging
|
||||
git push origin main # → Deployt zu Production
|
||||
```
|
||||
|
||||
**📖 Vollständige Command-Referenz:** Siehe [docs/guides/deployment-commands.md](docs/guides/deployment-commands.md)
|
||||
@@ -185,34 +232,54 @@ docker compose up -d
|
||||
|
||||
## CI/CD Pipeline
|
||||
|
||||
The CI/CD pipeline is defined in `.gitea/workflows/production-deploy.yml` and runs automatically on push to `main` branch.
|
||||
The CI/CD pipeline is defined in `.gitea/workflows/build-image.yml` and runs automatically on push to `staging` or `main` branch.
|
||||
|
||||
### Quick Start: Deploy Code Changes
|
||||
### Recommended Workflow: Staging → Production
|
||||
|
||||
**1. Push to `staging` (Standard for Development)**
|
||||
```bash
|
||||
# 1. Make changes locally
|
||||
# Make changes locally
|
||||
# ... edit files ...
|
||||
|
||||
# 2. Commit changes
|
||||
# Commit and push to staging
|
||||
git add .
|
||||
git commit -m "feat: Add new feature"
|
||||
|
||||
# 3. Push to main → Automatic deployment starts
|
||||
git push origin main
|
||||
git push origin staging # → Deploys to Staging
|
||||
```
|
||||
|
||||
**What happens automatically:**
|
||||
**What happens automatically on `staging`:**
|
||||
- ✅ Tests run (~2-5 min)
|
||||
- ✅ Docker image is built (~3-5 min)
|
||||
- ✅ Image is pushed to registry (~1-2 min)
|
||||
- ✅ Ansible deployment runs (~2-4 min)
|
||||
- ✅ Application stack is updated
|
||||
- ✅ Deployment to Staging via SSH/SCP (~2-4 min)
|
||||
- ✅ Staging stack is updated
|
||||
|
||||
**Total time:** ~8-15 minutes
|
||||
**2. Test on Staging**
|
||||
- Staging URL: `https://staging.michaelschiemer.de`
|
||||
- Verify functionality and run tests
|
||||
|
||||
**3. Merge to `main` (Only after successful testing)**
|
||||
```bash
|
||||
git checkout main
|
||||
git merge staging
|
||||
git push origin main # → Deploys to Production
|
||||
```
|
||||
|
||||
**What happens automatically on `main`:**
|
||||
- ✅ Tests run (~2-5 min)
|
||||
- ✅ Docker image is built (~3-5 min)
|
||||
- ✅ Image is pushed to registry (~1-2 min)
|
||||
- ✅ Deployment to Production via SSH/SCP (~2-4 min)
|
||||
- ✅ Production stack is updated
|
||||
|
||||
**Total time per deployment:** ~8-15 minutes
|
||||
|
||||
**Status check:**
|
||||
- Pipeline status: `https://git.michaelschiemer.de/michael/michaelschiemer/actions`
|
||||
- Application status: `ssh deploy@94.16.110.151 "cd ~/deployment/stacks/application && docker compose ps"`
|
||||
- Staging status: `ssh deploy@94.16.110.151 "cd ~/deployment/stacks/staging && docker compose ps"`
|
||||
- Production status: `ssh deploy@94.16.110.151 "cd ~/deployment/stacks/production && docker compose ps"`
|
||||
|
||||
**⚠️ Important:** Never push directly to `main` - always test on `staging` first!
|
||||
|
||||
**📖 Vollständige Dokumentation:**
|
||||
|
||||
@@ -224,11 +291,17 @@ git push origin main
|
||||
|
||||
### Pipeline Details
|
||||
|
||||
The CI/CD pipeline runs on push to main branch:
|
||||
The CI/CD pipeline runs on push to `staging` or `main` branch:
|
||||
|
||||
**On `staging` branch:**
|
||||
1. **Build Stage**: Build Docker image
|
||||
2. **Push Stage**: Push to private registry
|
||||
3. **Deploy Stage**: Deploy to production via Ansible
|
||||
3. **Deploy Stage**: Deploy to Staging via SSH/SCP
|
||||
|
||||
**On `main` branch:**
|
||||
1. **Build Stage**: Build Docker image
|
||||
2. **Push Stage**: Push to private registry
|
||||
3. **Deploy Stage**: Deploy to Production via SSH/SCP
|
||||
|
||||
## Monitoring
|
||||
|
||||
|
||||
Reference in New Issue
Block a user