Host In Docker (Draft)
Learn how to host Takumi as a standalone service and call from your application.
The following content is just a rough draft and the docker image is not yet available. Please open an issue on our GitHub repository if you have any questions.
Takumi works well with Node.js and Bun Integration, but when you get to a certain scale, you might want to decouple the actual rendering part from your application.
Or if you are not developing in JavaScript, like in Golang or Python, you might want to host Takumi as a standalone service.
Concept
Since Takumi defines everything in JSON format, it's easy to distribute even without JavaScript runtime.
To offload rendering part from your application, you can expose this service to the public network with proper cache-control and integrity check setup.
Installation
Takumi server is available as a Docker image on ghcr.io, you can start a container with volumes mounted to your fonts and images directory.
docker run \
-v ./fonts:/fonts \
-v ./images:/images \
-p 5123:5123 \
ghcr.io/kane50613/takumi-server:latest \
--fonts /fonts \
--images /images \
--port 5123
Options
--fonts
The path to the fonts directory.--images
The path to the images directory.--port
The port to listen on.--draw-debug-border
Enables drawing of debug borders around elements.
If you are familiar with Rust, you can also check the Args
struct to understand the available options.
Verify is it working
Once your container is running, you can verify it with curl.
curl -X POST http://localhost:5123/v1/image \
-H "Content-Type: application/json" \
-d '{
"width": 400,
"height": 200,
"backgroundColor": "#ffffff",
"children": [
{
"type": "text",
"content": "Hello, Takumi!",
"fontSize": 24,
"color": "#000000",
"x": 20,
"y": 20
}
]
}' \
--output test-image.png
API
POST /v1/image
Generate an image from a node tree.
GET /v1/metrics
(WIP) Prometheus metrics.
GET /v1/health
(WIP) Health check.
If theres any issues or unexpected behavior in the installation process, please open an issue on our GitHub repository.