Micro service to serve thumbnails
  • Go 92.3%
  • Dockerfile 7.7%
Find a file
Arnas Udovic 87fc3bede2
All checks were successful
Backend Build and Test / backend-tasks (push) Successful in 1m0s
badge link fixwq
2026-06-02 17:06:45 +03:00
.forgejo/workflows vips for build 2026-06-02 17:04:35 +03:00
.dockerignore working micro service; ready to try 2026-05-28 09:16:46 +03:00
.gitignore Initial commit 2026-05-28 04:54:36 +00:00
docker-compose.yaml working micro service; ready to try 2026-05-28 09:16:46 +03:00
Dockerfile working micro service; ready to try 2026-05-28 09:16:46 +03:00
go.mod working micro service; ready to try 2026-05-28 09:16:46 +03:00
go.sum working micro service; ready to try 2026-05-28 09:16:46 +03:00
LICENSE Initial commit 2026-05-28 04:54:36 +00:00
main.go added storage cleaner 2026-05-28 10:34:44 +03:00
main_test.go added storage cleaner 2026-05-28 10:34:44 +03:00
README.md badge link fixwq 2026-06-02 17:06:45 +03:00

tumbuloze

Build Status

Micro service to serve thumbnails from Zordsdavini :)

Features

  • Dynamic image resizing using bimg (powered by libvips).
  • Local filesystem caching to avoid redundant processing.
  • Supports multiple resizing modes.
  • Dockerized for easy deployment.

API Usage

Endpoint: GET /i/{mode}/{encoded_url}

Supported Modes

The service supports four resizing patterns:

  • w{width}: Resize to specific width, preserving aspect ratio (e.g., w200).
  • h{height}: Resize to specific height, preserving aspect ratio (e.g., h15).
  • {width}x{height}: Force resize to exact dimensions, ignoring aspect ratio (e.g., 300x200).
  • m{width}x{height}: Resize to max width or height, preserving aspect ratio (e.g., m100x100).

URL Encoding

The {encoded_url} must be the source image URL, escaped for use in a URL path.

Example:

  • Source: https://example.com/photo.jpg
  • Encoded: https%3A%2F%2Fexample.com%2Fphoto.jpg
  • Full Path: /i/w100/https%3A%2F%2Fexample.com%2Fphoto.jpg

Prerequisites

  • Docker & Docker Compose (Recommended)
  • Go 1.26+ (If building locally)
  • libvips 8.10+ (If building locally)

Local Development Setup

To build and run the service locally, you need to install libvips and its development headers.

Arch Linux

sudo pacman -S libvips openslide base-devel

Note: openslide is required by some libvips modules on Arch; installing it resolves "unable to load vips-openslide.so" warnings.

Deployment

Docker Compose (with Traefik)

The included docker-compose.yaml provides a full setup including Traefik as a reverse proxy.

docker-compose up -d

The service will be accessible at http://tumbuloze.localhost (ensure your hosts file maps this to 127.0.0.1).

Docker Only

docker build -t tumbuloze .
docker run -p 8080:8080 -v tumbuloze_storage:/storage tumbuloze

Storage & Caching

Processed images are stored in a local volume to speed up subsequent requests.

Filesystem Structure: /{host}/{url_path_to_dir}/{mode}/{image_filename}

Example path inside the container: /storage/example.com/img/w100/photo.jpg (for source https://example.com/img/photo.jpg)

Environment Variables

  • PORT: Port the service listens on (default: 8080).
  • CACHE_DIR: Directory for storing thumbnails (default: /storage).
  • CLEANUP_INTERVAL: How often to run the cache cleanup worker (e.g., 12h, 24h, 1h). Set to 0 to disable. (default: 24h).
  • MAX_AGE_DAYS: Number of days to keep cached files (default: 90).