I tried to draw a system configuration diagram with Diagrams on Docker

I thought it would be good to see the article "Draw a system configuration diagram in Python using Diagrams | Developers.IO", but Python I didn't have an environment, so I tried it with Docker.

Prepare a Docker image

Official documentation says "Install diagrams with pip, also install Graphviz. So create a Dockerfile accordingly.

Dockerfile


FROM python:latest
WORKDIR /app
RUN apt update && \
    apt install -y python3-pygraphviz && \
    pip install diagrams

Build. Keep a Docker image named diagrams for easy execution later.

$ docker build -t diagrams .

This completes the creation of the diagrams: latest Docker image.

Prepare the Diagrams file

Prepare the Official Quickstart file.

diagram.py


from diagrams import Diagram
from diagrams.aws.compute import EC2
from diagrams.aws.database import RDS
from diagrams.aws.network import ELB

with Diagram("Web Service", show=False):
    ELB("lb") >> EC2("web") >> RDS("userdb")

It's fairly intuitive, but see the official documentation for more details. Official document English but easy to read because it is simple and small in volume. Also, Examples is easy to understand.

Run Diagrams

According to the official documentation, if you have a local Python environment, you can run it with $ python diagram.py.

Since we are using a Docker container this time, it is OK if we volume mount the current directory where diagram.py is created and execute the command python diagram.py.

Currently the current directory looks like this.

$ ls
Dockerfile      diagram.py

Run the container.

$ docker run --rm -v `pwd`:/app diagrams python diagram.py

Another ls will generate a png file.

$ ls 
Dockerfile      diagram.py      web_service.png

Check the contents of web_service.png.

$ open web_service.png

web_service.png The result is as per the official Quick Start!

Summary

I was able to easily try Diagrams using Docker. I tried Examples and made a configuration diagram as I wanted to make, but all I can say is "It can be managed by code", "Simple and easy to see", and "There are a lot of Nodes (like icons)". On the other hand, as for itching, when it gets complicated, it may be like "Node placement is not there!", And it seems that you can not write a Cluster that straddles Cluster, so "Apply the same security group to different AZ instances. I felt that it was difficult to express something like.

Either way, I think it's worth a try.

References -Draw a system configuration diagram in Python using Diagrams | Developers.IO

Recommended Posts

I tried to draw a system configuration diagram with Diagrams on Docker
I tried to draw a configuration diagram using Diagrams
I tried to draw a route map with Python
I tried to display GUI on Mac with X Window System
I tried to easily create a fully automatic attendance system with Selenium + Python
I tried to implement Minesweeper on terminal with python
I tried to implement a recommendation system (content-based filtering)
[Go + Gin] I tried to build a Docker environment
I tried to automatically generate a password with Python3
I tried to implement a volume moving average with Quantx
I tried to automatically create a report with Markov chain
I tried to solve a combination optimization problem with Qiskit
I tried to get started with Hy ・ Define a class
I tried to sort a random FizzBuzz column with bubble sort.
[Visualization] I want to draw a beautiful graph with Plotly
I tried to divide with a deep learning language model
When I tried to create a project using Python on Docker with PyCharm, it didn't work, but it worked with Docker Compose.
[Shell startup] I tried to display the shell on the TV with a cheap Linux board G-cluster
I tried to build a service that sells machine-learned data at explosive speed with Docker
[5th] I tried to make a certain authenticator-like tool with python
I tried to make a system that fetches only deleted tweets
[2nd] I tried to make a certain authenticator-like tool with python
A memorandum when I tried to get it automatically with selenium
[3rd] I tried to make a certain authenticator-like tool with python
[Python] A memo that I tried to get started with asyncio
I tried to create a list of prime numbers with python
I tried to make a periodical process with Selenium and Python
I tried to register a station on the IoT platform "Rimotte"
I tried to make a 2channel post notification application with Python
I tried to get started with Bitcoin Systre on the weekend
I tried to create Bulls and Cows with a shell program
I tried to summarize everyone's remarks on slack with wordcloud (Python)
I tried to make a todo application using bottle with python
[4th] I tried to make a certain authenticator-like tool with python
[1st] I tried to make a certain authenticator-like tool with python
From "drawing" to "writing" the configuration diagram: Try drawing the AWS configuration diagram with Diagrams
I tried to make a strange quote for Jojo with LSTM
I tried Diagram as Code (Diagrams) which can manage the configuration diagram code
I tried to make a mechanism of exclusive control with Go
I tried using "Asciichart Py" which can draw a beautiful graph on the console with Python.
I tried to build a SATA software RAID configuration that boots the OS on Ubuntu Server
I tried to create a linebot (implementation)
I tried to implement Autoencoder with TensorFlow
I tried to create a linebot (preparation)
I tried to visualize AutoEncoder with TensorFlow
I tried to get started with Hy
I tried a functional language with Python
I tried to implement CVAE with PyTorch
I tried to make a Web API
I tried to solve TSP with QAOA
I made a configuration file with Python
I tried to introduce a serverless chatbot linked with Rakuten API to Teams
Python: I tried to make a flat / flat_map just right with a generator
I tried object detection with YOLO v3 (TensorFlow 2.0) on a windows CPU!
I tried to communicate with a remote server by Socket communication with Python.
I tried to implement a blockchain that actually works with about 170 lines
I tried to create a program to convert hexadecimal numbers to decimal numbers with python
I tried to create a plug-in with HULFT IoT Edge Streaming [Development] (2/3)
I tried to make a calculator with Tkinter so I will write it
I tried to make "Sakurai-san" a LINE BOT with API Gateway + Lambda
I tried to make a traffic light-like with Raspberry Pi 4 (Python edition)