2.4 KiB
Note: currently running at: http://gateway.iron.computer:8080/
IronFunctions
First, let's fire up an IronFunctions instance. Copy the example.env file into a file named .env and fill in the missing values.
Then start your functions instance:
docker run --env-file .env --rm -it --privileged -p 8080:8080 iron/functions
Usage
First things first, create an app/service: TOOD: App or service??
Create App
iron create app APP_NAME
# OR
curl -H "Content-Type: application/json" -X POST -d '{"name":"APP_NAME"}' http://localhost:8080/api/v1/apps
Create a Route for your Function
Now add routes to the app. First we'll add a route to the output of a docker container:
iron add route myapp /hello iron/hello
# OR
curl -H "Content-Type: application/json" -X POST -d '{"path":"/hello", "image":"iron/hello"}' http://localhost:8080/api/v1/apps/myapp/routes
And how about a slackbot too:
curl -H "Content-Type: application/json" -X POST -d '{"path":"/guppy","image":"treeder/guppy:0.0.2", "content_type": "application/json"}' http://localhost:8080/api/v1/apps/myapp/routes
Calling your Function
Surf to your function: http://localhost:8080/hello?app=APP_NAME . Boom!
To pass in data to your function,
Your function will get the body of the request as is, and the headers of the request will be passed in as env vars.
curl -H "Content-Type: application/json" -X POST -d '{"name":"Johnny"}' http://localhost:8080/hello?app=APP_NAME
Using IronFunctions Hosted by Iron.io
Simply point to https://functions.iron.io instead of localhost and add your Iron.io Authentication header (TODO: link), like this:
curl -H "Authorization: Bearer IRON_TOKEN" -H "Content-Type: application/json" -X POST -d '{"name":"APP_NAME"}' https://functions.iron.io/api/v1/apps
And you'll get an ironfunctions.com host:
APP_NAME.ironfunctions.com/PATH
Updating Your Images
Tag your images with a version, eg treeder/guppy:0.0.5 then use that including the tag and update
the route.
Examples
TODO: Link to examples in various languages TODO: Link to slackbots (easiest way to host slackbots?)
Operations
This is info on how to run and manage IronFunctions.
Logging
Run logspout container on your server.
Monitoring
TODO
Scaling
TODO