Compare commits

..

40 Commits

Author SHA1 Message Date
6fa6bb53ad Merge pull request 'fix: use system Python to fix venv symlink issue' (#4) from fix/netbox-mcp-python-venv into main
All checks were successful
Build and Push Docker Images / build (push) Successful in 21s
Reviewed-on: #4
2026-01-11 10:30:01 +00:00
a0078d331e fix: use system Python to fix venv symlink issue
- Add UV_PYTHON_PREFERENCE=only-system to prevent uv from downloading its own Python
- Use python:3.13-alpine3.21 (stable) instead of 3.14 (RC)

Fixes: exec /app/.venv/bin/netbox-mcp-server: no such file or directory
2026-01-11 10:25:32 +00:00
c3bef1afe0 Merge pull request 'feat: add netbox-mcp-server Docker image' (#3) from feature/netbox-mcp-server into main
All checks were successful
Build and Push Docker Images / build (push) Successful in 23s
Reviewed-on: #3
2026-01-11 10:12:37 +00:00
9e6ac27484 fix: use multi-stage build based on official Dockerfile 2026-01-10 20:22:51 +00:00
b577369cdd docs: add netbox-mcp-server README 2026-01-10 20:19:25 +00:00
9b7264bf56 feat: add netbox-mcp-server version file 2026-01-10 20:19:11 +00:00
3c2a4886e6 feat: add netbox-mcp-server image 2026-01-10 20:19:05 +00:00
f76d4cab71 fix: add --no-cache to docker build to avoid stale layers 2026-01-07 17:56:19 +00:00
9cff273a6a chore: remove plugins.py (now mounted at runtime from netbox-deployment)
All checks were successful
Build and Push Docker Images / build (push) Successful in 39s
2026-01-07 15:43:05 +00:00
faf1ca0404 refactor: remove plugins.py from image (mount at runtime)
All checks were successful
Build and Push Docker Images / build (push) Successful in 6s
2026-01-07 15:42:49 +00:00
5212600c8d chore: remove local_settings.py (now mounted at runtime from netbox-deployment)
All checks were successful
Build and Push Docker Images / build (push) Successful in 5s
2026-01-07 15:36:03 +00:00
6375641926 refactor: remove local_settings.py from image (mount at runtime)
All checks were successful
Build and Push Docker Images / build (push) Successful in 6s
2026-01-07 15:23:44 +00:00
93575f8569 fix: delete DATABASE after wrapping to avoid conflict
All checks were successful
Build and Push Docker Images / build (push) Successful in 6s
2026-01-07 15:19:25 +00:00
3ff6ace420 fix: build DATABASE from env vars instead of importing
All checks were successful
Build and Push Docker Images / build (push) Successful in 6s
2026-01-07 15:15:53 +00:00
b05a59213a fix: use relative import for configuration
All checks were successful
Build and Push Docker Images / build (push) Successful in 6s
2026-01-07 15:10:44 +00:00
876abcf8d0 fix: move local_settings.py to /etc/netbox/config/
All checks were successful
Build and Push Docker Images / build (push) Successful in 7s
2026-01-07 15:10:29 +00:00
71e980fd8c fix: import DATABASE from configuration instead of env vars
All checks were successful
Build and Push Docker Images / build (push) Successful in 7s
2026-01-07 15:02:55 +00:00
b60a3f0b1e fix: move netbox_branching to end of PLUGINS list (required)
All checks were successful
Build and Push Docker Images / build (push) Successful in 6s
2026-01-07 14:56:35 +00:00
2eef404f14 feat: add local_settings.py for netbox-branching support
All checks were successful
Build and Push Docker Images / build (push) Successful in 6s
2026-01-07 14:56:12 +00:00
425b618a3a feat: add local_settings.py for netbox-branching DynamicSchemaDict
All checks were successful
Build and Push Docker Images / build (push) Successful in 5s
2026-01-07 14:55:50 +00:00
277761107d docs(netbox): add branching configuration and version compatibility matrix
All checks were successful
Build and Push Docker Images / build (push) Successful in 5s
2026-01-07 13:43:43 +00:00
ef3dd25957 fix(netbox): pin plugin versions for NetBox 4.4.x compatibility
All checks were successful
Build and Push Docker Images / build (push) Successful in 8s
- netbox-branching: >=0.7.0,<0.8.0 (0.7.x for NetBox 4.4)
- netbox-bgp: >=0.17.0,<0.18.0 (0.17.x for NetBox 4.4, 0.18+ requires 4.5)
2026-01-07 13:43:03 +00:00
afcb1b2e60 fix(netbox): skip collectstatic at build time for complex plugins
All checks were successful
Build and Push Docker Images / build (push) Successful in 30s
netbox_branching requires DynamicSchemaDict for DATABASES which cannot
be configured at build time. Static assets will be collected at container
startup instead.
2026-01-07 13:41:26 +00:00
dce74cddfd Update images/netbox/Dockerfile
Some checks failed
Build and Push Docker Images / build (push) Failing after 5s
2026-01-07 13:39:13 +00:00
f0dc1fe699 Update images/netbox/plugins.py
Some checks failed
Build and Push Docker Images / build (push) Failing after 4s
2026-01-07 13:38:19 +00:00
daa9afdb5f Merge pull request 'Update images/netbox/plugin_requirements.txt' (#2) from feature/netbox-plugins into main
Some checks failed
Build and Push Docker Images / build (push) Failing after 5s
Reviewed-on: #2
2026-01-07 13:36:50 +00:00
8f194987c8 Update images/netbox/plugin_requirements.txt 2026-01-07 13:36:32 +00:00
1fb4a3ea3f Merge pull request 'feat(netbox): Add NetBox Docker image with plugins support' (#1) from feature/netbox-plugins into main
Some checks failed
Build and Push Docker Images / build (push) Failing after 19s
Reviewed-on: #1
2026-01-07 13:34:31 +00:00
167a3f1d0e Update images/netbox/README.md 2026-01-07 13:33:57 +00:00
14b4da71d1 Update images/netbox/NETBOX_VERSION 2026-01-07 13:31:48 +00:00
ee9b74ebe4 docs(netbox): document NETBOX_VERSION file and version tagging 2026-01-07 13:28:50 +00:00
75c68f57ef feat(ci): support version files for image tagging and build-args 2026-01-07 13:28:19 +00:00
526a488aba feat(netbox): add NETBOX_VERSION file for version tracking 2026-01-07 13:27:47 +00:00
6809982d3d docs(netbox): update README with branching and bgp plugins 2026-01-07 13:26:12 +00:00
c591816148 feat(netbox): configure netbox-branching and netbox-bgp 2026-01-07 13:25:45 +00:00
b05aada942 feat(netbox): add netbox-branching and netbox-bgp plugins 2026-01-07 13:25:33 +00:00
8ab22a1e66 docs(netbox): add README with usage instructions 2026-01-07 12:39:51 +00:00
3d048c0d99 feat(netbox): add plugins configuration file 2026-01-07 12:39:31 +00:00
b31055f944 feat(netbox): add plugin requirements file 2026-01-07 12:39:18 +00:00
b05905590a feat(netbox): add Dockerfile for NetBox with plugins 2026-01-07 12:39:09 +00:00
8 changed files with 355 additions and 3 deletions

View File

@@ -89,11 +89,47 @@ jobs:
fi
echo "========================================"
echo "Building ${IMAGE_NAME}:latest"
echo "Building ${IMAGE_NAME}"
echo "========================================"
docker build -t "${IMAGE_NAME}:latest" "${IMAGE_PATH}"
docker push "${IMAGE_NAME}:latest"
# Check for version file (format: <NAME>_VERSION or VERSION)
VERSION=""
BUILD_ARGS=""
# Look for specific version file (e.g., NETBOX_VERSION, TERRAFORM_VERSION)
for version_file in "$IMAGE_PATH"/*_VERSION "$IMAGE_PATH"/VERSION; do
if [ -f "$version_file" ]; then
VERSION=$(cat "$version_file" | tr -d '[:space:]')
VERSION_NAME=$(basename "$version_file" | sed 's/_VERSION$//')
if [ "$VERSION_NAME" = "VERSION" ]; then
# Generic VERSION file
echo "📌 Found VERSION file: $VERSION"
else
# Specific version file (e.g., NETBOX_VERSION)
echo "📌 Found ${VERSION_NAME}_VERSION file: $VERSION"
BUILD_ARGS="--build-arg ${VERSION_NAME}_VERSION=${VERSION}"
fi
break
fi
done
# Build the image with --no-cache to ensure fresh build
if [ -n "$BUILD_ARGS" ]; then
echo "🔧 Building with args: $BUILD_ARGS"
docker build --no-cache $BUILD_ARGS -t "${IMAGE_NAME}:latest" "$IMAGE_PATH"
else
docker build --no-cache -t "${IMAGE_NAME}:latest" "$IMAGE_PATH"
fi
# Push latest tag
docker push "${IMAGE_NAME}:latest"
echo "✅ Pushed ${IMAGE_NAME}:latest"
# Also tag and push with version if available
if [ -n "$VERSION" ]; then
docker tag "${IMAGE_NAME}:latest" "${IMAGE_NAME}:${VERSION}"
docker push "${IMAGE_NAME}:${VERSION}"
echo "✅ Pushed ${IMAGE_NAME}:${VERSION}"
fi
done

View File

@@ -0,0 +1,62 @@
# =============================================================================
# NetBox MCP Server
#
# Image Docker pour le serveur MCP NetBox (Model Context Protocol)
# Permet l'interaction read-only avec NetBox via LLMs
# Source: https://github.com/netboxlabs/netbox-mcp-server
# =============================================================================
ARG NETBOX_MCP_VERSION=1.0.0
# -----------------------------------------------------------------------------
# Stage 1: Builder
# -----------------------------------------------------------------------------
FROM python:3.13-alpine3.21 AS builder
ARG NETBOX_MCP_VERSION
RUN apk add --no-cache git \
&& pip install --root-user-action=ignore --no-cache-dir --upgrade pip \
&& pip install --root-user-action=ignore --no-cache-dir uv
ENV UV_LINK_MODE=copy
ENV UV_PYTHON_PREFERENCE=only-system
WORKDIR /app
# Clone le repo à la version spécifiée
RUN git clone --depth 1 --branch v${NETBOX_MCP_VERSION} \
https://github.com/netboxlabs/netbox-mcp-server.git .
# Sync des dépendances avec cache uv
RUN --mount=type=cache,target=/root/.cache/uv \
uv sync --locked --no-dev
# -----------------------------------------------------------------------------
# Stage 2: Runtime
# -----------------------------------------------------------------------------
FROM python:3.13-alpine3.21
LABEL maintainer="Damien Arnodo"
LABEL org.opencontainers.image.title="NetBox MCP Server"
LABEL org.opencontainers.image.description="A read-only MCP server for NetBox"
LABEL org.opencontainers.image.url="https://github.com/netboxlabs/netbox-mcp-server"
LABEL org.opencontainers.image.source="https://github.com/netboxlabs/netbox-mcp-server"
LABEL org.opencontainers.image.licenses="Apache-2.0"
ENV PYTHONUNBUFFERED=1
RUN apk add --no-cache ca-certificates \
&& addgroup -g 1000 appuser \
&& adduser -D -u 1000 -G appuser appuser
COPY --from=builder --chown=appuser:appuser /app /app
WORKDIR /app
USER appuser
ENV PATH="/app/.venv/bin:$PATH"
EXPOSE 8000
CMD ["netbox-mcp-server"]

View File

@@ -0,0 +1 @@
1.0.0

View File

@@ -0,0 +1,70 @@
# NetBox MCP Server
Image Docker pour le [NetBox MCP Server](https://github.com/netboxlabs/netbox-mcp-server) - serveur Model Context Protocol permettant l'interaction read-only avec NetBox via LLMs.
## Usage avec Claude Desktop (STDIO)
Configuration dans `claude_desktop_config.json` :
```json
{
"mcpServers": {
"netbox": {
"command": "docker",
"args": [
"run", "-i", "--rm",
"-e", "NETBOX_URL",
"-e", "NETBOX_TOKEN",
"gitea.arnodo.fr/damien/netbox-mcp-server:latest"
],
"env": {
"NETBOX_URL": "https://netbox.example.com/",
"NETBOX_TOKEN": "your-api-token"
}
}
}
}
```
## Usage en mode HTTP
Pour les clients web MCP :
```bash
docker run --rm \
-e NETBOX_URL=https://netbox.example.com/ \
-e NETBOX_TOKEN=your-api-token \
-e TRANSPORT=http \
-p 8000:8000 \
gitea.arnodo.fr/damien/netbox-mcp-server:latest
```
Le serveur sera accessible sur `http://localhost:8000/mcp`.
## Variables d'environnement
| Variable | Défaut | Description |
|----------|--------|-------------|
| `NETBOX_URL` | - | URL de l'instance NetBox (requis) |
| `NETBOX_TOKEN` | - | Token API NetBox read-only (requis) |
| `TRANSPORT` | `stdio` | Transport MCP : `stdio` ou `http` |
| `VERIFY_SSL` | `true` | Vérification des certificats SSL |
| `LOG_LEVEL` | `INFO` | Niveau de log |
| `HOST` | `0.0.0.0` | Adresse d'écoute (mode HTTP) |
| `PORT` | `8000` | Port d'écoute (mode HTTP) |
## Outils MCP disponibles
| Outil | Description |
|-------|-------------|
| `get_objects` | Récupère les objets NetBox selon type et filtres |
| `get_object_by_id` | Détails d'un objet par son ID |
| `get_changelogs` | Historique des modifications |
## Exemples de requêtes
```
> Liste tous les devices du site 'DC1'
> Montre-moi l'utilisation IPAM
> Qui a modifié le routeur principal cette semaine ?
```

22
images/netbox/Dockerfile Normal file
View File

@@ -0,0 +1,22 @@
# =============================================================================
# NetBox Docker Image with Plugins
#
# Image NetBox personnalisée avec plugins pré-installés
# Basée sur l'image officielle netboxcommunity/netbox
# =============================================================================
ARG NETBOX_VERSION=latest
FROM netboxcommunity/netbox:${NETBOX_VERSION}
LABEL maintainer="Damien Arnodo"
LABEL description="NetBox with pre-installed plugins for homelab use"
# Copie du fichier de requirements des plugins
COPY plugin_requirements.txt /opt/netbox/
# Installation des plugins via uv pip (méthode officielle NetBox Docker)
RUN /usr/local/bin/uv pip install --no-cache -r /opt/netbox/plugin_requirements.txt
# NOTE: configuration.py et plugins.py doivent être montés au runtime
# via docker-compose pour configurer DynamicSchemaDict et les plugins.
# Voir: https://gitea.arnodo.fr/Damien/netbox-deployment

View File

@@ -0,0 +1 @@
v4.4

131
images/netbox/README.md Normal file
View File

@@ -0,0 +1,131 @@
# NetBox Docker Image avec Plugins
Image Docker NetBox personnalisée avec plugins pré-installés, construite automatiquement via Gitea Actions.
## Plugins inclus
Par défaut, les plugins suivants sont installés :
| Plugin | Description | Version (pour NetBox 4.4.x) |
|--------|-------------|----------------------------|
| `netbox-branching` | Branching et change management (NetBox Labs) | 0.7.x |
| `netbox-bgp` | Gestion des sessions BGP, peers, communities | 0.17.x |
| `netbox-secrets` | Gestion sécurisée des secrets et mots de passe | latest |
| `netbox-topology-views` | Visualisation de topologie réseau | latest |
## Utilisation
### Pull depuis le registry
```bash
# Dernière version
docker pull gitea.arnodo.fr/damien/netbox:latest
# Version spécifique
docker pull gitea.arnodo.fr/damien/netbox:v4.4
```
### Avec Docker Compose
Créer un `docker-compose.override.yml` pour utiliser l'image personnalisée :
```yaml
services:
netbox:
image: gitea.arnodo.fr/damien/netbox:v4.4
pull_policy: always
netbox-worker:
image: gitea.arnodo.fr/damien/netbox:v4.4
pull_policy: always
netbox-housekeeping:
image: gitea.arnodo.fr/damien/netbox:v4.4
pull_policy: always
```
## ⚠️ Configuration requise pour netbox-branching
Le plugin `netbox-branching` nécessite une configuration spéciale de la base de données. Tu dois modifier ta configuration NetBox pour wrapper `DATABASES` avec `DynamicSchemaDict`.
### Dans ton `configuration.py` ou via variables d'environnement :
```python
from netbox_branching.utilities import DynamicSchemaDict
DATABASES = DynamicSchemaDict({
'default': {
'ENGINE': 'django.db.backends.postgresql',
'NAME': 'netbox',
'USER': 'netbox',
'PASSWORD': 'password',
'HOST': 'postgres',
'PORT': '',
}
})
DATABASE_ROUTERS = [
'netbox_branching.database.BranchAwareRouter',
]
```
### Permissions PostgreSQL requises
L'utilisateur PostgreSQL doit avoir la permission de créer des schemas :
```sql
GRANT CREATE ON DATABASE netbox TO netbox;
```
Voir la [documentation officielle netbox-branching](https://netboxlabs.com/docs/extensions/branching/) pour plus de détails.
## Gestion des versions
La version de NetBox est définie dans le fichier `NETBOX_VERSION`. Pour changer de version :
1. Modifier le fichier `NETBOX_VERSION` avec la version souhaitée (ex: `v4.4`)
2. **Mettre à jour les versions des plugins** dans `plugin_requirements.txt` si nécessaire
3. Commit et push
4. Le CI va automatiquement :
- Builder l'image avec cette version de NetBox
- Tagger l'image avec `latest` ET avec la version (ex: `v4.4`)
### Compatibilité plugins / NetBox
| NetBox | netbox-branching | netbox-bgp |
|--------|------------------|------------|
| 4.4.x | 0.7.x | 0.17.x |
| 4.5.x | 0.8.x+ | 0.18.x+ |
## Personnalisation des plugins
### Ajouter un plugin
1. Éditer `plugin_requirements.txt` et ajouter le package PyPI
2. Éditer `plugins.py` et ajouter le plugin à la liste `PLUGINS`
3. Configurer le plugin dans `PLUGINS_CONFIG` si nécessaire
4. Commit et push - l'image sera rebuild automatiquement
## Structure des fichiers
```
images/netbox/
├── Dockerfile # Image principale
├── NETBOX_VERSION # Version de NetBox à utiliser
├── plugin_requirements.txt # Liste des plugins PyPI (avec versions)
├── plugins.py # Configuration des plugins
└── README.md # Cette documentation
```
## Plugins - Liens et documentation
- **netbox-branching** : https://github.com/netboxlabs/netbox-branching
- **netbox-bgp** : https://github.com/netbox-community/netbox-bgp
- **netbox-secrets** : https://github.com/Onemind-Services-LLC/netbox-secrets
- **netbox-topology-views** : https://github.com/netbox-community/netbox-topology-views
## Notes
- L'image utilise `uv pip` pour l'installation des plugins (méthode officielle NetBox Docker)
- Les assets statiques sont collectés au premier démarrage (pas au build)
- Compatible avec NetBox >= 4.0 (netbox-branching requiert NetBox 4.1+)
- Le fichier `NETBOX_VERSION` contrôle la version de base et le tag de l'image
- **Les versions des plugins sont fixées** pour garantir la compatibilité

View File

@@ -0,0 +1,29 @@
# =============================================================================
# NetBox Plugins Requirements
# =============================================================================
# Liste des plugins à installer dans l'image NetBox
# Format: nom-du-package==version (ou sans version pour la dernière)
#
# IMPORTANT: Les versions sont fixées pour garantir la compatibilité avec
# NetBox 4.4.x. Mettre à jour les versions lors du passage à NetBox 4.5+
#
# Documentation des plugins:
# - netbox-branching: Branching et change management (NetBox Labs)
# https://github.com/netboxlabs/netbox-branching
# - netbox-bgp: Gestion des sessions BGP, peers, communities
# https://github.com/netbox-community/netbox-bgp
# - netbox-secrets: Gestion des secrets (remplace netbox-secretstore pour NetBox >= 3.5)
# - netbox-topology-views: Visualisation de topologie réseau
# =============================================================================
# Plugins actifs - versions fixées pour NetBox 4.4.x
netboxlabs-netbox-branching>=0.7.0,<0.8.0
netbox-bgp>=0.17.0,<0.18.0
netbox-secrets
netbox-topology-views
# Plugins disponibles - décommente ceux dont tu as besoin
# netbox-documents
# netbox-acls
# netbox-qrcode
# netbox-proxbox