Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .markdownlint.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"no-space-in-code": true,
"no-space-in-links": true,
"no-empty-links": true,
"ol-prefix": {"style": "one_or_ordered"},
"ol-prefix": false,
"no-reversed-links": true,
"reference-links-images": {
"shortcut_syntax": false
Expand Down
4 changes: 2 additions & 2 deletions content/guides/admin-user-management/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ summary: Simplify user access while ensuring security and efficiency in Docker.
description: A guide for managing roles, provisioning users, and optimizing Docker access with tools like SSO and activity logs.
tags: [admin]
params:
featured: true
featured: false
time: 20 minutes
image:
image:
resource_links:
- title: Overview of Administration in Docker
url: /admin/
Expand Down
56 changes: 56 additions & 0 deletions content/guides/github-sonarqube-sandbox/_index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
---
title: How to build an AI-powered code quality workflow with SonarQube and E2B
linkTitle: Build an AI-powered code quality workflow
summary: Build AI-powered code quality workflows using E2B sandboxes with Docker's MCP catalog to automate GitHub and SonarQube integration.
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.
tags: [devops]
params:
featured: true
time: 40 minutes
image:
resource_links:
- title: E2B Documentation
url: https://e2b.dev/docs
- title: Docker MCP Catalog
url: https://hub.docker.com/mcp
- title: Sandboxes
url: https://docs.docker.com/ai/mcp-catalog-and-toolkit/sandboxes/
---

This guide demonstrates how to build an AI-powered code quality workflow using
[E2B sandboxes](https://e2b.dev/docs) with Docker’s MCP catalog. You’ll create
a system that automatically analyzes code quality issues in GitHub repositories
using SonarQube, then generate pull requests with fixes.

## What you'll build

You’ll build a Node.js script that spins up an E2B sandbox, connects GitHub and
SonarQube MCP servers, and uses Claude Code to analyze code quality and propose
improvements. The MCP servers are containerized and run as part of the E2B
sandbox.

## What you'll learn

In this guide, you'll learn:

- How to create E2B sandboxes with multiple MCP servers
- How to configure GitHub and SonarQube MCP servers for AI workflows
- How to use Claude Code inside sandboxes to interact with external tools
- How to build automated code review workflows that create quality-gated
pull requests

## Why use E2B sandboxes?

Running this workflow in E2B sandboes provides several advantages over
local execution:

- Security: AI-generated code runs in isolated containers, protecting your
local environment and credentials
- Zero setup: No need to install SonarQube, GitHub CLI, or manage dependencies
locally
- Scalability: Resource-intensive operations like code scanning run in the
cloud without consuming local resources

## Learn more

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/).
181 changes: 181 additions & 0 deletions content/guides/github-sonarqube-sandbox/customize.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,181 @@
---
title: Customize a code quality check workflow
linkTitle: Customize workflow
summary: Adapt your GitHub and SonarQube workflow to focus on specific quality issues, integrate with CI/CD, and set custom thresholds.
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.
weight: 20
---

Now that you understand the basics of automating code quality workflows with
GitHub and SonarQube in E2B sandboxes, you can customize the workflow
for your needs.

## Focus on specific quality issues

Modify the prompt to prioritize certain issue types:

{{< tabs group="language" >}}
{{< tab name="TypeScript" >}}

```typescript
const prompt = `Using SonarQube and GitHub MCP tools:

Focus only on:
- Security vulnerabilities (CRITICAL priority)
- Bugs (HIGH priority)
- Skip code smells for this iteration

Analyze "${repoPath}" and fix the highest priority issues first.`;
```

{{< /tab >}}
{{< tab name="Python" >}}

```python
prompt = f"""Using SonarQube and GitHub MCP tools:

Focus only on:
- Security vulnerabilities (CRITICAL priority)
- Bugs (HIGH priority)
- Skip code smells for this iteration

Analyze "{repo_path}" and fix the highest priority issues first."""
```

{{< /tab >}}
{{< /tabs >}}

## Integrate with CI/CD

Add this workflow to GitHub Actions to run automatically on pull requests:

{{< tabs group="language" >}}
{{< tab name="TypeScript" >}}

```yaml
name: Automated quality checks
on:
pull_request:
types: [opened, synchronize]

jobs:
quality:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: "18"
- run: npm install
- run: npx tsx 06-quality-gated-pr.ts
env:
E2B_API_KEY: ${{ secrets.E2B_API_KEY }}
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONARQUBE_TOKEN: ${{ secrets.SONARQUBE_TOKEN }}
GITHUB_OWNER: ${{ github.repository_owner }}
GITHUB_REPO: ${{ github.event.repository.name }}
SONARQUBE_ORG: your-org-key
```

{{< /tab >}}
{{< tab name="Python" >}}

```yaml
name: Automated quality checks
on:
pull_request:
types: [opened, synchronize]

jobs:
quality:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.8"
- run: pip install e2b python-dotenv
- run: python 06_quality_gated_pr.py
env:
E2B_API_KEY: ${{ secrets.E2B_API_KEY }}
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONARQUBE_TOKEN: ${{ secrets.SONARQUBE_TOKEN }}
GITHUB_OWNER: ${{ github.repository_owner }}
GITHUB_REPO: ${{ github.event.repository.name }}
SONARQUBE_ORG: your-org-key
```

{{< /tab >}}
{{< /tabs >}}

## Filter by file patterns

Target specific parts of your codebase:

{{< tabs group="language" >}}
{{< tab name="TypeScript" >}}

```typescript
const prompt = `Analyze code quality but only consider:
- Files in src/**/*.js
- Exclude test files (*.test.js, *.spec.js)
- Exclude build artifacts in dist/

Focus on production code only.`;
```

{{< /tab >}}
{{< tab name="Python" >}}

```python
prompt = """Analyze code quality but only consider:
- Files in src/**/*.js
- Exclude test files (*.test.js, *.spec.js)
- Exclude build artifacts in dist/

Focus on production code only."""
```

{{< /tab >}}
{{< /tabs >}}

## Set quality thresholds

Define when PRs should be created:

{{< tabs group="language" >}}
{{< tab name="TypeScript" >}}

```typescript
const prompt = `Quality gate thresholds:
- Only create PR if:
* Bug count decreases by at least 1
* No new security vulnerabilities introduced
* Code coverage does not decrease
* Technical debt reduces by at least 15 minutes

If changes do not meet these thresholds, explain why and skip PR creation.`;
```

{{< /tab >}}
{{< tab name="Python" >}}

```python
prompt = """Quality gate thresholds:
- Only create PR if:
* Bug count decreases by at least 1
* No new security vulnerabilities introduced
* Code coverage does not decrease
* Technical debt reduces by at least 15 minutes

If changes do not meet these thresholds, explain why and skip PR creation."""
```

{{< /tab >}}
{{< /tabs >}}

## Next steps

Learn how to troubleshoot common issues.
Loading