SAM
SAM

Reputation: 159

Creating a docker container of the generated SchemaSpy documentation site

I'm trying to create a permanent docker container to host the documentation site generated by SchemaSpy of my mysql database.

Here is the relevant section from my docker-compose.yaml:

    docs:
        image: schemaspy/schemaspy:latest
        container_name: Docs
        ports:
            - "5558:80"
        environment:
            DB_USER: root
            DB_PASS: pass111
            DB_NAME: EduSys
            DB_PORT: "1026"
            DB_HOST: 138.150.210.254
        depends_on:
            - "mysql"
        volumes:
            - "/SchemaSpy/output:/output"
        command: >
            -u root -p pass111 -db EduSys -t mysql -host 138.150.210.254 -port 1026 -s EduSys -renderer none -nohtmlimages -nodot
        restart: always

   mysql:
        image: mysql:8.2
        container_name: MySQL
        environment:
            MYSQL_ROOT_PASSWORD: pass111
            MYSQL_OPTIONS: --sort_buffer_size=2M
        ports:
            - "1026:3306"
        volumes:
            - mysql_db:/var/lib/mysql

volumes:
  mysql_db:

The container runs and can be viewed using docker ps.

Trying to access 138.150.210.254:5558/index.html gives me a "The site can not be reached" page.

Using docker logs Docs prints out these error messages:

INFO  - Starting Main v6.2.4 on 6bb5f0568ddd with PID 1 (/usr/local/lib/schemaspy/schemaspy-6.2.4-app.jar started by java in /)
INFO  - The following profiles are active: default
INFO  - Started Main in 1.372 seconds (JVM running for 1.889)
INFO  - Starting schema analysis
INFO  - Connected to MySQL - 8.2.0
INFO  - Gathering schema details
Gathering schema details..................................................................................................................................................................................................................(1sec)
Connecting relationships..................................................................................................................................................................................................................(2sec)
Writing/graphing summary.INFO  - Gathered schema details in 2 seconds
INFO  - Writing/graphing summary
INFO  - Graphviz renderer set to ':cairo'
.ERROR - dot -Tpng:cairo relationships.real.compact.dot -orelationships.real.compact.png -Tcmapx: Warning: cell size too small for content
ERROR - dot -Tpng:cairo relationships.real.compact.dot -orelationships.real.compact.png -Tcmapx: in label of node Schools
ERROR - dot -Tpng:cairo relationships.real.compact.dot -orelationships.real.compact.png -Tcmapx: Warning: cell size too small for content
ERROR - dot -Tpng:cairo relationships.real.compact.dot -orelationships.real.compact.png -Tcmapx: in label of node Courses
ERROR - dot -Tpng:cairo relationships.real.compact.dot -orelationships.real.compact.png -Tcmapx: Warning: cell size too small for content
ERROR - dot -Tpng:cairo relationships.real.compact.dot -orelationships.real.compact.png -Tcmapx: in label of node Degrees
ERROR - dot -Tpng:cairo relationships.real.large.dot -orelationships.real.large.png -Tcmapx: Warning: cell size too small for content
ERROR - dot -Tpng:cairo relationships.real.large.dot -orelationships.real.large.png -Tcmapx: in label of node Schools
ERROR - dot -Tpng:cairo relationships.real.large.dot -orelationships.real.large.png -Tcmapx: Warning: cell size too small for content
ERROR - dot -Tpng:cairo relationships.real.large.dot -orelationships.real.large.png -Tcmapx: in label of node Courses
ERROR - dot -Tpng:cairo relationships.real.large.dot -orelationships.real.large.png -Tcmapx: Warning: cell size too small for content
ERROR - dot -Tpng:cairo relationships.real.large.dot -orelationships.real.large.png -Tcmapx: in label of node Degrees
.ERROR - dot -Tpng:cairo relationships.implied.compact.dot -orelationships.implied.compact.png -Tcmapx: Warning: cell size too small for content
ERROR - dot -Tpng:cairo relationships.implied.compact.dot -orelationships.implied.compact.png -Tcmapx: in label of node Schools
ERROR - dot -Tpng:cairo relationships.implied.compact.dot -orelationships.implied.compact.png -Tcmapx: Warning: cell size too small for content
ERROR - dot -Tpng:cairo relationships.implied.compact.dot -orelationships.implied.compact.png -Tcmapx: in label of node Courses
ERROR - dot -Tpng:cairo relationships.implied.compact.dot -orelationships.implied.compact.png -Tcmapx: Warning: cell size too small for content
ERROR - dot -Tpng:cairo relationships.implied.compact.dot -orelationships.implied.compact.png -Tcmapx: in label of node Degrees
ERROR - dot -Tpng:cairo relationships.implied.large.dot -orelationships.implied.large.png -Tcmapx: Warning: cell size too small for content
ERROR - dot -Tpng:cairo relationships.implied.large.dot -orelationships.implied.large.png -Tcmapx: in label of node Schools
ERROR - dot -Tpng:cairo relationships.implied.large.dot -orelationships.implied.large.png -Tcmapx: Warning: cell size too small for content
ERROR - dot -Tpng:cairo relationships.implied.large.dot -orelationships.implied.large.png -Tcmapx: in label of node Courses
ERROR - dot -Tpng:cairo relationships.implied.large.dot -orelationships.implied.large.png -Tcmapx: Warning: cell size too small for content
ERROR - dot -Tpng:cairo relationships.implied.large.dot -orelationships.implied.large.png -Tcmapx: in label of node Degrees
.ERROR - dot -Tpng:cairo orphans.dot -oorphans.png -Tcmapx: dot: graph is too large for cairo-renderer bitmaps. Scaling by 0.420959 to fit
.....(11sec)
Writing/diagramming detailsINFO  - Completed summary in 11 seconds
INFO  - Writing/diagramming details
.........................ERROR - dot -Tpng:cairo Schools.1degree.dot -oSchools.1degree.png -Tcmapx: Warning: cell size too small for content
ERROR - dot -Tpng:cairo Schools.1degree.dot -oSchools.1degree.png -Tcmapx: in label of node Schools
ERROR - dot -Tpng:cairo Schools.2degrees.dot -oSchools.2degrees.png -Tcmapx: Warning: cell size too small for content
ERROR - dot -Tpng:cairo Schools.2degrees.dot -oSchools.2degrees.png -Tcmapx: in label of node Courses
ERROR - dot -Tpng:cairo Schools.2degrees.dot -oSchools.2degrees.png -Tcmapx: Warning: cell size too small for content
ERROR - dot -Tpng:cairo Schools.2degrees.dot -oSchools.2degrees.png -Tcmapx: in label of node Schools
................ERROR - dot -Tpng:cairo Courses.1degree.dot -oCourses.1degree.png -Tcmapx: Warning: cell size too small for content
ERROR - dot -Tpng:cairo Courses.1degree.dot -oCourses.1degree.png -Tcmapx: in label of node Courses
ERROR - dot -Tpng:cairo Courses.2degrees.dot -oCourses.2degrees.png -Tcmapx: Warning: cell size too small for content
ERROR - dot -Tpng:cairo Courses.2degrees.dot -oCourses.2degrees.png -Tcmapx: in label of node Courses
ERROR - dot -Tpng:cairo Courses.2degrees.dot -oCourses.2degrees.png -Tcmapx: Warning: cell size too small for content
ERROR - dot -Tpng:cairo Courses.2degrees.dot -oCourses.2degrees.png -Tcmapx: in label of node Schools
............ERROR - dot -Tpng:cairo Programs.1degree.dot -oPrograms.1degree.png -Tcmapx: Warning: cell size too small for content
ERROR - dot -Tpng:cairo Programs.1degree.dot -oPrograms.1degree.png -Tcmapx: in label of node Courses
ERROR - dot -Tpng:cairo Programs.1degree.dot -oPrograms.1degree.png -Tcmapx: Warning: cell size too small for content
ERROR - dot -Tpng:cairo Programs.1degree.dot -oPrograms.1degree.png -Tcmapx: in label of node Schools

