yuzutech / kroki

Creates diagrams from textual descriptions!
https://kroki.io
MIT License
2.79k stars 206 forks source link

Docker containers for more platforms #1084

Open MarcelWaldvogel opened 2 years ago

MarcelWaldvogel commented 2 years ago

Besides x68_64 aka amd64, various ARM platforms are being used for servers or development (Raspberry, Mac, AWS, …). The current docker build process can only build for the developer machine's architecture, typically amd64. This is then also what is published as a docker image on Docker Hub. As a result, ARM servers cannot use the docker image; a complete build system has to be set up on the ARM server before Kroki can be run.

Docker supports multi-architecture images seamlessly and efficiently; clients will transparently request the correct image for their architecture, if that architecture is available. For example, Debian base images are available in up to 9 architectures.

If the underlying code runs on multiple architectures as well, then it is easy to build a multi-architecture docker image, e.g., in Knot DNS. If not, these issues need to be sorted out first.

As most of the code is Java, Python, or JavaScript, I would expect the changes to be straightforward.

(Spin-off of #1066 discussion)

huyz commented 2 years ago

Since there are no existing kroki images for arm64, should I be building my own ARM image locally? Is it simple to do?

ggrossetie commented 2 years ago

The "gateway container" yuzutech/kroki isn't available for arm64 but I was still able to run it on a Mac mini M1. Other containers are multi-arch: https://github.com/yuzutech/kroki/pull/1227

In your logs, you can see that the application ("verticle") has been successfully deployed:

WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested
{"timestamp":"1657949007763","level":"WARN","thread":"vertx-blocked-thread-checker","logger":"io.vertx.core.impl.BlockedThreadChecker","message":"Thread Thread[vert.x-eventloop-thread-1,5,main] has been blocked for 2064 ms, time limit is 2000 ms","context":"default"}
{"timestamp":"1657949008745","level":"WARN","thread":"vertx-blocked-thread-checker","logger":"io.vertx.core.impl.BlockedThreadChecker","message":"Thread Thread[vert.x-eventloop-thread-1,5,main] has been blocked for 3073 ms, time limit is 2000 ms","context":"default"}
{"timestamp":"1657949008860","level":"INFO","thread":"vert.x-eventloop-thread-0","logger":"io.vertx.core.impl.launcher.commands.VertxIsolatedDeployer","message":"Succeeded in deploying verticle","context":"default"}

I'm not entirely sure why the event loop is blocked. You will need to provide additional information so I can try to reproduce this issue.

What happens when you send a simple query: GET /graphviz/svg/eNpLyUwvSizIUHBXqPZIzcnJ17ULzy_KSanlAgB1EAjQ? Do you see any logs? What is your OS? Are you using the latest version 0.17.2?

huyz commented 2 years ago

The connection just closes on me:

❯ telnet localhost 8000
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
GET /graphviz/svg/eNpLyUwvSizIUHBXqPZIzcnJ17ULzy_KSanlAgB1EAjQ
HTTP/1.0 400 Bad Request
content-length: 0

Connection closed by foreign host.

And there are no additional logs.

I'm on macOS 12.4. I assume it's the latest kroki. All I did was run docker run -p8000:8000 yuzutech/kroki which should give me the latest image, right?

Not sure if this helps:

❯ docker images --digests yuzutech/kroki
REPOSITORY       TAG       DIGEST                                                                    IMAGE ID       CREATED       SIZE
yuzutech/kroki   latest    sha256:aed7c32710ebe953822f6f0f8397ccdc7efe782221656564971fbcbe5ff0b557   2aa269335e5d   6 weeks ago   514MB
ggrossetie commented 2 years ago

Could you please use curl in verbose mode and also copy/paste the logs you get from the container?

huyz commented 2 years ago

Oh never mind, it works now! (I had forgotten to specify HTTP/1.1 in my telnet command)

Well, mostly. If I try a mermaid diagram, I get Error 503: Connection refused: /127.0.0.1:8002

ggrossetie commented 2 years ago

Mermaid is provided as a companion container, see: https://docs.kroki.io/kroki/setup/install/#_companion_containers

Thomas-Ganter commented 1 year ago

I made some local changes and was able to successfully build (and upload to Docker Hub) the gateway server as a Multi-Arch-Image for both arm64 and amd64 — and it deployed successfully on my Raspberry Kubernetes Cluster.

image image

Here is a commit I made with all the changes I had to do to make it work.

Mainly:

I hope this at least gives those who seek a solution an option to build the stuff themself. Or you just use the image I pushed to Docker Hub.

image

I was not able to find anyone who already did this, so I hope this is helpful.

lidaling commented 1 year ago

I made some local changes and was able to successfully build (and upload to Docker Hub) the gateway server as a Multi-Arch-Image for both arm64 and amd64 — and it deployed successfully on my Raspberry Kubernetes Cluster. image image

Here is a commit I made with all the changes I had to do to make it work.

Mainly:

  • I moved some dependency builds into containerized builds as I did not want to pollute my machine with loads of build artefacts.
  • I had to disable some tests, some because they depended on locally installed binaries (which were not there on my machine) and some because they simply failed.
  • Instead of bakeing the code i wrote a small script to build and push the server.
  • The Dockerfile for the server contained explicit references to x86 runtimes which I had to convert into multi-arch.

I hope this at least gives those who seek a solution an option to build the stuff themself. Or you just use the image I pushed to Docker Hub. image

I was not able to find anyone who already did this, so I hope this is helpful.

It works

felixvanoost commented 1 year ago

@Thomas-Ganter @lidaling I have a PR open (#1487) to build and release both arm64 and amd64 images. Give it a try if you have time!

maxsitu commented 2 months ago

Hi @Thomas-Ganter have you ever tested kroki-erd on your build? I kept getting syntax error generating ERD diagram. The other types work for me. The sample url I used is http://localhost:8000/erd/svg/eNqLDkgtKs7Pi-XSykvMTeXKSM1MzyjhKodQ2kmZRSUZ8Tn5yYklmfl58ZkpXFzRPlAeUAuQn5xZUslVXJJYksqVnF-aV1JUycUFMVJBS1fXUAGmGgCFAiQX

felixvanoost commented 2 months ago

Hi @Thomas-Ganter have you ever tested kroki-erd on your build? I kept getting syntax error generating ERD diagram. The other types work for me. The sample url I used is http://localhost:8000/erd/svg/eNqLDkgtKs7Pi-XSykvMTeXKSM1MzyjhKodQ2kmZRSUZ8Tn5yYklmfl58ZkpXFzRPlAeUAuQn5xZUslVXJJYksqVnF-aV1JUycUFMVJBS1fXUAGmGgCFAiQX

@maxsitu There's an open issue #1239 to resolve this, but the maintainer of erd hasn't been active recently and hasn't finished merging my upstream PR.