Updates to fnctl to make UX better (#272)

* See the hello/go README for how this all works now.

* Node support for fnctl auto build

* Updated based on PR comments.
This commit is contained in:
Travis Reeder
2016-11-14 10:10:29 -08:00
committed by GitHub
parent 28d57e50a4
commit 3357476583
24 changed files with 402 additions and 185 deletions

View File

@@ -1 +1,3 @@
node_modules/
function.yaml
Dockerfile

View File

@@ -1,6 +0,0 @@
FROM iron/node
WORKDIR /app
ADD . /app
ENTRYPOINT ["node", "hello.js"]

View File

@@ -1,40 +1,18 @@
## Quick Example for a NodeJS Function (4 minutes)
This example will show you how to test and deploy Go (Golang) code to IronFunctions.
### 1. Prepare the `functions.yaml` file:
At functions.yaml you will find:
```yml
app: nodeapp
route: /hello
image: USERNAME/hello:0.0.1
build:
- docker run --rm -v "$PWD":/worker -w /worker iron/node:dev npm install
```
The important step here is to ensure you replace `USERNAME` with your Docker Hub account name. Some points of note:
the application name is `nodeapp` and the route for incoming requests is `/hello`. These informations are relevant for
the moment you try to test this function.
### 2. Build:
This example will show you how to test and deploy a Node function to IronFunctions.
```sh
fnctl publish
fnctl init <YOUR_DOCKERHUB_USERNAME>/hello
fnctl build
# test it
cat hello.payload.json | fnctl run
# push it to Docker Hub for use with IronFunctions
fnctl push
# Create a route to this function on IronFunctions
fnctl routes create myapp /hello YOUR_DOCKERHUB_USERNAME/hello:0.0.X
# todo: Image name could be optional if we read the function file for creating the route. Then command could be:
fnctl routes create myapp /hello
```
`-v` is optional, but it allows you to see how this function is being built.
### 3. Queue jobs for your function
Now you can start jobs on your function. Let's quickly queue up a job to try it out.
```sh
cat hello.payload.json | fnctl run nodeapp /hello
```
Here's a curl example to show how easy it is to do in any language:
```sh
curl -H "Content-Type: application/json" -X POST -d @hello.payload.json http://localhost:8080/r/nodeapp/hello
```
Now surf to: http://localhost:8080/r/myapp/hello

View File

@@ -1,5 +0,0 @@
app: nodeapp
route: /hello
image: USERNAME/hello:0.0.1
build:
- docker run --rm -v "$PWD":/worker -w /worker iron/node:dev npm install

View File

@@ -6,4 +6,4 @@ try {
name = obj.name
}
} catch(e) {}
console.log("Hello", name, "from Node!");
console.log("Hello", name, "from Node!");