Sign inSign up

mochify/mochify-lite

By mochify

•Updated 8 months ago

Privacy-first image optimizer. Zero-persistence, RAM-only processing. Built for high-security infra.

Image
Developer tools
1

985

mochify/mochify-lite repository overview

⁠mochify‑lite – C++ Drogon Image Compression Service (Lite)

mochify/mochify-lite is a lightweight, self‑hostable image compression service built on C++20 and the Drogon web framework. It is the “lite” backend variant of Mochify, designed for secure, single‑threaded deployments with predictable resource usage.

The live service at mochify.xyz⁠ provides a more feature‑rich stack (Jpegli, AVIF, WebP, AVX512 SIMD, larger limits), while this image targets simpler, hardened self‑hosting setups.


⁠Features

  • C++ Drogon backend
    High‑performance, low‑latency HTTP API implemented in C++ using Drogon’s asynchronous HTTP server.

  • JPEG and PNG only (up to 10 MB)
    The lite image accepts JPEG and PNG input with a maximum file size of 10 MB per image, making resource usage easy to reason about.

  • libjpeg‑based JPEG compression
    Uses libjpeg for JPEG recompression, which keeps builds smaller and dependencies simpler compared with the Jpegli stack used on the main site.

  • Single‑threaded by design
    Processes requests on a single thread to better match low‑resource VPS or container environments and simplify performance tuning.

  • Security‑hardened container profile
    Supports running with a read‑only filesystem, a tmpfs scratch buffer, and no new privileges, reducing the attack surface of the service.


⁠Lite vs. Live Site

Aspectmochify/mochify-lite (this Docker image)Live site (mochify.xyz)
FrameworkDrogon (C++ HTTP backend)Same C++20 engine, scaled for public traffic
JPEG backendlibjpegJpegli for higher JPEG density
SIMD optimizationsMinimalAVX512‑optimized compression paths
Max file size per image10 MB20 MB
Parallel processingSingle‑threadedParallel jobs
Accepted formatsJPEG, PNGJPEG, PNG, AVIF, WebP, JXL
Container hardeningRead‑only FS + tmpfs scratch recommendedManaged by Mochify infrastructure
Primary use caseSelf‑hosted, private, low‑footprint deploymentsPublic, high‑throughput bulk compression

⁠Secure Docker Run Example

The following example demonstrates a hardened way to run mochify-lite, with a read‑only root filesystem and a small in‑memory buffer for temporary data:

docker run -d \
  --name mochify-lite \
  -p 5555:5555 \
  --read-only \
  --tmpfs /app/temp_ram_buffer:rw,size=64m,mode=1777 \
  --security-opt=no-new-privileges \
  mochify/mochify-lite:latest

This setup:

  • Binds the service to http://localhost:5555⁠
  • Mounts the container filesystem as read-only
  • Provides a 64mb tmpfs at /app/temp_ram_buffer for transient data
  • Disables acquisition of any new Linux capabilities or privileges inside the container

⁠HTTP API Example

A minimal example compressing a JPEG via curl:

curl -X POST "http://localhost:5555/v1/squish" \
     -H "Content-Type: image/jpeg" \
     --data-binary "@mochi.jpg" \
     --output mochi_optimized.jpg

Notes:

  • Content-Type should match the image format (image/jpeg or image/png).
  • The request body is the raw image bytes (--data-binary keeps the file unmodified).
  • The response body is the optimized image, written here to mochi_optimized.jpg.

You can integrate this into your own service (e.g., from Node, Python, Go, or C++) by issuing an HTTP POST with the image bytes and saving the response.

⁠Constraints (Lite Mode)

  • Maximum file size: 10 MB per image.
  • Accepted formats: JPEG and PNG only.
  • No Jpegli, AVIF, WebP, or JXL encoders in this image.
  • Single‑threaded request handling.

For larger files, more formats, and heavier optimizations (Jpegli, AVX512 paths, 20 MB limit), refer to the main Mochify deployment described at mochify.xyz.

Tag summary

Content type

Image

Digest

sha256:759060ff7…

Size

20.5 MB

Last updated

8 months ago

docker pull mochify/mochify-lite