Skip to content

Commit

Permalink
netbox
Browse files Browse the repository at this point in the history
  • Loading branch information
SaswatPadhi committed Dec 26, 2024
1 parent f232459 commit b904711
Show file tree
Hide file tree
Showing 11 changed files with 275 additions and 0 deletions.
63 changes: 63 additions & 0 deletions .github/workflows/compose-test_netbox.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: "Docker Compose Test (Netbox)"

on:
pull_request:
branches: master
push:
branches: master
schedule:
- cron: "0 8 * * *"

env:
TARGET_SERVICE: netbox
TARGET_TIMEOUT: 120

jobs:
test:
runs-on: ubuntu-latest
steps:
-
name: "Git: Checkout"
uses: actions/checkout@v4
-
name: "Service: Setup"
run: |
cp .github/workflows/config/options.conf "${TARGET_SERVICE}/options.override.conf"
cp .github/workflows/config/options.conf "traefik/options.override.conf"
-
name: "Service: Start"
run: |
./comp up --skip-prereqs --labels no ${TARGET_SERVICE}
-
name: "Service: Wait"
run: |
cd ${TARGET_SERVICE} ; cat .env env/*
sleep ${TARGET_TIMEOUT}s
-
name: "Service: Test"
run: |
if ! ./comp status --skip-prereqs ${TARGET_SERVICE}; then
docker ps
cd ${TARGET_SERVICE} ; docker compose logs
exit 1
fi
-
name: "Service: Restart with Traefik"
run: |
./comp down,up ${TARGET_SERVICE}
-
name: "Service: Wait"
run: |
sleep ${TARGET_TIMEOUT}s ; sleep ${TARGET_TIMEOUT}s
-
name: "Service: Test with Traefik"
run: |
if ! ./comp status ${TARGET_SERVICE} ; then
docker ps
cd ${TARGET_SERVICE} ; docker compose logs
cd traefik ; docker compose logs
exit 1
fi
cd traefik
docker compose exec -T traefik wget --spider --no-check-certificate https://127.0.0.1:9443/netbox/ \
|| (docker ps ; docker compose logs ; cd ../${TARGET_SERVICE} ; docker compose logs ; exit 1)
69 changes: 69 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -559,6 +559,75 @@ for optionally customizing compositions via _overrides_.
:heavy_multiplication_x:
</td>
</tr>
<tr>
<th>
<a href='https://github.com/netbox-community/netbox'>Netbox</a>
<br>
<sub>:9443/netbox</sub>
<hr>
<a href='https://github.com/padhi-homelab/services/actions?query=workflow%3A%22Docker+Compose+Test+%28Netbox%29%22'><img src='https://img.shields.io/github/actions/workflow/status/padhi-homelab/services/compose-test_netbox.yml?branch=master&logo=github&logoWidth=24&style=flat-square&label=tests'></img></a>
</th>
<th>
B <br> B <br> A
</th>
<th align='right'>
<a href='https://hub.docker.com/_/postgres'>
<sub>postgres</sub>
</a>
<br>
<a href='https://hub.docker.com/r/valkey/valkey'>
<sub>redis</sub>
</a>
<br>
<a href='https://hub.docker.com/r/padhihomelab/netbox/'>
<sub>netbox</sub>
</a>
</th>
<td align='center'>
<code><sub>17.2...ne</sub></code>
<br>
<code><sub>8.0.1...ne</sub></code>
<br>
<code><sub>4.1.10</sub></code>
</td>
<td align='center'>
:heavy_check_mark:
</td>
<td align='center'>
:heavy_check_mark:
<br>
:heavy_multiplication_x:
<br>
:heavy_check_mark:
</td>
<td align='center'>
:heavy_check_mark:
<br>
:heavy_multiplication_x:
<br>
:heavy_multiplication_x:
</td>
<td align='center'>
:heavy_check_mark:
</td>
<td align='center'>
:heavy_check_mark:
</td>
<td align='center'>
:heavy_check_mark:
<br>
:heavy_multiplication_x:
<br>
:heavy_multiplication_x:
</td>
<td align='center'>
:heavy_check_mark:
<br>
:heavy_multiplication_x:
<br>
:heavy_multiplication_x:
</td>
</tr>
<tr>
<th>
<a href='https://nextcloud.com/'>Nextcloud</a>
Expand Down
7 changes: 7 additions & 0 deletions netbox/docker-compose.labels.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
services:
netbox:
labels:
traefik.enable: true
traefik.http.routers.netbox.rule: PathPrefix(`/${NETBOX_BASE_PATH:?}`)
traefik.http.routers.netbox.entryPoints: lan-https
traefik.http.services.netbox.loadBalancer.server.port: 80
16 changes: 16 additions & 0 deletions netbox/docker-compose.logging.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
services:
postgres:
logging:
options:
max-size: "1m"
max-file: "1"
redis:
logging:
options:
max-size: "1m"
max-file: "1"
netbox:
logging:
options:
max-size: "4m"
max-file: "1"
12 changes: 12 additions & 0 deletions netbox/docker-compose.pre_hook.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/usr/bin/env bash

set -Eumo pipefail

SELF_DIR="$(cd -P -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd -P)"
DATA_DIR="$SELF_DIR/data"

mkdir -p "$DATA_DIR/postgres/var/lib/postgresql/data" \
"$DATA_DIR/redis/data" \
"$DATA_DIR/netbox/opt/netbox/netbox/media" \
"$DATA_DIR/netbox/opt/netbox/netbox/reports" \
"$DATA_DIR/netbox/opt/netbox/netbox/scripts"
86 changes: 86 additions & 0 deletions netbox/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
networks:
proxy:
external: true

services:
postgres:
hostname: postgres
image: postgres:17.2-alpine
restart: unless-stopped

security_opt:
# NOTE: Do NOT add a [space] before `true` below.
- no-new-privileges:true
user: ${USER_ID:?}

networks:
- default
volumes:
- ./data/postgres/var/lib/postgresql/data:/var/lib/postgresql/data:rw

env_file:
- env/postgres

healthcheck:
test: "psql -U $$POSTGRES_USER -d $$POSTGRES_DB -c 'SELECT 1'"
interval: 15s
timeout: 3s
start_period: 30s

redis:
hostname: redis
image: valkey/valkey:8.0.1-alpine
restart: unless-stopped

security_opt:
# NOTE: Do NOT add a [space] before `true` below.
- no-new-privileges:true
user: ${USER_ID:?}

command: |-
sh -c 'exec valkey-server --requirepass "$${REDIS_PASSWORD}"'
networks:
- default
volumes:
- ./data/redis/data:/data:rw

env_file:
- env/redis
environment:
TZ: ${TZ:?}

healthcheck:
test: '[ $$(valkey-cli --pass "$${REDIS_PASSWORD}" ping) = ''PONG'' ]'
start_period: 10s
interval: 5s

netbox:
hostname: netbox
image: 567b20c7ee5f
restart: unless-stopped

security_opt:
# NOTE: Do NOT add a [space] before `true` below.
- no-new-privileges:true

depends_on:
- postgres
- redis

networks:
- default
- proxy
volumes:
- ./data/netbox/opt/netbox/netbox/media:/opt/netbox/netbox/media:rw
- ./data/netbox/opt/netbox/netbox/reports:/opt/netbox/netbox/reports:rw
- ./data/netbox/opt/netbox/netbox/scripts:/opt/netbox/netbox/scripts:rw

env_file:
- env/postgres
- env/redis
- env/netbox
environment:
DOCKER_UID: ${USER_ID:?}
DOCKER_GID: ${GROUP_ID:?}
TZ: ${TZ:?}
8 changes: 8 additions & 0 deletions netbox/env/netbox
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
POSTGRES_HOST: postgres
REDIS_HOST: redis
SECRET_KEY: 'a988a1a6d5b1c49753bf185a7ef3b40fec60ff05b88c2dec237382b71e53e919'
NETBOX_BASE_PATH: ${NETBOX_BASE_PATH:?}
HOUSEKEEPING_INTERVAL_SECONDS: 7200
ALLOWED_HOSTS: '*'
CSRF_TRUSTED_ORIGINS: "https://localhost"
CORS_ORIGIN_ALLOW_ALL: True
3 changes: 3 additions & 0 deletions netbox/env/postgres
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
POSTGRES_DB: 'netbox'
POSTGRES_USER: 'nbox_pg_user'
POSTGRES_PASSWORD: 'nbdb.pg~p4ss'
1 change: 1 addition & 0 deletions netbox/env/redis
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
REDIS_PASSWORD: 'netbox~r3d1s-password'
9 changes: 9 additions & 0 deletions netbox/meta.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
messages:
up:
post:
- >-
${_bold_}${_CUR_COMP_}${_normal_} may now be accessed on
${_fg_magenta_}${_uline_}https://${SERVER_LAN_FQDN}:${SERVER_LAN_HTTPS_PORT}/${NETBOX_BASE_PATH}/${_normal_}
pre_reqs:
- traefik
1 change: 1 addition & 0 deletions netbox/static.env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
NETBOX_BASE_PATH=netbox

0 comments on commit b904711

Please sign in to comment.