What I don't understand is why it's ignoring the -nohtmlimages and -nodot flags I specified in my command so that it doesn't generate any diagrams? And why can't I reach it when navigating to the port it should be hosted on?

PS: the ip and passwords included in this question are unreal, to maintain security.

Upvotes: 0

Views: 26

Answers (1)

SAM
SAM

Reputation: 159

Ok, I think I reached a satisfactory solution. I realised I need to do two things:

  1. Generate the static website using schemaspy
  2. Run a web server to serve the static website so I can actually access it using the ip and the port

So I created two docker containers; one to do each of these steps. I would prefer if I can do both these things in one container, but I kept running into errors trying to achieve that so I'm letting it be like this for now.

Here's my current working setup in docker-compose.yaml:

    docs:
        image: schemaspy/schemaspy:latest
        container_name: Docs
        environment:
            DB_USER: root
            DB_PASS: pass111
            DB_NAME: EduSys
            DB_PORT: "1026"
            DB_HOST: 138.150.210.254
        depends_on:
            - "mysql"
        volumes:
            - schemaspy-data:/output
        entrypoint: >
            sh -c "schemaspy -t mysql -host 138.150.210.254 -port 1026 -db EduSys -s EduSys -u root -p pass111"

    zcedudocs_web:
        image: nginx:latest
        container_name: nginx
        ports:
            - "5558:80"
        volumes:
            - schemaspy-data:/usr/share/nginx/html:ro
        depends_on:
            - docs

    mysql:
        image: mysql:8.2
        container_name: MySQL
        environment:
            MYSQL_ROOT_PASSWORD: pass111
            MYSQL_OPTIONS: --sort_buffer_size=2M
        ports:
            - "1026:3306"
        volumes:
            - mysql_db:/var/lib/mysql

    volumes:
       mysql_db:
       schemaspy-data:

I used docker compose up -d to run everything, and it works now! Just remember to use http not https. And the url looks like this http://138.150.210.254:5558/index.html

Note: I can still see the same Graphviz errors if I use docker logs Docs, but turns out it doesn't actually prevent the website generation. I still don't know why it doesn't go away when I use -nohtmlimages and -nodot. Any input on that would be appreciated.

Upvotes: 0

Related Questions