Improve diagram
This commit is contained in:
parent
dfdf161182
commit
a594e5d083
2 changed files with 54 additions and 10 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1,3 +1,4 @@
|
|||
*.secret.env
|
||||
|
||||
serguzim.net.png
|
||||
diagram_assets/
|
||||
|
|
63
diagram.py
63
diagram.py
|
@ -1,21 +1,51 @@
|
|||
""" Diagram to visualize serguzim.net """
|
||||
# pragma pylint: disable=pointless-statement
|
||||
|
||||
import glob
|
||||
import mimetypes
|
||||
import os
|
||||
from urllib.request import urlretrieve
|
||||
|
||||
from diagrams import Cluster, Diagram
|
||||
|
||||
from diagrams.oci.compute import Container, OCIRegistry
|
||||
from diagrams.custom import Custom
|
||||
|
||||
from diagrams.oci.storage import ObjectStorage
|
||||
|
||||
from diagrams.onprem.ci import Droneci
|
||||
from diagrams.onprem.database import Influxdb, Postgresql
|
||||
from diagrams.onprem.inmemory import Redis
|
||||
from diagrams.onprem.monitoring import Grafana, Prometheus
|
||||
from diagrams.onprem.network import Caddy
|
||||
from diagrams.onprem.vcs import Gitea
|
||||
|
||||
import requests
|
||||
|
||||
|
||||
ASSETS_DIR = "./diagram_assets/"
|
||||
os.makedirs(ASSETS_DIR, exist_ok=True)
|
||||
|
||||
|
||||
def add_to_groups(service, *groups):
|
||||
""" Add a service to groups like 'db_users' """
|
||||
for group in groups:
|
||||
group.append(service)
|
||||
|
||||
def get_custom_icon(name, url):
|
||||
""" Download icon for service to location. Reuses existing icons. """
|
||||
|
||||
icon_no_extension = os.path.join(ASSETS_DIR, name)
|
||||
|
||||
exisiting_icons = glob.glob(icon_no_extension + ".*")
|
||||
if exisiting_icons:
|
||||
return exisiting_icons[0]
|
||||
|
||||
response = requests.head(url, allow_redirects=True)
|
||||
extension = mimetypes.guess_extension(response.headers['Content-Type'])
|
||||
|
||||
icon = icon_no_extension + extension
|
||||
urlretrieve(url, icon)
|
||||
return icon
|
||||
|
||||
|
||||
with Diagram("serguzim.net", show=False):
|
||||
|
||||
|
@ -31,7 +61,12 @@ with Diagram("serguzim.net", show=False):
|
|||
|
||||
proxy = Caddy()
|
||||
|
||||
ci = Droneci("ci.serguzim.me")
|
||||
ICON_URL = "https://avatars.githubusercontent.com/u/105618662"
|
||||
analytics = Custom("analytics.serguzim.me", get_custom_icon("umami", ICON_URL))
|
||||
add_to_groups(analytics, services, db_users)
|
||||
|
||||
ICON_URL = "https://avatars.githubusercontent.com/u/84780935"
|
||||
ci = Custom("ci.serguzim.me", get_custom_icon("woodpecker-ci", ICON_URL))
|
||||
add_to_groups(ci, services, db_users)
|
||||
|
||||
db_time = Influxdb("tick.serguzim.me")
|
||||
|
@ -42,20 +77,26 @@ with Diagram("serguzim.net", show=False):
|
|||
graph = Grafana("graph.serguzim.me")
|
||||
add_to_groups(graph, services, db_users)
|
||||
|
||||
mail = Container("mail.serguzim.me")
|
||||
ICON_URL = "https://avatars.githubusercontent.com/u/23747925"
|
||||
mail = Custom("mail.serguzim.me", get_custom_icon("mailcow", ICON_URL))
|
||||
add_to_groups(mail, services)
|
||||
|
||||
matrix = Container("matrix.serguzim.me")
|
||||
ICON_URL = "https://avatars.githubusercontent.com/u/8418310?s=200&v=4"
|
||||
matrix = Custom("matrix.serguzim.me", get_custom_icon("matrix", ICON_URL))
|
||||
add_to_groups(matrix, services, db_users, objectstore_users)
|
||||
|
||||
prometheus = Prometheus("prometheus.serguzim.me")
|
||||
add_to_groups(prometheus, services)
|
||||
|
||||
registry = OCIRegistry("registry.serguzim.me")
|
||||
add_to_groups(registry , services, db_users, objectstore_users)
|
||||
ICON_URL = "https://github.com/TandoorRecipes/recipes/raw/develop/cookbook/static/assets/logo_color512.png"
|
||||
recipies = Custom("recipies.serguzim.me", get_custom_icon("tandoor", ICON_URL))
|
||||
add_to_groups(recipies, services, db_users)
|
||||
|
||||
vcs = Gitea("git.serguzim.me")
|
||||
add_to_groups(vcs, services, db_users)
|
||||
vcs = Gitea("git.serguzim.me\nregistry.serguzim.me")
|
||||
add_to_groups(vcs, services, db_users, objectstore_users)
|
||||
|
||||
webdis = Redis("webdis.huck.serguzim.me")
|
||||
add_to_groups(webdis, services)
|
||||
|
||||
db_users >> db
|
||||
proxy >> services
|
||||
|
@ -65,7 +106,9 @@ with Diagram("serguzim.net", show=False):
|
|||
services = []
|
||||
|
||||
proxy = Caddy()
|
||||
minecraft = Container("minecraft.serguzim.me")
|
||||
|
||||
ICON_URL = "https://www.pikpng.com/pngl/m/11-111495_minecraft-block-png-minecraft-logo-clipart.png"
|
||||
minecraft = Custom("minecraft.serguzim.me", get_custom_icon("minecraft", ICON_URL))
|
||||
add_to_groups(minecraft, services)
|
||||
|
||||
proxy >> services
|
||||
|
|
Reference in a new issue