Skip to content

Commit

Permalink
feat: add node example page
Browse files Browse the repository at this point in the history
Signed-off-by: iverly <github@iverly.net>
  • Loading branch information
iverly committed Oct 30, 2023
1 parent 03d41fd commit 25123e0
Show file tree
Hide file tree
Showing 2 changed files with 79 additions and 1 deletion.
3 changes: 2 additions & 1 deletion pages/docs/getting-started/_meta.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"installation": "Installation"
"installation": "Installation",
"example-node": "Example: Node"
}
77 changes: 77 additions & 0 deletions pages/docs/getting-started/example-node.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
import { Steps } from 'nextra/components';

# Example: Node

This example demonstrates how to deploy a simple Node.js executor on Faast using
Docker Compose. We have provided an example folder on GitHub, containing the
necessary initramfs and configuration file to work seamlessly with Docker
Compose.

## A few explanations

In the interest of simplifying the initial setup and demonstration, we have
pre-compiled the necessary components and included them in the example folder
available on GitHub.

- The provided initramfs has been built with essential elements already
incorporated. It includes an agent responsible for facilitating the
communication between the VM and the API via GRPC. Additionally, it comprises
the Node.js SDK, enabling the immediate deployment and execution of Node.js
functions.

- A configuration file for the Lambdo component is also provided, pre-set with
the parameters needed for interfacing with the API. This pre-configuration
accelerates the setup process, allowing you to dive directly into deploying
and testing your functions.

This pre-configured setup is designed to lower the entry barrier, offering a
straightforward way to explore Faast's functionality, especially for those new
to the system or eager to quickly test a Node.js function deployment.

## Let's run it

### Clone the lambdo repository

You can clone the `lambdo` repository from GitHub using the following command:

```bash copy filename="bash"
git clone https://github.com/faast-rt/lambdo
cd lambdo
```

### Start lambdo using Docker Compose

You can start lambdo using Docker Compose using the following command:

```bash copy filename="bash"
docker-compose up
```

### Execute your Node.js code

Lambdo will now expose an HTTP endpoint on port 3000. You can send a POST
request to `/run` in order to execute your Node.js code.

The following example uses `curl`:

```bash copy filename="bash"
curl --location 'http://127.0.0.1:3000/run' \
--header 'Content-Type: application/json' \
--data '{
"language": "NODE",
"version": "1.0.0",
"input": "",
"code": [{
"filename": "main.js",
"content": "console.log('\''Hello World!'\'')"
}]
}'
```

You should see the following output:

```bash filename="bash"
{"status":0,"stdout":"Hello World\n","stderr":""}
```

You are now ready to execute your own Node.js code on Faast!

0 comments on commit 25123e0

Please sign in to comment.