Compare commits
13 Commits
7555c25a58
...
1fb4a3ea3f
| Author | SHA1 | Date | |
|---|---|---|---|
| 1fb4a3ea3f | |||
| 167a3f1d0e | |||
| 14b4da71d1 | |||
| ee9b74ebe4 | |||
| 75c68f57ef | |||
| 526a488aba | |||
| 6809982d3d | |||
| c591816148 | |||
| b05aada942 | |||
| 8ab22a1e66 | |||
| 3d048c0d99 | |||
| b31055f944 | |||
| b05905590a |
@@ -89,11 +89,47 @@ jobs:
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
echo "========================================"
|
echo "========================================"
|
||||||
echo "Building ${IMAGE_NAME}:latest"
|
echo "Building ${IMAGE_NAME}"
|
||||||
echo "========================================"
|
echo "========================================"
|
||||||
|
|
||||||
docker build -t "${IMAGE_NAME}:latest" "${IMAGE_PATH}"
|
# Check for version file (format: <NAME>_VERSION or VERSION)
|
||||||
docker push "${IMAGE_NAME}:latest"
|
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
|
||||||
|
if [ -n "$BUILD_ARGS" ]; then
|
||||||
|
echo "🔧 Building with args: $BUILD_ARGS"
|
||||||
|
docker build $BUILD_ARGS -t "${IMAGE_NAME}:latest" "$IMAGE_PATH"
|
||||||
|
else
|
||||||
|
docker build -t "${IMAGE_NAME}:latest" "$IMAGE_PATH"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Push latest tag
|
||||||
|
docker push "${IMAGE_NAME}:latest"
|
||||||
echo "✅ Pushed ${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
|
done
|
||||||
|
|||||||
26
images/netbox/Dockerfile
Normal file
26
images/netbox/Dockerfile
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
# =============================================================================
|
||||||
|
# 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
|
||||||
|
|
||||||
|
# Copie de la configuration des plugins
|
||||||
|
COPY plugins.py /etc/netbox/config/plugins.py
|
||||||
|
|
||||||
|
# Collecte des assets statiques des plugins
|
||||||
|
# Nécessite une SECRET_KEY dummy pour le build
|
||||||
|
RUN SECRET_KEY="build-time-dummy-key-not-used-in-production" \
|
||||||
|
/opt/netbox/venv/bin/python /opt/netbox/netbox/manage.py collectstatic --no-input
|
||||||
1
images/netbox/NETBOX_VERSION
Normal file
1
images/netbox/NETBOX_VERSION
Normal file
@@ -0,0 +1 @@
|
|||||||
|
v4.4
|
||||||
129
images/netbox/README.md
Normal file
129
images/netbox/README.md
Normal file
@@ -0,0 +1,129 @@
|
|||||||
|
# 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 | Activé |
|
||||||
|
|--------|-------------|--------|
|
||||||
|
| `netbox-branching` | Branching et change management (NetBox Labs) | ✅ |
|
||||||
|
| `netbox-bgp` | Gestion des sessions BGP, peers, communities | ✅ |
|
||||||
|
| `netbox-secrets` | Gestion sécurisée des secrets et mots de passe | ✅ |
|
||||||
|
| `netbox-topology-views` | Visualisation de topologie réseau | ✅ |
|
||||||
|
|
||||||
|
## 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.2
|
||||||
|
```
|
||||||
|
|
||||||
|
### 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.2
|
||||||
|
pull_policy: always
|
||||||
|
netbox-worker:
|
||||||
|
image: gitea.arnodo.fr/damien/netbox:v4.2
|
||||||
|
pull_policy: always
|
||||||
|
netbox-housekeeping:
|
||||||
|
image: gitea.arnodo.fr/damien/netbox:v4.2
|
||||||
|
pull_policy: always
|
||||||
|
```
|
||||||
|
|
||||||
|
## 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.2`)
|
||||||
|
2. Commit et push
|
||||||
|
3. Le CI va automatiquement :
|
||||||
|
- Builder l'image avec cette version de NetBox
|
||||||
|
- Tagger l'image avec `latest` ET avec la version (ex: `v4.2`)
|
||||||
|
|
||||||
|
### Tags disponibles
|
||||||
|
|
||||||
|
| Tag | Description |
|
||||||
|
|-----|-------------|
|
||||||
|
| `latest` | Dernière version buildée |
|
||||||
|
| `v4.2` | Version spécifique de NetBox |
|
||||||
|
|
||||||
|
## 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
|
||||||
|
|
||||||
|
### Exemple : Activer netbox-proxbox
|
||||||
|
|
||||||
|
```python
|
||||||
|
# plugin_requirements.txt
|
||||||
|
netbox-proxbox
|
||||||
|
|
||||||
|
# plugins.py
|
||||||
|
PLUGINS = [
|
||||||
|
"netbox_branching",
|
||||||
|
"netbox_bgp",
|
||||||
|
"netbox_secrets",
|
||||||
|
"netbox_topology_views",
|
||||||
|
"netbox_proxbox", # Ajouter ici
|
||||||
|
]
|
||||||
|
|
||||||
|
PLUGINS_CONFIG = {
|
||||||
|
# ...
|
||||||
|
"netbox_proxbox": {
|
||||||
|
"proxmox": [
|
||||||
|
{
|
||||||
|
"domain": "proxmox.home.arpa",
|
||||||
|
"http_port": 8006,
|
||||||
|
"user": "netbox@pve",
|
||||||
|
"password": "your-api-token",
|
||||||
|
"ssl": True,
|
||||||
|
"node": "pve",
|
||||||
|
}
|
||||||
|
],
|
||||||
|
},
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
## Structure des fichiers
|
||||||
|
|
||||||
|
```
|
||||||
|
images/netbox/
|
||||||
|
├── Dockerfile # Image principale
|
||||||
|
├── NETBOX_VERSION # Version de NetBox à utiliser
|
||||||
|
├── plugin_requirements.txt # Liste des plugins PyPI
|
||||||
|
├── 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-branching** : https://github.com/netboxlabs/netbox-branching
|
||||||
|
|
||||||
|
## Notes
|
||||||
|
|
||||||
|
- L'image utilise `uv pip` pour l'installation des plugins (méthode officielle NetBox Docker)
|
||||||
|
- Les assets statiques sont collectés au build pour les plugins qui en ont
|
||||||
|
- Compatible avec NetBox >= 4.0 (netbox-branching requiert NetBox 4.0+)
|
||||||
|
- Le fichier `NETBOX_VERSION` contrôle la version de base et le tag de l'image
|
||||||
30
images/netbox/plugin_requirements.txt
Normal file
30
images/netbox/plugin_requirements.txt
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
# =============================================================================
|
||||||
|
# NetBox Plugins Requirements
|
||||||
|
# =============================================================================
|
||||||
|
# Liste des plugins à installer dans l'image NetBox
|
||||||
|
# Format: nom-du-package==version (ou sans version pour la dernière)
|
||||||
|
#
|
||||||
|
# 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
|
||||||
|
# - netbox-documents: Gestion de documents
|
||||||
|
# - netbox-acls: Gestion des ACLs
|
||||||
|
# - netbox-qrcode: Génération de QR codes
|
||||||
|
# - netbox-proxbox: Intégration Proxmox
|
||||||
|
# =============================================================================
|
||||||
|
|
||||||
|
# Plugins actifs
|
||||||
|
netbox-branching
|
||||||
|
netbox-bgp
|
||||||
|
netbox-secrets
|
||||||
|
netbox-topology-views
|
||||||
|
|
||||||
|
# Plugins disponibles - décommente ceux dont tu as besoin
|
||||||
|
# netbox-documents
|
||||||
|
# netbox-acls
|
||||||
|
# netbox-qrcode
|
||||||
|
# netbox-proxbox
|
||||||
54
images/netbox/plugins.py
Normal file
54
images/netbox/plugins.py
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
# =============================================================================
|
||||||
|
# NetBox Plugins Configuration
|
||||||
|
# =============================================================================
|
||||||
|
# Ce fichier est copié dans /etc/netbox/config/plugins.py
|
||||||
|
# Il active et configure les plugins installés
|
||||||
|
# =============================================================================
|
||||||
|
|
||||||
|
# Liste des plugins activés
|
||||||
|
# Doit correspondre aux packages installés dans plugin_requirements.txt
|
||||||
|
PLUGINS = [
|
||||||
|
"netbox_branching",
|
||||||
|
"netbox_bgp",
|
||||||
|
"netbox_secrets",
|
||||||
|
"netbox_topology_views",
|
||||||
|
# "netbox_documents",
|
||||||
|
# "netbox_acls",
|
||||||
|
# "netbox_qrcode",
|
||||||
|
# "netbox_proxbox",
|
||||||
|
]
|
||||||
|
|
||||||
|
# Configuration des plugins
|
||||||
|
PLUGINS_CONFIG = {
|
||||||
|
"netbox_branching": {
|
||||||
|
# Configuration par défaut
|
||||||
|
# Voir: https://github.com/netboxlabs/netbox-branching#configuration
|
||||||
|
},
|
||||||
|
"netbox_bgp": {
|
||||||
|
# Configuration par défaut
|
||||||
|
# "top_level_menu": True, # Ajoute un menu BGP au niveau supérieur
|
||||||
|
# "asdot": False, # Utilise la notation ASPLAIN par défaut
|
||||||
|
},
|
||||||
|
"netbox_secrets": {
|
||||||
|
# Configuration par défaut
|
||||||
|
# "public_key_size": 4096,
|
||||||
|
},
|
||||||
|
"netbox_topology_views": {
|
||||||
|
# Configuration par défaut
|
||||||
|
# "static_image_directory": "netbox_topology_views/img",
|
||||||
|
# "allow_coordinates_saving": True,
|
||||||
|
# "always_save_coordinates": False,
|
||||||
|
},
|
||||||
|
# "netbox_proxbox": {
|
||||||
|
# "proxmox": [
|
||||||
|
# {
|
||||||
|
# "domain": "proxmox.example.com",
|
||||||
|
# "http_port": 8006,
|
||||||
|
# "user": "root@pam",
|
||||||
|
# "password": "your-password",
|
||||||
|
# "ssl": True,
|
||||||
|
# "node": "pve",
|
||||||
|
# }
|
||||||
|
# ],
|
||||||
|
# },
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user