Fly.ioTutorial
Deploy Your Own (Not) Midjourney Bot on Fly GPUs
Summary
This tutorial builds a Discord image-generation bot that uses Fooocus, an open-source interface for Stable Diffusion, to provide a Midjourney-like /imagine command. It separates the system into a normal Fly Machine running a Python Pycord bot and a GPU Machine running Fooocus-API, with Flycast connecting them over Fly.io’s private network. The bot defers Discord responses, polls for the generated image each second, and uploads the resulting file, while the post notes that this blocking flow will not perform well for hundreds of simultaneous users. Fly GPU rootfs supports the nearly 12GB image, and an L40S setup costs about $3.20/hr when running, with scale-to-zero intended to avoid charges for unused compute. GPU activity is verified with nvidia-smi, and the source code can be extended with additional commands and image-to-image features.
Context
The project provides an easier way to access Stable Diffusion through Discord, using Fooocus to reduce manual configuration while deploying the bot and image-synthesis API separately. The post also addresses GPU image size, private service communication, scale-to-zero, and the cost of running an L40S.
Approach / What changed
Deploy a Python Pycord Discord bot on a normal Fly Machine and Fooocus-API on a Fly GPU Machine. Connect them through Flycast over Fly.io’s private network, use Discord’s deferred responses and polling to deliver generated files, and verify GPU usage with nvidia-smi.
Takeaways
Fooocus adds GPT-2-based prompt expansion and supports style chaining, aspect ratios, and negative prompts for image generation.
The bot’s image-generation flow is blocking and polls the filesystem every second, so the post says it will not perform well for hundreds of concurrent Discord users.
An L40S GPU costs $2.50/hr on demand; with VM resources and model storage, the post estimates about $3.20/hr while the GPU Machine is running.
Source and freshness
- Source
- fly.io
- Published
- Added to Yomu
- Last updated
Summaries are generated from the original by a language model. Check the original before relying on it.
Keep reading
Related reading
The Good Stuff
Paid picks we use ourselves. Links carry a referral code — a subscription through one earns us a commission at no extra cost to you.
The best engineering reads, once a week
One useful email. Unsubscribe anytime.