Skip to content

Enhanced Examples & Walkthroughs

This page provides comprehensive, real-world examples of using DevOpsForge with step-by-step walkthroughs and actual command outputs.

🐍 Complete Python Project Walkthrough

Step 1: Project Setup

mkdir my-flask-app
cd my-flask-app
mkdir tests
touch main.py requirements.txt README.md

Step 2: Sample Code

main.py:

from flask import Flask, jsonify

app = Flask(__name__)

@app.route('/')
def hello():
    return jsonify({"message": "Hello from DevOpsForge!"})

@app.route('/health')
def health():
    return jsonify({"status": "healthy"})

if __name__ == '__main__':
    app.run(host='0.0.0.0', port=8000)

requirements.txt:

flask==2.3.0
pytest==7.4.0

Step 3: Analysis

devopsforge analyze .

Output:

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ πŸ” Repository Analysis Results      β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Property    β”‚ Value               β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ Project Typeβ”‚ python              β”‚
β”‚ Language    β”‚ python              β”‚
β”‚ Dependenciesβ”‚ flask, pytest       β”‚
β”‚ Build Tools β”‚ pip                 β”‚
β”‚ Test Framew.β”‚ pytest             β”‚
β”‚ Framework   β”‚ flask               β”‚
β”‚ Database    β”‚ None                β”‚
β”‚ Has Docker  β”‚ False               β”‚
β”‚ Has K8s     β”‚ False               β”‚
β”‚ Has CI/CD   β”‚ False               β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Step 4: Generate Configurations

devopsforge generate . -o ./devops-config

Generated Files:

devops-config/
β”œβ”€β”€ Dockerfile
β”œβ”€β”€ .github/workflows/ci.yml
└── README-DEVOPS.md

Step 5: Test Generated Configuration

cd devops-config
docker build -t my-flask-app .
docker run -p 8000:8000 my-flask-app
curl http://localhost:8000/health

🟒 Node.js Project Walkthrough

Step 1: Project Setup

mkdir my-express-app
cd my-express-app
npm init -y
npm install express jest
mkdir src tests

Step 2: Sample Code

src/index.js:

const express = require('express');
const app = express();
const port = process.env.PORT || 3000;

app.get('/', (req, res) => {
  res.json({ message: 'Hello from DevOpsForge!' });
});

app.get('/health', (req, res) => {
  res.json({ status: 'healthy' });
});

app.listen(port, () => {
  console.log(`Server running on port ${port}`);
});

Step 3: Analysis & Generation

devopsforge analyze .
devopsforge generate . -o ./devops-config

πŸ’‘ Advanced Usage Examples

Custom Output Formats

# JSON output for automation
devopsforge analyze ./my-project -f json -o ./analysis.json

# Summary output for quick overview
devopsforge analyze ./my-project -f summary

Selective Generation

# Generate only Dockerfile
devopsforge generate ./my-project -o ./output --dockerfile

# Generate only CI/CD pipeline
devopsforge generate ./my-project -o ./output --ci-cd

πŸ”§ Real-World Workflow

Complete DevOps Setup

# 1. Analyze project
devopsforge analyze ./my-project

# 2. Generate configurations
devopsforge generate ./my-project -o ./devops-config

# 3. Get suggestions
devopsforge suggest ./my-project

# 4. Review and customize
ls -la ./devops-config/

# 5. Commit and push
git add ./devops-config/
git commit -m "Add DevOps configurations"
git push origin main

πŸ“Š Before & After Examples

Before DevOpsForge

my-project/
β”œβ”€β”€ main.py
β”œβ”€β”€ requirements.txt
└── tests/

After DevOpsForge

my-project/
β”œβ”€β”€ main.py
β”œβ”€β”€ requirements.txt
β”œβ”€β”€ tests/
β”œβ”€β”€ Dockerfile                    # ← Generated
β”œβ”€β”€ .github/workflows/ci.yml      # ← Generated
└── README-DEVOPS.md             # ← Generated

🎯 Customization Examples

Custom Dockerfile Modifications

# Add custom modifications to generated Dockerfile
RUN apt-get update && apt-get install -y curl

# Add health check
HEALTHCHECK --interval=30s --timeout=3s \
    CMD curl -f http://localhost:8000/health || exit 1

Custom CI/CD Pipeline Modifications

# Add custom steps to generated workflow
- name: Custom Security Scan
  run: |
    echo "Running custom security checks..."
    # Your security scanning logic

πŸ“š Next Steps