SHSF (Self-Hostable Serverless Functions) V2
Because why would you use AWS Lambda when you have a raspberry pi, home lab, or even a old laptop lying around?
SHSF is a self-hostable serverless functions platform that allows you to run your code without worrying about infrastructure. It's like having your own mini AWS Lambda, but on your own hardware.
🌟 Overview
SHSF has a web interface, supports Python and Go as main runtimes and allows you to trigger functions via HTTP(S) requests or cron jobs.
Requiremnets
- Docker with Compose plugin
- 512MB Ram minimum (not really but if you have less, might not even compile)
- A modern-ish browser
Installation
-
Clone the repository
git clone https://github.com/Space-Banane/shsf.git cd shsf -
Configure environment
cp .env.example .env nano .env # Edit configuration, add database details and stuff # If needed there is a commented database section in the docker-compose.yml -
Start the services
docker-compose up -d -
Access the interface
Open your browser and navigate to
http://localhost:3000(or your configured port)
Runtime data directory
SHSF stores function files and runtime caches in an OS-specific data directory:
- Linux/Docker:
/opt/shsf_data - Windows local development:
./shsf_datainside theBackendfolder
This keeps Docker bind mounts valid on Windows while preserving the normal /opt/shsf_data layout on Linux servers.
Usage
- Open the web interface and register (first user becomes admin).
- Create a function: Click "Create Function", pick Python or Go, write your code, and save.
- Run your function:
- Click "Run" in the UI
- Use the provided HTTP API endpoint
- Set up a schedule (cron) if needed
Function Structure
Python function example:
def main(args):
# Your function logic here
name = args.get('body', {}).get('name', 'World')
return f"Hello, {name}!"
Go function example:
package main
import "fmt"
func main_user(args interface{}) (interface{}, error) {
// Your function logic here
payload, _ := args.(map[string]interface{})
name := "World"
if body, ok := payload["body"].(map[string]interface{}); ok {
if n, ok := body["name"].(string); ok {
name = n
}
}
return fmt.Sprintf("Hello, %s!", name), nil
}
Thanks for using (if you do)
Star the repo, complain about bugs. thanks