2016-06-17 19:43:26 -07:00
2015-07-22 00:01:54 -07:00
2016-06-16 19:32:12 -07:00
2013-04-02 16:50:35 -07:00
2015-10-09 18:22:32 -07:00
2016-06-17 19:43:26 -07:00
2016-06-16 19:32:12 -07:00
2016-06-16 19:32:12 -07:00
2016-06-17 19:43:26 -07:00
2016-06-17 19:43:26 -07:00

Note: currently running at: http://gateway.iron.computer:8080/

MicroServices Gateway / API Gateway

First things first, create an app/service:

TOOD: App or service??

iron create app
# OR
curl -H "Content-Type: application/json" -X POST -d '{"name":"myapp"}' http://localhost:8080/api/v1/apps

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:0.0.1
# OR
curl -H "Content-Type: application/json" -X POST -d '{"path":"/hello", "image":"iron/hello", "type":"run"}' http://localhost:8080/api/v1/apps/myapp/routes

And how about a slackbot endpoint:

curl -H "Content-Type: application/json" -X POST -d '{"path":"/guppy","image":"treeder/guppy:0.0.2"}' http://localhost:8080/api/v1/apps/myapp/routes

Test out the route:

Surf to: http://localhost:8080/hello?app=myapp

Now try mapping an app endpoint:

curl -H "Content-Type: application/json" -X POST -d '{"path":"/sinatra","image":"treeder/hello-sinatra", "type":"app", "cpath":"/"}' http://localhost:8080/api/v1/apps/myapp/routes

And test it out:

curl -i -X GET http://localhost:8080/sinatra?app=myapp

And another:

curl -H "Content-Type: application/json" -X POST -d '{"path":"/sinatra/ping","image":"treeder/hello-sinatra", "type":"app", "cpath":"/ping"}' http://localhost:8080/api/v1/apps/myapp/routes

And test it out:

curl -i -X GET http://localhost:8080/sinatra?app=myapp

You'all also get a custom URL like this when in production.

appname.iron.computer

Building/Testing

Build:

# one time:
glide install
# then every time
./build.sh

Test it, the iron token and project id are for cache.

docker run -e "IRON_TOKEN=GP8cqlKSrcpmqeR8x9WKD4qSAss" -e "IRON_PROJECT_ID=4fd2729368a0197d1102056b" -e "CLOUDFLARE_EMAIL=treeder@gmail.com" -e "CLOUDFLARE_API_KEY=X" --rm -it --privileged -p 8080:8080 iron/gateway

Push it:

docker push iron/gateway

Get it on a server and point router.iron.computer (on cloudflare) to the machine.

After deploying, running it with:

docker run -e "IRON_TOKEN=GP8cqlKSrcpmqeR8x9WKD4qSAss" -e "IRON_PROJECT_ID=4fd2729368a0197d1102056b" --name irongateway -it --privileged --net=host -p 8080:8080 -d --name irongateway iron/gateway

TODOS

  • Check if image exists when registering the endpoint, not at run time
  • Put stats into influxdb or something to show to user (requests, errors)
  • Store recent logs for user.
  • Allow env vars for config on the app and routes (routes override apps).
  • Provide a base url for each app, eg: appname.userid.iron.computer
  • Allow setting content-type on a route, then use that when responding
Description
The container native, cloud agnostic serverless platform.
Readme Apache-2.0 170 MiB
Languages
Go 97.4%
Shell 1.2%
Ruby 0.5%
Makefile 0.4%
Dockerfile 0.4%
Other 0.1%