mirror of
https://github.com/fnproject/fn.git
synced 2022-10-28 21:29:17 +03:00
Docs update with new fnctl commands (#273)
* Added high level roadmap. * Changed to funtion.yaml. * Added logo * updating quickstart code example, WIP, waiting on another merge. * Minor updates. * Changed function.yaml to func.yaml and updated fnctl README.
This commit is contained in:
9
examples/README.md
Normal file
9
examples/README.md
Normal file
@@ -0,0 +1,9 @@
|
||||
# Example Functions
|
||||
|
||||
This directory has a collection of example functions you can look at to learn more about how to write them
|
||||
or just copy one and build on it to get started faster.
|
||||
|
||||
## Hello World Examples
|
||||
|
||||
The [Hello World examples](hello/) are the most basic functions you can write and we'll try to have an example in most major languages.
|
||||
This is a good place to start and good examples to copy and build upon.
|
||||
2
examples/hello/go/.gitignore
vendored
2
examples/hello/go/.gitignore
vendored
@@ -4,4 +4,4 @@ vendor/
|
||||
/app
|
||||
/__uberscript__
|
||||
|
||||
function.yaml
|
||||
func.yaml
|
||||
|
||||
@@ -3,22 +3,20 @@
|
||||
This example will show you how to test and deploy Go (Golang) code to IronFunctions.
|
||||
|
||||
```sh
|
||||
# create your func.yaml file
|
||||
fnctl init <YOUR_DOCKERHUB_USERNAME>/hello
|
||||
# build the function
|
||||
fnctl build
|
||||
# test it
|
||||
cat hello.payload.json | fnctl run
|
||||
# push it to Docker Hub
|
||||
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
|
||||
```
|
||||
|
||||
Now you use your function on IronFunctions:
|
||||
Now you can call your function on IronFunctions:
|
||||
|
||||
```sh
|
||||
curl -H "Content-Type: application/json" -X POST -d @hello.payload.json http://localhost:8080/r/myapp/hello
|
||||
```
|
||||
|
||||
Or surf to it: http://localhost:8080/r/myapp/hello
|
||||
|
||||
4
examples/hello/go/function.yaml
Normal file
4
examples/hello/go/function.yaml
Normal file
@@ -0,0 +1,4 @@
|
||||
name: treeder/hello4
|
||||
version: 0.0.1
|
||||
runtime: go
|
||||
entrypoint: ./func
|
||||
@@ -13,5 +13,5 @@ type Person struct {
|
||||
func main() {
|
||||
p := &Person{Name: "World"}
|
||||
json.NewDecoder(os.Stdin).Decode(p)
|
||||
fmt.Println("Hello", p.Name, "!!!")
|
||||
fmt.Printf("Hello %v!", p.Name)
|
||||
}
|
||||
|
||||
2
examples/hello/node/.gitignore
vendored
2
examples/hello/node/.gitignore
vendored
@@ -1,3 +1,3 @@
|
||||
node_modules/
|
||||
function.yaml
|
||||
func.yaml
|
||||
Dockerfile
|
||||
|
||||
@@ -3,15 +3,15 @@
|
||||
This example will show you how to test and deploy a Node function to IronFunctions.
|
||||
|
||||
```sh
|
||||
# create your func.yaml file
|
||||
fnctl init <YOUR_DOCKERHUB_USERNAME>/hello
|
||||
# build the function
|
||||
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
|
||||
```
|
||||
|
||||
|
||||
4
examples/hello/node/function.yaml
Normal file
4
examples/hello/node/function.yaml
Normal file
@@ -0,0 +1,4 @@
|
||||
name: treeder/node4
|
||||
version: 0.0.2
|
||||
runtime: node
|
||||
entrypoint: node hello.js
|
||||
@@ -2,13 +2,14 @@
|
||||
|
||||
This example will show you how to test and deploy Go (Golang) code to IronFunctions.
|
||||
|
||||
### 1. Prepare the `functions.yaml` file:
|
||||
### 1. Prepare the `func.yaml` file:
|
||||
|
||||
At functions.yaml you will find:
|
||||
At func.yaml you will find:
|
||||
```yml
|
||||
app: phpapp
|
||||
route: /hello
|
||||
image: USERNAME/hello:0.0.1
|
||||
image: USERNAME/hello
|
||||
version: 0.0.1
|
||||
build:
|
||||
- docker run --rm -v "$PWD":/worker -w /worker iron/php:dev composer install
|
||||
```
|
||||
|
||||
@@ -2,13 +2,15 @@
|
||||
|
||||
This example will show you how to test and deploy Go (Golang) code to IronFunctions.
|
||||
|
||||
### 1. Prepare the `functions.yaml` file:
|
||||
### 1. Prepare the `func.yaml` file:
|
||||
|
||||
At func.yaml you will find:
|
||||
|
||||
At functions.yaml you will find:
|
||||
```yml
|
||||
app: pythonapp
|
||||
route: /hello
|
||||
image: USERNAME/hello:0.0.1
|
||||
image: USERNAME/hello
|
||||
version: 0.0.1
|
||||
build:
|
||||
- docker run --rm -v "$PWD":/worker -w /worker iron/python:2-dev pip install -t packages -r requirements.txt
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user