Crates.io | spsd |
lib.rs | spsd |
version | 0.1.4 |
source | src |
created_at | 2024-01-12 12:23:46.565276 |
updated_at | 2024-01-21 23:53:11.040549 |
description | state persistent serverless devboxes |
homepage | |
repository | |
max_upload_size | |
id | 1097636 |
size | 174,815 |
spsd is a command line utility for managing state persistent, serverless devboxes. With spsd, you can spin up instances with 16 vCPUs, 32 gb of memory, and 500 gb of persistent disk in a region of your choice with a port open to the internet in seconds.
Instances are machines (Firecracker VMs) hosted by fly.io, launched from a docker image. You can bring your own or use one of the base images included in spsd.
You can install spsd via homebrew by running brew tap tfsingh/spsd && brew install spsd
in your terminal. You can also install from source with cargo install spsd
(must install flyctl in this case).
Navigate to fly.io, create an account (you also need to configure billing although small instances should be free), and generate an access token.
Configure your profile with spsd profile <API_KEY> <ALLOCATE_IP>
, with API_KEY being the api key you generated above and ALLOCATE_IP (expose your instances to the internet) being either y/n.
Create an instance by running spsd new
and filling out the relevant fields.
Run the instance you just created serverlessly with spsd sl <NAME>
. Note that any data you'd like to be persisted should be kept on the /data path.
Destroy an instance
name
— Name of the instanceList instances and associated data (name, image, cpus, memory, region, port, state)
ip
— List attached IPv4 addresses (optional)Create a new instance
name
— Name of the instanceimage
— URL of the imagecpus
— Number of vCPUs (1, 2, 4, 8, 12, 16)memory
— Amount of memory (256 - 32768 MB)volume
— Size of volume (1-500 GB)region
— Region of the instanceport
— Port to expose (optional, 1024-65536)Please note that Fly enforces CPU/memory ratios that may render your configuration invalid.
Set fly.io profile
api_key
— Fly API key (overwrites existing)allocate_ip
— Allocate a dedicated IPv4 address ($2/mo)Run an instance serverlessly (stops instance on graceful disconnection)
name
— Name of the instanceStart and connect to an instance
name
— Name of the instanceStop an instance
name
— Name of the instanceHow do I configure my instance to respond to HTTP requests?
First, allocate an IP to your app if you haven't already (see below). Ensure your instance has a port exposed (for example, we'll say we configured our instance to listen on port 8080), and run spsd list ip
to view your dedicated IPv4 address (i.e. 123.1.23.12). Ensure your sever is listening on whatever port you exposed above in your instance configuration locally (localhost:8080) and it'll be accesible publicly at the same port on your allocated ip (http://123.1.23.12:8080).
How can I allocate an IP if I didn't initially?
Assuming your api key is valid, run flyctl ip allocate-v4 -a <APP_NAME>
in your terminal (app name is available on the fly.io dashboard).
How do I use my own Docker image?
Publish your image with docker push
, ensure your repository is public, and enter "registry-1.docker.io/YOUR-DOCKER-USERNAME/IMAGE-NAME:TAG" as your image url.
Value | City |
---|---|
ams | Amsterdam |
bom | Mumbai |
cdg | Paris |
dfw | Dallas |
fra | Frankfurt |
hkg | Hong Kong |
iad | Washington DC |
lax | Los Angeles |
lhr | London |
nrt | Tokyo |
ord | Chicago |
scl | Santiago |
sea | Seattle |
sin | Singapore |
sjc | San Jose |
syd | Sydney |
yyz | Toronto |
The following can be entered as an image instead of providing a concrete url:
Thank you to Erik Bernhardsson for the inspiration for spsd, nebula for the code used to parse responses from Fly's API, and the fly.io team for building what they have.