mirror of
https://github.com/fnproject/fn.git
synced 2022-10-28 21:29:17 +03:00
Starting on some examples to use with function tool.
This commit is contained in:
15
README.md
15
README.md
@@ -13,37 +13,38 @@ docker run --env-file .env --rm -it --privileged -p 8080:8080 iron/functions
|
|||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
First things first, create an app/service:
|
First things first, create an app/service:
|
||||||
|
|
||||||
TOOD: App or service??
|
TOOD: App or service??
|
||||||
|
|
||||||
|
### Create App
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
iron create app APP_NAME
|
iron create app APP_NAME
|
||||||
# OR
|
# OR
|
||||||
curl -H "Content-Type: application/json" -X POST -d '{"name":"APP_NAME"}' http://localhost:8080/api/v1/apps
|
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:
|
Now add routes to the app. First we'll add a route to the output of a docker container:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
iron add route myapp /hello iron/hello
|
iron add route myapp /hello iron/hello
|
||||||
# OR
|
# 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:
|
And how about a [slackbot](https://github.com/treeder/slackbots/tree/master/guppy) endpoint:
|
||||||
|
|
||||||
```sh
|
```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
|
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.
|
You'all also get a custom URL like this when in production.
|
||||||
|
|
||||||
```
|
```
|
||||||
myapp.ironfunctions.com/myroute
|
APP_NAME.ironfunctions.com/PATH
|
||||||
```
|
```
|
||||||
|
|
||||||
## Updating Your Images
|
## Updating Your Images
|
||||||
|
|||||||
@@ -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
|
|
||||||
13
tool/README.md
Normal file
13
tool/README.md
Normal file
@@ -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.
|
||||||
|
|
||||||
1
tool/examples/hello/.gitignore
vendored
Normal file
1
tool/examples/hello/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
/hello
|
||||||
7
tool/examples/hello/Dockerfile
Normal file
7
tool/examples/hello/Dockerfile
Normal file
@@ -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"]
|
||||||
1
tool/examples/hello/VERSION
Normal file
1
tool/examples/hello/VERSION
Normal file
@@ -0,0 +1 @@
|
|||||||
|
0.0.1
|
||||||
10
tool/examples/hello/hello.go
Normal file
10
tool/examples/hello/hello.go
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
)
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
fmt.Printf("Hello %v!\n", os.Getenv("PAYLOAD"))
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user