DEV Community

Noah
Noah

Posted on

I got tired of metered image CDN pricing, so I built my own

I've built and rebuilt image pipelines for side projects more times than I can count, and every time it's the same story: hosted CDN, love it for a month, then start dreading the bill because it moves with traffic you don't control. So this time I just self-hosted it. Fottly — image transforms and AI background removal through a plain URL, AGPL-3.0, reading from a bucket I actually own.

GET /t/w_800,c_fit,bg_remove,f_webp/product.jpg

Two things from building it that are worth sharing.

Picking the background removal model took way longer than it should have. The default one cropped a leg off a photo of a character standing up. Switched models, that fixed it, but then a "better" model OOM-killed the container because its file was almost 1GB. Ended up resizing images to 1600px before background removal even runs — barely hurts quality, stops the crashes.

The one that actually annoyed me: I had ufw locked down, default deny, only ssh/http/https open. Turns out Docker writes its own iptables rules when you publish a container port, and those rules run ahead of ufw's — so the "firewall" wasn't blocking anything for stuff running in containers. Fixed it by binding to 127.0.0.1 and putting Caddy in front. If you run ufw + Docker, worth checking you're not in the same boat.

Repo's here if you want to poke at it: https://github.com/Noah-1919/Fottly

Top comments (0)