diff --git a/README.md b/README.md index 8c54cd237..2f3662ebf 100644 --- a/README.md +++ b/README.md @@ -13,37 +13,38 @@ 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 + ```sh 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 + Now add routes to the app. First we'll add a route to the output of a docker container: ```sh iron add route myapp /hello iron/hello # 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 +curl -H "Content-Type: application/json" -X POST -d '{"path":"/hello", "image":"iron/hello"}' http://localhost:8080/api/v1/apps/myapp/routes ``` +Surf to your function: http://localhost:8080/hello?app=APP_NAME . Boom! + And how about a [slackbot](https://github.com/treeder/slackbots/tree/master/guppy) endpoint: ```sh 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 ``` -Test out the route: - -Surf to: http://localhost:8080/hello?app=myapp - You'all also get a custom URL like this when in production. ``` -myapp.ironfunctions.com/myroute +APP_NAME.ironfunctions.com/PATH ``` ## Updating Your Images diff --git a/curlcmds.txt b/curlcmds.txt deleted file mode 100644 index 010eec936..000000000 --- a/curlcmds.txt +++ /dev/null @@ -1,8 +0,0 @@ -make app: -curl -H "Content-Type: application/json" -X POST -d '{"name":"myapp","password":"xyz"}' http://localhost:8080/test/1/projects/123/apps - -register route: -curl -H "Content-Type: application/json" -X POST -d '{"path":"/hello.rb","image":"treeder/hello.rb", "type":"run"}' http://localhost:8080/test/1/projects/123/apps/myapp/routes - -get route: -curl -i -X GET http://localhost:8080/hello.rb?app=myapp diff --git a/tool/README.md b/tool/README.md new file mode 100644 index 000000000..d1805b5bd --- /dev/null +++ b/tool/README.md @@ -0,0 +1,13 @@ + +# Function Tool + +The function tool is a tool to help you build and deploy functions to IronFunctions. + +In your projects root folder, run: + +```sh +iron build +``` + +This will iterate through your directories building any changed functions, bumping their version numbers and pushing them to Docker Hub. + diff --git a/tool/examples/hello/.gitignore b/tool/examples/hello/.gitignore new file mode 100644 index 000000000..e92569d01 --- /dev/null +++ b/tool/examples/hello/.gitignore @@ -0,0 +1 @@ +/hello diff --git a/tool/examples/hello/Dockerfile b/tool/examples/hello/Dockerfile new file mode 100644 index 000000000..ee192de5a --- /dev/null +++ b/tool/examples/hello/Dockerfile @@ -0,0 +1,7 @@ +FROM iron/go:dev + +ADD . /go/src/github.com/treeder/hello +WORKDIR /go/src/github.com/treeder/hello +RUN go build github.com/treeder/hello + +ENTRYPOINT ["/go/src/github.com/treeder/hello/hello"] diff --git a/tool/examples/hello/VERSION b/tool/examples/hello/VERSION new file mode 100644 index 000000000..8acdd82b7 --- /dev/null +++ b/tool/examples/hello/VERSION @@ -0,0 +1 @@ +0.0.1 diff --git a/tool/examples/hello/hello.go b/tool/examples/hello/hello.go new file mode 100644 index 000000000..88bfe9d97 --- /dev/null +++ b/tool/examples/hello/hello.go @@ -0,0 +1,10 @@ +package main + +import ( + "fmt" + "os" +) + +func main() { + fmt.Printf("Hello %v!\n", os.Getenv("PAYLOAD")) +}