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¶
- View the source on GitHub: DevOpsForge Repository
- Open an issue: GitHub Issues
- Contribute: Contributing Guide