dainok / netdoc

Automatic Network Documentation plugin for NetBox
GNU General Public License v3.0
84 stars 14 forks source link

netbox-docker-2.6.1 install Netdoc during build missing script for Diagrams #126

Closed toystorykiwi closed 1 month ago

toystorykiwi commented 3 months ago

Hello,

i have configured the netbox-docker 2.6.1 / Netbox version 3.5.9 with the latest Netdoc plugin all is working except the diagram section.

I suppose the root cause is this one (missing script diagram.js and the other vis) I don't understand why during the plugin installation those file weren't copy in the correct path image Is it necessary to specify something in the dockerfile-plugin? or maybe run some "mkdir" to setup the folder location?

At the moment i found a "dirty" workaround, I have cloned the Netdoc repo and copied the missing file, adding this row on the dockerfile-plugin COPY ./netdoc/netdoc/static/netdoc /opt/netbox/netbox/static/netdoc image

Thank you Any help or suggestions would be appreciated

dainok commented 3 months ago

Hi @toystorykiwi In the previous NetDoc version I made a mistake and yes, some files were missing. Please use the latest NetDoc version (3.5.21).

$ wget -q -O- https://files.pythonhosted.org/packages/c4/fb/d1f2fcc572dab5344afacdff240baafb2d59054d55c1cd80da829054a20a/netdoc-3.5.21.tar.gz | tar tzv | grep diagram
-rw-r--r--  0 runner docker     577 Mar 27 08:38 netdoc-3.5.21/netdoc/migrations/0005_diagram_include_global_vrf_alter_diagram_details.py
-rw-r--r--  0 runner docker    4434 Mar 27 08:38 netdoc-3.5.21/netdoc/static/netdoc/js/diagram.js
-rw-r--r--  0 runner docker    1439 Mar 27 08:38 netdoc-3.5.21/netdoc/templates/netdoc/diagram.html
toystorykiwi commented 3 months ago

Thanks for this feedback but the strange things is that i'm already using the Netdoc 3.5.21. image

I also tried to force the version in the "plugin-requirements" and build again but nothing change. (browser cache is clear) Should I configure "some additional folder" on the dockerfile-plugin before the plugin installation? RUN mkdir -p /opt/netbox/netbox/static/netdoc This is my Dockerile-Plugins file

` FROM netboxcommunity/netbox:v3.5.9

COPY ./plugin_requirements.txt / RUN apt-get update RUN apt-get -y install git RUN git clone --depth=1 https://github.com/networktocode/ntc-templates /opt/ntc-templates RUN /opt/netbox/venv/bin/pip install --no-warn-script-location -r /plugin_requirements.txt

Add friday 12 04 2024 to fix Topology-Views-Plugin

RUN mkdir -p /opt/netbox/netbox/static/netbox_topology_views/img RUN cp -rv /opt/netbox/venv/lib/python3.10/site-packages/netbox_topology_views/static/netbox_topology_views /opt/netbox/netbox/static

Temporary fix for Netdoc missing Diagrams

COPY ./netdoc/netdoc/static/netdoc /opt/netbox/netbox/static/netdoc `

Thanks

dainok commented 3 months ago

In the first post you mentioned Netbox version 3.5.9. Try to use docker shell with find to list all files under /opt. And check if files are missing.

toystorykiwi commented 3 months ago

Hi @dainok sorry for late reply I have found something

Ouput find command without applying ---> COPY ./netdoc/netdoc/static/netdoc /opt/netbox/netbox/static/netdoc

unit@110d8cf22027:/opt/netbox/netbox$ find /opt/ -name 'diagram.js'
/opt/netbox/venv/lib/python3.10/site-packages/netdoc/static/netdoc/js/diagram.js
unit@110d8cf22027:/opt/netbox/netbox$ find /opt/ -name 'netdoc.js'
/opt/netbox/venv/lib/python3.10/site-packages/netdoc/static/netdoc/js/netdoc.js
unit@110d8cf22027:/opt/netbox/netbox$ find /opt/ -name 'vis-network.min.js'
/opt/netbox/venv/lib/python3.10/site-packages/netdoc/static/netdoc/js/vis-network.min.js
unit@110d8cf22027:/opt/netbox/netbox$

And as you said the js were present BUT not in the correct folder

Then I thought that I had a similar issue with the "Topology-View-Plugin" and I have found on the community (at the moment i can't find the post) a suggestion, " add this line on your dockerfile-plugin ---> RUN cp -rv /opt/netbox/venv/lib/python3.10/site-packages/netbox_topology_views/static/netbox_topology_views So I thought if you "forked from Topology-View-Plugin" maybe I have the same issue indeed I perform the same command RUN cp -rv /opt/netbox/venv/lib/python3.10/site-packages/netdoc/static/netdoc /opt/netbox/netbox/static and now also the Diagram from netdoc are working

AFTER adding the dedicated command RUN cp -rv for Netdoc

unit@91dd3e668be7:/opt/netbox/netbox$ find /opt/ -name 'diagram.js'
/opt/netbox/venv/lib/python3.10/site-packages/netdoc/static/netdoc/js/diagram.js
/opt/netbox/netbox/static/netdoc/js/diagram.js
unit@91dd3e668be7:/opt/netbox/netbox$ find /opt/ -name 'netdoc.js'
/opt/netbox/venv/lib/python3.10/site-packages/netdoc/static/netdoc/js/netdoc.js
/opt/netbox/netbox/static/netdoc/js/netdoc.js
unit@91dd3e668be7:/opt/netbox/netbox$ find /opt/ -name 'vis-network.min.js'
/opt/netbox/venv/lib/python3.10/site-packages/netdoc/static/netdoc/js/vis-network.min.js
/opt/netbox/netbox/static/netdoc/js/vis-network.min.js
unit@91dd3e668be7:/opt/netbox/netbox$ 

I think during the building process those file can't be copied in the correct location, but if I add the RUN command in the dockerfile-plugin seems fixing the issue

Let me know what you think Thanks

dainok commented 3 months ago

Hi @toystorykiwi thank you for your tests. I rewrote Topology-View, but yes I was inspired by it. Honestly it doesn't make sense because on non-Docker setup NetDoc is installed using PIP and running under site-packages. So I don't know why on Docker a manual cp is required.

Unless... the non-Docker setup is broken and no one has notified it to me, but I don't think so.