DEV Community

Kazilsky
Kazilsky

Posted on

Deploy to Raspberry Pi in One Command: Building a Rust-based Deployment Tool

Article

Ever SSH'd into 5 different Raspberry Pis just to git pull and restart a service? Yeah, me too. That's why I built Flare.

The Problem

I run a small homelab with multiple Raspberry Pis:

  • Pi in living room: Home automation
  • Pi in garage: Temperature monitoring
  • Pi in basement: Blog and personal sites

Every time I wanted to deploy an update:

ssh pi@192.168.1.50
cd ~/apps/temperature-monitor
git pull
npm install
sudo systemctl restart temp-monitor

ssh pi@192.168.1.51
# ... repeat ...

ssh pi@192.168.1.52
# ... and again ...
Enter fullscreen mode Exit fullscreen mode

Ansible? Too heavy. Docker Swarm? Overkill for 3 Pis. I just wanted git push → deployed.

The Solution

I built Flare - a lightweight deployment tool in Rust that:

  • Auto-discovers devices on your network
  • Deploys from GitHub/Gitea with one command
  • Manages apps (start/stop/restart)
  • Sets up databases automatically

Here's what it looks like:

![Demo GIF]https://github.com/Velooroo/Flare/raw/main/assets/demo.gif

How It Works

1. Start daemon on your Pi

# On Raspberry Pi
flared
# Listening on :7530
Enter fullscreen mode Exit fullscreen mode

That's it. No Docker, no Python, just a 10MB binary.

2. Discover devices from your laptop

# On your laptop
$ flare discover
[0] 192.168.1.50:7530 (new)
[1] 192.168.1.51:7530 (new)

$ flare sync 0
Name: pi-living-room
Enter fullscreen mode Exit fullscreen mode

Flare uses UDP broadcast to find devices automatically. No static IPs needed!

3. Add config to your project

Create flare.toml in your repo:

[app]
name = "temp-monitor"
version = "1.0.0"

[run]
command = "python sensor.py"
port = 8080

[database]
type = "sqlite"
name = "readings.db"
Enter fullscreen mode Exit fullscreen mode

4. Deploy!

flare deploy github-user/temp-monitor --device pi-living-room
Enter fullscreen mode Exit fullscreen mode

Real-World Example

Here's my temperature monitoring setup:

# sensor.py
import time
import sqlite3
from flask import Flask, jsonify
from w1thermsensor import W1ThermSensor

app = Flask(__name__)
sensor = W1ThermSensor()

@app.route('/temperature')
def get_temp():
    temp = sensor.get_temperature()

    # Store in SQLite
    conn = sqlite3.connect('readings.db')
    c = conn.cursor()
    c.execute('INSERT INTO readings VALUES (?, ?)', 
              (time.time(), temp))
    conn.commit()

    return jsonify({'temperature': temp})

if __name__ == '__main__':
    app.run(host='0.0.0.0', port=8080)
Enter fullscreen mode Exit fullscreen mode

With this flare.toml:

[app]
name = "temperature-monitor"
version = "1.0.0"

[build]
command = "pip install -r requirements.txt"

[run]
command = "python sensor.py"
port = 8080

[database]
type = "sqlite"
name = "readings.db"
preseed = "schema.sql"

[health]
url = "http://localhost:8080/temperature"
timeout = 10
Enter fullscreen mode Exit fullscreen mode

Deploy to all Pis at once:

flare deploy my-github/temp-monitor --device all
Enter fullscreen mode Exit fullscreen mode

Technical Details

For the curious, here's what happens under the hood:

  1. Discovery: UDP broadcast on port 7001
  2. Authentication: Argon2 hashed tokens (auto-generated)
  3. Transport: TLS encrypted TCP (self-signed certs)
  4. Protocol: Length-prefixed messages
  5. Isolation: Optional systemd scopes

The stack:

  • Rust with tokio for async
  • rustls for TLS
  • clap for CLI
  • serde for serialization

Security

Flare generates unique tokens for each device during sync:

// CLI generates random token
let token = generate_random_token();

// Hashes with argon2
let hash = argon2::hash(token);

// Sends hash to daemon
daemon.register(hash);

// Future deploys use this token
deploy_with_token(token);
Enter fullscreen mode Exit fullscreen mode

No passwords to manage, rotatable anytime.

Performance

On a Raspberry Pi Zero W:

  • Binary size: 10MB
  • RAM usage: ~20MB idle, ~40MB during deploy
  • Deploy time: 5-15 seconds depending on repo size
  • CPU: ~5% idle, ~30% during deploy

Compare to Ansible:

  • Ansible needs Python (100MB+)
  • Takes minutes to run playbooks
  • Requires maintaining inventory files

Current Limitations 📝

Being honest - this is v0.2:

  • Gateway reverse proxy incomplete (static sites work, APIs coming)
  • No Windows daemon support yet
  • Single database per app
  • Basic health checks

But it works great for my homelab!

Try It!

# Install
cargo install flare-cli flare-daemon
# Or download binaries from GitHub

# Quick test
flared &
flare discover
flare deploy your-github/your-app
Enter fullscreen mode Exit fullscreen mode

GitHub: https://github.com/Velooroo/flare

What's Next?

  • [ ] Web dashboard
  • [ ] Multi-database support
  • [ ] Metrics collection
  • [ ] Plugin system

Conclusion

Flare solved my "I just want to deploy to Pi" problem. It might not be Kubernetes, but for homelabs and IoT projects, sometimes simple is better.

If you're running a homelab or IoT devices, give it a try! I'd love feedback on what features you'd want.

What's your deployment setup for edge devices? Do you use Ansible, scripts, or something else? Let me know in the comments!

Top comments (3)

Collapse
 
richardpascoe profile image
Richard Pascoe

A truly excellent post, which has encouraged me to do more with my own Raspberry Pi. Looking forward to reading more about your experiences and projects in the future!

Collapse
 
kazilsky profile image
Kazilsky

Thanks so much Richard! Really appreciate the kind words!

I'm planning a series on building a custom Linux distro for Pi using Buildroot - stripping it down to just what's needed for edge deployments. Should be a fun deep dive!

What kind of projects are you running on your Pi? Always looking for inspiration and real-world use cases to tackle.

And if you do try Flare, would love to hear your feedback - still early days and learning what people actually need vs what I think they need :)

Collapse
 
richardpascoe profile image
Richard Pascoe • Edited

You are more than welcome, Kazilsky.

I will certainly be reading your series on a custom distro for the Raspberry Pi - that sounds very interesting indeed!

To be honest, not running anything currently. My 8GB Raspberry Pi 4 was actually my daily driver for a while - learning Python with Thonny. I have an Argon One case and an SSD for it now, so that's my next project. Then I plan to pick up another Raspberry Pi 4 to play some of my favourite Spectrum text adventures on, using the spare official case and power supply unit I'll have.

I will most certainly give Flare a look in the future and let you know how I go!