Skip to content

Commit 17ff955

Browse files
guide: code quality checks (#23595)
## Description - Adds guide for AI-powered code quality checks w/ E2B and Docker MCP - Provides a full e2e tutorial to build a code quality check workflow w/ customization options - Adds troubleshooting page ## Related issues or tickets https://docker.atlassian.net/browse/ENGDOCS-3073
1 parent 6c64ad4 commit 17ff955

File tree

7 files changed

+2177
-3
lines changed

7 files changed

+2177
-3
lines changed

.markdownlint.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"no-space-in-code": true,
1414
"no-space-in-links": true,
1515
"no-empty-links": true,
16-
"ol-prefix": {"style": "one_or_ordered"},
16+
"ol-prefix": false,
1717
"no-reversed-links": true,
1818
"reference-links-images": {
1919
"shortcut_syntax": false

content/guides/admin-user-management/_index.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ summary: Simplify user access while ensuring security and efficiency in Docker.
44
description: A guide for managing roles, provisioning users, and optimizing Docker access with tools like SSO and activity logs.
55
tags: [admin]
66
params:
7-
featured: true
7+
featured: false
88
time: 20 minutes
9-
image:
9+
image:
1010
resource_links:
1111
- title: Overview of Administration in Docker
1212
url: /admin/
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
---
2+
title: How to build an AI-powered code quality workflow with SonarQube and E2B
3+
linkTitle: Build an AI-powered code quality workflow
4+
summary: Build AI-powered code quality workflows using E2B sandboxes with Docker's MCP catalog to automate GitHub and SonarQube integration.
5+
description: Learn how to create E2B sandboxes with MCP servers, analyze code quality with SonarQube, and generate quality-gated pull requests using GitHub—all through natural language interactions with Claude.
6+
tags: [devops]
7+
params:
8+
featured: true
9+
time: 40 minutes
10+
image:
11+
resource_links:
12+
- title: E2B Documentation
13+
url: https://e2b.dev/docs
14+
- title: Docker MCP Catalog
15+
url: https://hub.docker.com/mcp
16+
- title: Sandboxes
17+
url: https://docs.docker.com/ai/mcp-catalog-and-toolkit/sandboxes/
18+
---
19+
20+
This guide demonstrates how to build an AI-powered code quality workflow using
21+
[E2B sandboxes](https://e2b.dev/docs) with Docker’s MCP catalog. You’ll create
22+
a system that automatically analyzes code quality issues in GitHub repositories
23+
using SonarQube, then generate pull requests with fixes.
24+
25+
## What you'll build
26+
27+
You’ll build a Node.js script that spins up an E2B sandbox, connects GitHub and
28+
SonarQube MCP servers, and uses Claude Code to analyze code quality and propose
29+
improvements. The MCP servers are containerized and run as part of the E2B
30+
sandbox.
31+
32+
## What you'll learn
33+
34+
In this guide, you'll learn:
35+
36+
- How to create E2B sandboxes with multiple MCP servers
37+
- How to configure GitHub and SonarQube MCP servers for AI workflows
38+
- How to use Claude Code inside sandboxes to interact with external tools
39+
- How to build automated code review workflows that create quality-gated
40+
pull requests
41+
42+
## Why use E2B sandboxes?
43+
44+
Running this workflow in E2B sandboes provides several advantages over
45+
local execution:
46+
47+
- Security: AI-generated code runs in isolated containers, protecting your
48+
local environment and credentials
49+
- Zero setup: No need to install SonarQube, GitHub CLI, or manage dependencies
50+
locally
51+
- Scalability: Resource-intensive operations like code scanning run in the
52+
cloud without consuming local resources
53+
54+
## Learn more
55+
56+
Read Docker's blog post: [Docker + E2B: Building the Future of Trusted AI](https://www.docker.com/blog/docker-e2b-building-the-future-of-trusted-ai/).
Lines changed: 181 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,181 @@
1+
---
2+
title: Customize a code quality check workflow
3+
linkTitle: Customize workflow
4+
summary: Adapt your GitHub and SonarQube workflow to focus on specific quality issues, integrate with CI/CD, and set custom thresholds.
5+
description: Learn how to customize prompts for specific quality issues, filter by file patterns, set quality thresholds, and integrate your workflow with GitHub Actions for automated code quality checks.
6+
weight: 20
7+
---
8+
9+
Now that you understand the basics of automating code quality workflows with
10+
GitHub and SonarQube in E2B sandboxes, you can customize the workflow
11+
for your needs.
12+
13+
## Focus on specific quality issues
14+
15+
Modify the prompt to prioritize certain issue types:
16+
17+
{{< tabs group="language" >}}
18+
{{< tab name="TypeScript" >}}
19+
20+
```typescript
21+
const prompt = `Using SonarQube and GitHub MCP tools:
22+
23+
Focus only on:
24+
- Security vulnerabilities (CRITICAL priority)
25+
- Bugs (HIGH priority)
26+
- Skip code smells for this iteration
27+
28+
Analyze "${repoPath}" and fix the highest priority issues first.`;
29+
```
30+
31+
{{< /tab >}}
32+
{{< tab name="Python" >}}
33+
34+
```python
35+
prompt = f"""Using SonarQube and GitHub MCP tools:
36+
37+
Focus only on:
38+
- Security vulnerabilities (CRITICAL priority)
39+
- Bugs (HIGH priority)
40+
- Skip code smells for this iteration
41+
42+
Analyze "{repo_path}" and fix the highest priority issues first."""
43+
```
44+
45+
{{< /tab >}}
46+
{{< /tabs >}}
47+
48+
## Integrate with CI/CD
49+
50+
Add this workflow to GitHub Actions to run automatically on pull requests:
51+
52+
{{< tabs group="language" >}}
53+
{{< tab name="TypeScript" >}}
54+
55+
```yaml
56+
name: Automated quality checks
57+
on:
58+
pull_request:
59+
types: [opened, synchronize]
60+
61+
jobs:
62+
quality:
63+
runs-on: ubuntu-latest
64+
steps:
65+
- uses: actions/checkout@v4
66+
- uses: actions/setup-node@v4
67+
with:
68+
node-version: "18"
69+
- run: npm install
70+
- run: npx tsx 06-quality-gated-pr.ts
71+
env:
72+
E2B_API_KEY: ${{ secrets.E2B_API_KEY }}
73+
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
74+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
75+
SONARQUBE_TOKEN: ${{ secrets.SONARQUBE_TOKEN }}
76+
GITHUB_OWNER: ${{ github.repository_owner }}
77+
GITHUB_REPO: ${{ github.event.repository.name }}
78+
SONARQUBE_ORG: your-org-key
79+
```
80+
81+
{{< /tab >}}
82+
{{< tab name="Python" >}}
83+
84+
```yaml
85+
name: Automated quality checks
86+
on:
87+
pull_request:
88+
types: [opened, synchronize]
89+
90+
jobs:
91+
quality:
92+
runs-on: ubuntu-latest
93+
steps:
94+
- uses: actions/checkout@v4
95+
- uses: actions/setup-python@v5
96+
with:
97+
python-version: "3.8"
98+
- run: pip install e2b python-dotenv
99+
- run: python 06_quality_gated_pr.py
100+
env:
101+
E2B_API_KEY: ${{ secrets.E2B_API_KEY }}
102+
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
103+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
104+
SONARQUBE_TOKEN: ${{ secrets.SONARQUBE_TOKEN }}
105+
GITHUB_OWNER: ${{ github.repository_owner }}
106+
GITHUB_REPO: ${{ github.event.repository.name }}
107+
SONARQUBE_ORG: your-org-key
108+
```
109+
110+
{{< /tab >}}
111+
{{< /tabs >}}
112+
113+
## Filter by file patterns
114+
115+
Target specific parts of your codebase:
116+
117+
{{< tabs group="language" >}}
118+
{{< tab name="TypeScript" >}}
119+
120+
```typescript
121+
const prompt = `Analyze code quality but only consider:
122+
- Files in src/**/*.js
123+
- Exclude test files (*.test.js, *.spec.js)
124+
- Exclude build artifacts in dist/
125+
126+
Focus on production code only.`;
127+
```
128+
129+
{{< /tab >}}
130+
{{< tab name="Python" >}}
131+
132+
```python
133+
prompt = """Analyze code quality but only consider:
134+
- Files in src/**/*.js
135+
- Exclude test files (*.test.js, *.spec.js)
136+
- Exclude build artifacts in dist/
137+
138+
Focus on production code only."""
139+
```
140+
141+
{{< /tab >}}
142+
{{< /tabs >}}
143+
144+
## Set quality thresholds
145+
146+
Define when PRs should be created:
147+
148+
{{< tabs group="language" >}}
149+
{{< tab name="TypeScript" >}}
150+
151+
```typescript
152+
const prompt = `Quality gate thresholds:
153+
- Only create PR if:
154+
* Bug count decreases by at least 1
155+
* No new security vulnerabilities introduced
156+
* Code coverage does not decrease
157+
* Technical debt reduces by at least 15 minutes
158+
159+
If changes do not meet these thresholds, explain why and skip PR creation.`;
160+
```
161+
162+
{{< /tab >}}
163+
{{< tab name="Python" >}}
164+
165+
```python
166+
prompt = """Quality gate thresholds:
167+
- Only create PR if:
168+
* Bug count decreases by at least 1
169+
* No new security vulnerabilities introduced
170+
* Code coverage does not decrease
171+
* Technical debt reduces by at least 15 minutes
172+
173+
If changes do not meet these thresholds, explain why and skip PR creation."""
174+
```
175+
176+
{{< /tab >}}
177+
{{< /tabs >}}
178+
179+
## Next steps
180+
181+
Learn how to troubleshoot common issues.

0 commit comments

Comments
 (0)