CI/CD & DevOps Documentation
Overview
This document provides comprehensive CI/CD and DevOps documentation for the Laravel Project, covering containerization, deployment strategies, and development workflows.
Development Environment
Docker-Based Development Setup
Docker Compose Configuration
Primary File: docker-compose.ymlCI Configuration: ci-docker-compose.yml
Service Architecture
services:
wedissimo-api: # Main Laravel application
wedissimo-pg: # PostgreSQL database
wedissimo-mailpit: # Mail testing service
wedissimo-q: # Queue processing service
wedissimo-mysql: # Legacy MySQL database for migration
wedissimo-cloud-sql-proxy: # Cloud SQL proxy for accessing legacy database
wedissimo-typesense: # Typesense search engine
# Optional services:
# wedissimo-es: # Elasticsearch
# wedissimo-fe-app: # Frontend applicationNetwork Configuration
- Custom Network: `w
- Static IP Assignment: Each service has a dedicated IP
- Host Communication:
host.docker.internalfor external access
Service Details
Main Application Service (wedissimo-api)
wedissimo-api:
build:
context: .
dockerfile: dockerfiles/Api.Dockerfile
container_name: wedissimo-api
depends_on:
- wedissimo-pg
volumes:
- .:/var/www/html
restart: always
ports:
- "2222:80"
networks:
wedissimo-network:
ipv4_address: 22.22.1.1Access: http://22.22.1.1 (or http://localhost:2222)
PostgreSQL Database Service (wedissimo-pg)
wedissimo-pg:
image: postgres:15
container_name: wedissimo-pg
volumes:
- wedissimo-pg-disk:/var/lib/postgres
restart: always
environment:
POSTGRES_PASSWORD: password
POSTGRES_DB: testing
ports:
- "2232:5432"
networks:
wedissimo-network:
ipv4_address: 22.22.1.2Mail Testing Service (wedissimo-mailpit)
wedissimo-mailpit:
image: "axllent/mailpit:latest"
container_name: wedissimo-mailpit
restart: always
ports:
- "2225:8025"
networks:
wedissimo-network:
ipv4_address: 22.22.1.3Access: http://localhost:2222 (Mail interface)
Queue Processing Service (wedissimo-q)
wedissimo-q:
build:
context: .
dockerfile: dockerfiles/QueueListener.Dockerfile
container_name: wedissimo-q
depends_on:
- wedissimo-api
volumes:
- .:/var/www/html
restart: unless-stopped
networks:
wedissimo-network:
ipv4_address: 22.22.1.4Docker Images and Dockerfiles
Available Dockerfiles
dockerfiles/
├── Api.Dockerfile # Main application container
├── Ci.Dockerfile # CI/testing container
├── QueueListener.Dockerfile # Queue processing container
├── FeApp.Dockerfile # Frontend application container
├── 0x.Dockerfile # Utility/debugging container
├── api-runner # API startup script
├── fe-app-runner # Frontend startup script
└── queue-listener # Queue listener scriptAPI Container Configuration
File: dockerfiles/Api.Dockerfile
FROM devopsfnl/image:php-8.4-npx
COPY php.ini /usr/local/etc/php/
ENTRYPOINT ["/var/www/html/dockerfiles/api-runner"]Base Image Features:
- PHP 8.4.11
- Apache web server
- Node.js/NPM
- Common PHP extensions
API Startup Script
File: dockerfiles/api-runner
#!/bin/bash
composer install
composer run dev
git config --global --add safe.directory /var/www/html
git config core.filemode false
npm install
npm run build
apache2-foregroundStartup Process:
- Install PHP dependencies
- Run development setup
- Configure Git settings
- Install and build frontend assets
- Start Apache server
Development Workflow
Initial Setup
# Clone repository
git clone <repository-url>
cd wedissimo-api
# Start development environment
docker compose up -d
# Access application
open http://22.22.1.1Daily Development
# Start services
docker compose up -d
# Execute commands in container
docker compose exec wedissimo-api bash
docker compose exec wedissimo-api composer install
docker compose exec wedissimo-api php artisan migrate
# View logs
docker compose logs wedissimo-api
docker compose logs -f wedissimo-api # Follow logs
# Stop services
docker compose downDatabase Management
# Run migrations
docker compose exec wedissimo-api php artisan migrate
# Seed database
docker compose exec wedissimo-api php artisan db:seed
# Reset database
docker compose exec wedissimo-api php artisan migrate:fresh --seed
# Database access
docker compose exec wedissimo-pg psql -U postgres -d testingCI/CD Pipeline
CircleCI Configuration
File: .circleci/config.yml
Pipeline Overview
The CI/CD pipeline consists of two main jobs:
- CI (Continuous Integration): Code quality, testing, and validation
- CD (Continuous Deployment): Automated deployment to staging/production
CI Job Configuration
ci:
machine:
image: ubuntu-2004:202201-02
resource_class: medium
working_directory: ~/code
environment:
- CIRCLE_PROJECT_REPONAME: fl-laravel_boilerplateCI Pipeline Steps
1. Code Checkout
- checkout2. Commit Validation
- run:
name: Check Rejected Commits
command: wget https://api.reviewee.it/repository/$CIRCLE_PROJECT_REPONAME/haveRejectedCommits -q -O - | grep -q '\"success\":true'3. Environment Setup
- run:
name: Docker compose
command: docker-compose -f ci-docker-compose.yml up -d4. Code Quality & Testing
- run:
name: CI checks
command: docker-compose -f ci-docker-compose.yml exec wedissimo-api composer run ciCI Checks Include:
- Laravel Pint: Code formatting
- PHP CodeSniffer: Coding standards
- PHP Mess Detector: Code quality analysis
- Security Checker: Dependency vulnerabilities
- Pest Tests: Feature and unit tests
- Enlightn: Security and performance analysis
5. Development Environment Setup
- run:
name: Setup dev environment
command: docker-compose -f ci-docker-compose.yml exec wedissimo-api composer run dev6. API Testing
- run:
name: Postman tests
command: docker-compose -f ci-docker-compose.yml exec wedissimo-api postman collection run postman/ci-collection.jsonCD Job Configuration
cd:
machine:
image: ubuntu-2004:202201-02
resource_class: medium
working_directory: ~/code
steps:
- checkout
- run:
name: Heroku deploy
command: git push --force https://heroku:$HEROKU_AUTH_KEY@git.heroku.com/$HEROKU_UAT_APP_NAME.git HEAD:refs/heads/masterWorkflow Configuration
workflows:
version: 2
ci-cd:
jobs:
- ci:
filters:
branches:
only:
- main
- staging
- cd:
requires:
- ciBranch Strategy:
- main: Production deployments
- staging: Staging environment deployments
- CI runs on both branches
- CD only runs after successful CI
Composer Scripts for CI/CD
CI Script
"ci": [
"@tests"
]Tests Script
"tests": [
"@pre-commit",
"@pest",
"@php artisan enlightn --ci"
]Pre-commit Checks
"pre-commit": [
"@pint",
"@phpcbf",
"@phpcs",
"@phpmd",
"@security-checker"
]Individual Commands:
@pint: Laravel Pint code formatting@phpcbf: PHP Code Beautifier and Fixer@phpcs: PHP CodeSniffer@phpmd: PHP Mess Detector@security-checker: Security vulnerability checker@pest: Pest test execution@php artisan enlightn --ci: Enlightn analysis in CI mode
Deployment Strategy
Heroku Deployment
Platform Configuration
- Platform: Heroku
- Deployment Method: Git-based deployment
- Process Management: Procfile-based
Procfile Configuration
File: Procfile
release: php artisan migrate --seed --force && php artisan optimize:clear && npm install --include=dev && npm run build
web: vendor/bin/heroku-php-apache2 public/
worker: php artisan queue:listen --tries=3 --timeout=1800Process Types:
- release: Pre-deployment tasks (migrations, optimization, asset building)
- web: Web server process
- worker: Queue processing worker
Deployment Process
- Code Push: Git push triggers deployment
- Build Phase: Composer and NPM dependency installation
- Release Phase: Database migrations and optimizations
- Deploy Phase: Application startup
Environment Variables
Critical environment variables for deployment:
APP_ENV=production
APP_DEBUG=false
APP_KEY=<generated-key>
DB_CONNECTION=pgsql
DB_HOST=<heroku-postgres-host>
DB_DATABASE=<heroku-postgres-db>
DB_USERNAME=<heroku-postgres-user>
DB_PASSWORD=<heroku-postgres-password>
MAIL_MAILER=postmark
POSTMARK_TOKEN=<postmark-token>Production Optimization
Laravel Optimizations
# Configuration caching
php artisan config:cache
# Route caching
php artisan route:cache
# View compilation
php artisan view:cache
# Clear optimization (for updates)
php artisan optimize:clearAsset Optimization
# Production asset build
npm run build
# Asset versioning
# Handled automatically by ViteCode Quality & Security
Code Quality Tools
Laravel Pint
Configuration: pint.json
{
"preset": "laravel"
}Usage:
composer run pintPHP CodeSniffer
Standard: PSR12
composer run phpcs
composer run phpcbf # Auto-fixPHP Mess Detector
Configuration: phpmd_ruleset.xml
composer run phpmdSecurity Tools
Enlightn Security Analysis
composer run enlightn
php artisan enlightn --ci # CI modeAnalysis Areas:
- Security vulnerabilities
- Performance issues
- Code quality metrics
- Best practice compliance
Security Checker
composer run security-checkerChecks:
- Known security vulnerabilities in dependencies
- Outdated packages with security issues
Git Hooks Integration
Composer Git Hooks
Package: svikramjeet/composer-git-hooks
Hook Configuration:
"hooks": {
"pre-commit": [
"docker-compose exec -T wedissimo-api composer run pre-commit"
],
"pre-push": [
"docker-compose exec -T wedissimo-api composer run pre-push"
],
"post-merge": [
"docker-compose exec -T wedissimo-api composer run post-merge"
]
}Hook Actions:
- pre-commit: Code quality checks
- pre-push: Full test suite execution
- post-merge: Dependency updates and migrations
Environment Management
Environment Files
.env.example: Template for environment configuration.env.testing: Testing environment configuration.env: Local development (not in version control)
Configuration Management
Key Configuration Files:
config/app.php: Application settingsconfig/database.php: Database connectionsconfig/mail.php: Email configurationconfig/services.php: Third-party services
Secrets Management
- Environment variable-based secrets
- Heroku config vars for production
- Local
.envfor development - CI environment variables for testing
Monitoring & Debugging
Application Monitoring
- Laravel Telescope: Development debugging
- Bugsnag: Error tracking and reporting
- Heroku Metrics: Platform-level monitoring
Logging Strategy
- Log Channels: Configured in
config/logging.php - Error Tracking: Bugsnag integration
- Debug Information: Laravel Telescope
Performance Monitoring
- Query Monitoring: Telescope query tracking
- Performance Metrics: Enlightn analysis
- Resource Usage: Heroku metrics
Backup & Recovery
Database Backups
- Heroku Postgres: Automatic backups
- Manual Backups: Available via Heroku CLI
- Point-in-time Recovery: Heroku Postgres feature
Code Backup
- Git Repository: Primary code backup
- Multiple Remotes: Origin and deployment remotes
- Branching Strategy: Feature branches for safety
Scaling Considerations
Horizontal Scaling
- Heroku Dynos: Scale web and worker processes
- Database: Heroku Postgres scaling options
- Queue Processing: Multiple worker dynos
Performance Optimization
- Caching: Redis for session and cache storage
- CDN: Asset delivery optimization
- Database Optimization: Query optimization and indexing
Future DevOps Considerations for AI Rebuild
Enhanced CI/CD for Modern Stack
- Livewire Testing: Component-specific testing strategies
- Tailwind v4: Updated build processes
- Flux UI: Component library integration testing
Infrastructure as Code
- Terraform: Infrastructure provisioning
- Docker Compose Override: Environment-specific configurations
- Kubernetes: Container orchestration for larger deployments
Advanced Monitoring
- APM Tools: Application Performance Monitoring
- Real-time Monitoring: WebSocket and real-time feature monitoring
- User Analytics: Enhanced user behavior tracking
This comprehensive CI/CD and DevOps documentation ensures that the AI-powered rebuild maintains robust development workflows, quality assurance processes, and deployment strategies.