mirror of
https://github.com/fnproject/fn.git
synced 2022-10-28 21:29:17 +03:00
Cleaned up main readme a bit (#693)
* Cleaned up main readme a bit * Update README.md
This commit is contained in:
64
README.md
64
README.md
@@ -42,7 +42,7 @@ If you're on a Mac and use [Homebrew](https://brew.sh/), this one is for you:
|
|||||||
brew install fn
|
brew install fn
|
||||||
```
|
```
|
||||||
|
|
||||||
#### 2. Shell script
|
#### 2. Shell script - Linux and MacOS
|
||||||
|
|
||||||
This one works on Linux and MacOS (partially on Windows):
|
This one works on Linux and MacOS (partially on Windows):
|
||||||
|
|
||||||
@@ -52,7 +52,7 @@ curl -LSs https://raw.githubusercontent.com/fnproject/cli/master/install | sh
|
|||||||
|
|
||||||
This will download a shell script and execute it. If the script asks for a password, that is because it invokes sudo.
|
This will download a shell script and execute it. If the script asks for a password, that is because it invokes sudo.
|
||||||
|
|
||||||
#### 3. Download the bin
|
#### 3. Download the bin - Linux, MacOS and Windows
|
||||||
|
|
||||||
Head over to our [releases](https://github.com/fnproject/cli/releases) and download it.
|
Head over to our [releases](https://github.com/fnproject/cli/releases) and download it.
|
||||||
|
|
||||||
@@ -71,41 +71,31 @@ If you are on a Linux system where the SELinux security policy is set to "Enforc
|
|||||||
|
|
||||||
### Your First Function
|
### Your First Function
|
||||||
|
|
||||||
Functions are small but powerful blocks of code that generally do one simple thing. Forget about monoliths when using functions, just focus on the task that you want the function to perform.
|
Functions are small but powerful blocks of code that generally do one simple thing. Forget about monoliths when using functions, just focus on the task that you want the function to perform. Our CLI tool will help you get started super quickly.
|
||||||
|
|
||||||
First, create an empty directory called `hello` and cd into it.
|
Create hello world function:
|
||||||
|
|
||||||
The following is a simple Go program that outputs a string to STDOUT. Copy and paste the code below into a file called `func.go`.
|
|
||||||
|
|
||||||
```go
|
|
||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
)
|
|
||||||
|
|
||||||
func main() {
|
|
||||||
fmt.Println("Hello from Fn!")
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
Now run the following CLI commands:
|
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
# Initialize your function
|
fn init --runtime go hello
|
||||||
# This detects your runtime from the code above and creates a func.yaml
|
```
|
||||||
fn init
|
|
||||||
|
|
||||||
|
This will create a simple function in the directory `hello`, so let's cd into it:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
cd hello
|
||||||
|
```
|
||||||
|
|
||||||
|
Feel free to check out the files it created or just keep going and look at it later.
|
||||||
|
|
||||||
|
```sh
|
||||||
# Set your Docker Hub username
|
# Set your Docker Hub username
|
||||||
export FN_REGISTRY=<DOCKERHUB_USERNAME>
|
export FN_REGISTRY=<DOCKERHUB_USERNAME>
|
||||||
|
|
||||||
# Test your function
|
# Run your function locally
|
||||||
# This will run inside a container exactly how it will on the server
|
|
||||||
fn run
|
fn run
|
||||||
|
|
||||||
# Deploy your functions to the Fn server (default localhost:8080)
|
# Deploy your functions to your local Fn server
|
||||||
# This will create a route to your function as well
|
fn deploy --app myapp --local
|
||||||
fn deploy --app myapp
|
|
||||||
```
|
```
|
||||||
|
|
||||||
Now you can call your function:
|
Now you can call your function:
|
||||||
@@ -118,23 +108,13 @@ fn call myapp /hello
|
|||||||
|
|
||||||
Or in a browser: [http://localhost:8080/r/myapp/hello](http://localhost:8080/r/myapp/hello)
|
Or in a browser: [http://localhost:8080/r/myapp/hello](http://localhost:8080/r/myapp/hello)
|
||||||
|
|
||||||
That's it! You just deployed your first function and called it. To update your function you can update your code and run `fn deploy myapp` again.
|
That's it! You just deployed your first function and called it. Try updating the function code in `func.go` then deploy it again to see the change.
|
||||||
|
|
||||||
## User Interface
|
|
||||||
|
|
||||||
We also have an open source graphical user interface for Fn. It's very easy to use, simply run the command below:
|
|
||||||
|
|
||||||
```sh
|
|
||||||
docker run --rm -it --link fnserver:api -p 4000:4000 -e "FN_API_URL=http://api:8080" fnproject/ui
|
|
||||||
```
|
|
||||||
|
|
||||||
For more information, see: [https://github.com/fnproject/ui](https://github.com/fnproject/ui)
|
|
||||||
|
|
||||||
|
|
||||||
## Learn More
|
## Learn More
|
||||||
|
|
||||||
* With our [Fn Getting Started Series](examples/tutorial/), quickly create Fn Hello World applications in multiple languages. This is a great Fn place to start!
|
* With our [Fn Getting Started Series](examples/tutorial/), quickly create Fn Hello World applications in multiple languages. This is a great Fn place to start!
|
||||||
* Visit [Fn tutorials](https://github.com/fnproject/tutorials) for step by step guides to creating apps with Fn . These tutorials range from introductory to more advanced.
|
* Visit [Fn tutorials](https://github.com/fnproject/tutorials) for step by step guides to creating apps with Fn . These tutorials range from introductory to more advanced.
|
||||||
|
* [User interface](https://github.com/fnproject/ui)
|
||||||
* See our [full documentation](docs/README.md)
|
* See our [full documentation](docs/README.md)
|
||||||
* View all of our [examples](/examples)
|
* View all of our [examples](/examples)
|
||||||
* View our [YouTube Channel](https://www.youtube.com/channel/UCo3fJqEGRx9PW_ODXk3b1nw)
|
* View our [YouTube Channel](https://www.youtube.com/channel/UCo3fJqEGRx9PW_ODXk3b1nw)
|
||||||
@@ -150,7 +130,7 @@ For more information, see: [https://github.com/fnproject/ui](https://github.com/
|
|||||||
|
|
||||||
* Join our [Slack Community](http://slack.fnproject.io)
|
* Join our [Slack Community](http://slack.fnproject.io)
|
||||||
* Learn how to [contribute](CONTRIBUTING.md)
|
* Learn how to [contribute](CONTRIBUTING.md)
|
||||||
* See [milestones](https://github.com/fnproject/fn/milestones) for detailed issues
|
* See [issues](https://github.com/fnproject/fn/issues) for issues you can help with
|
||||||
|
|
||||||
## Stay Informed
|
## Stay Informed
|
||||||
|
|
||||||
|
|||||||
@@ -16,6 +16,8 @@ config:
|
|||||||
headers:
|
headers:
|
||||||
Content-Type:
|
Content-Type:
|
||||||
- text/html
|
- text/html
|
||||||
|
build_image: x/y
|
||||||
|
run_image: x/y
|
||||||
build:
|
build:
|
||||||
- make
|
- make
|
||||||
- make test
|
- make test
|
||||||
@@ -40,8 +42,6 @@ appended to the image as a tag.
|
|||||||
`runtime` represents programming language runtime, for example,
|
`runtime` represents programming language runtime, for example,
|
||||||
'go', 'python', 'java', etc. The runtime 'docker' will use the existing Dockerfile if one exists.
|
'go', 'python', 'java', etc. The runtime 'docker' will use the existing Dockerfile if one exists.
|
||||||
|
|
||||||
`build` (optional) is an array of local shell calls which are used to help
|
|
||||||
building the function. TODO: Deprecate this?
|
|
||||||
|
|
||||||
`type` (optional) allows you to set the type of the route. `sync`, for functions
|
`type` (optional) allows you to set the type of the route. `sync`, for functions
|
||||||
whose response are sent back to the requester; or `async`, for functions that
|
whose response are sent back to the requester; or `async`, for functions that
|
||||||
@@ -69,6 +69,13 @@ for more information.
|
|||||||
`expects` (optional) a list of config/env vars that are required to run this function. These vars will be used when running/testing locally,
|
`expects` (optional) a list of config/env vars that are required to run this function. These vars will be used when running/testing locally,
|
||||||
if found in your local environment. If these vars are not found, local testing will fail.
|
if found in your local environment. If these vars are not found, local testing will fail.
|
||||||
|
|
||||||
|
`build` (optional) is an array of local shell calls which are used to help
|
||||||
|
building the function. TODO: Deprecate this?
|
||||||
|
|
||||||
|
`build_image` (optional) base Docker image to use for building your function. Default images used are the `dev` tagged images from the [dockers repo](https://github.com/fnproject/dockers).
|
||||||
|
|
||||||
|
`run_image` (optional) base Docker image to use for running your function, part of a multi-stage build. Function will be built with `build_image` and run with `run_image`. Default images used from the [dockers repo](https://github.com/fnproject/dockers).
|
||||||
|
|
||||||
## Hot functions
|
## Hot functions
|
||||||
|
|
||||||
hot functions support also adds two extra options to this configuration file.
|
hot functions support also adds two extra options to this configuration file.
|
||||||
|
|||||||
@@ -63,17 +63,20 @@ And the second should return:
|
|||||||
|
|
||||||
## Run Tests
|
## Run Tests
|
||||||
|
|
||||||
This is simply running:
|
In your function directory, run:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
fn test
|
fn test
|
||||||
```
|
```
|
||||||
|
|
||||||
in your function directory.
|
|
||||||
|
|
||||||
You can also test against a remote `fn` server by using the `--remote` flag. eg:
|
You can also test against a remote `fn` server by using the `--remote` flag. eg:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
fn test --remote myapp
|
fn test --remote myapp
|
||||||
```
|
```
|
||||||
|
|
||||||
|
To test your entire Fn application:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
fn test --all
|
||||||
|
```
|
||||||
|
|||||||
Reference in New Issue
Block a user