Skip to content

Commit 55f814c

Browse files
committed
Restrict deployment to Nimbella functions.
Update docs. Add back env export. Update plugin manifest.
1 parent 25b4275 commit 55f814c

File tree

4 files changed

+146
-302
lines changed

4 files changed

+146
-302
lines changed

README.md

Lines changed: 22 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ The Nimbella add-on provides the following benefits.
1212

1313
1. **More runtimes:** implement functions in numerous languages including Python, Rust, Swift, Ruby, PHP, Java, Go, Node, and Deno.
1414
2. **Resource customization:** run functions for longer durations, and with more memory.
15-
3. **Support for key-value and object stores:** build stateful APIs, and handle images or files.
15+
3. **Support for key-value and object stores:** build stateful APIs, and handle images or files with no additional resources to provision.
1616
4. **Easier packaging:** skip the hassles of web packing and working with dependencies.
1717
5. **Cloud portability**: repeatable deployments that work across clouds.
1818

@@ -24,7 +24,6 @@ Learn more about the Nimbella add-on for Netlify [on our website](https://nimbel
2424
- [Minimal Netlify TOML Configuration](#minimal-netlify-toml-configuration)
2525
- [Usage](#usage)
2626
- [Use Nimbella Projects with Netlify Sites](#use-nimbella-projects-with-netlify-sites)
27-
- [Deploy Netlify Functions on Nimbella Cloud](#deploy-netlify-functions-on-nimbella-cloud)
2827
- [Examples](#examples)
2928
- [Support](#support)
3029
- [License](#license)
@@ -42,7 +41,7 @@ To do that, run the following command from the base of your local project direct
4241
netlify addons:create nimbella
4342
```
4443

45-
The add-on will create a Nimbella namespace where your resources are allocated. Your Nimbella namespace includes your serverless functions, a dedicated key-value store, and access to an integrated object store.
44+
The add-on will create a Nimbella namespace where your resources are allocated. Your Nimbella namespace includes your serverless APIs, a dedicated key-value store, and access to an integrated object store.
4645

4746
<!--TODO: add steps to claim the namespace and configure `nim` CLI when the flow is enabled. -->
4847
<!--You may claim the namespace and login to your Nimbella account by running `netlify addons:auth nimbella`.-->
@@ -68,29 +67,22 @@ Once your add-on is configured, you need to add the Nimbella Build Plugin to You
6867
package = "netlify-plugin-nimbella"
6968
```
7069

71-
You may provide additional configuration in the `netlify.toml` file to configure the resources available to your serverless functions, or to configure the API path for your functions. Here is an example.
70+
You may provide additional configuration in the `netlify.toml` file. The plugin input configuration is optional, however you will want to at least set the API `path` to avoid CORS issues between your frontend and backend components of your cloud application.
7271

7372
```toml
7473
[[plugins]]
7574
package = "netlify-plugin-nimbella"
75+
7676
[plugins.inputs]
77-
functions = "functions" # Functions source directory. Use this if you would like to use Nimbella to deploy your functions.
78-
memory = 256 # Function memory limit in MB.
79-
path = "/api/" # The prefix path to access your deployed packages.
80-
timeout = 6000 # Function timeout limit in milliseconds.
77+
path = "/api" # The prefix path to access your deployed packages.
78+
env = [] # Environment variables to export to serverless APIs.
8179
```
8280

83-
## Usage
84-
85-
In this section, you will learn how to structure your repository and `netlify.toml` for this plugin to deploy your functions on Nimbella Cloud.
86-
87-
**Note:** Deployment of packages/functions to Nimbella is skipped when the build context is not "production". We're working on an enhancement that will allow you to deploy preview builds to staging namespaces on Nimbella.
88-
89-
#### Use Nimbella Projects with Netlify Sites
81+
## Understanding your Nimbella Project
9082

9183
The Nimbella add-on for Netlify allows you to use [Nimbella projects](https://nimbella.io/downloads/nim/nim.html#overview-of-nimbella-projects-actions-and-deployment) to automate packaging and deployment. We suggest reading the documentation about [Nimbella projects](https://nimbella.io/downloads/nim/nim.html#overview-of-nimbella-projects-actions-and-deployment) at some point. We provide a quick introduction here.
9284

93-
Nimbella projects inspect a directory named `packages` at the base of your repository. The contents of this directory dictate the serverless functions that are deployed. The plugin will automatically deploy the functions inside `packages` and all of the functions (also called actions) can accessed using the following pattern: `https://your-site.com/<path(default="api")>/<packageName>/<actionName>`.
85+
Nimbella projects inspect a directory named `packages` at the base of your repository. The contents of this directory dictate the serverless APIs that are deployed. The plugin will automatically deploy each API inside the `packages` directory. We use the term `action` to be synonymous with serverless API (or serverless function). Each API can accessed using the following pattern: `https://your-site.com/<path(default="api")>/<packageName>/<actionName>`.
9486

9587
For example, for the following project structure:
9688

@@ -99,47 +91,31 @@ site
9991
├── netlify.toml
10092
├── packages
10193
│ ├── auth
102-
│ │ ├── login.js
94+
│ │ ├── login
95+
│ │ │ └── index.js
10396
│ │ └── logout.js
10497
│ └── todos
105-
│ ├── create.js
106-
│ ├── delete.js
107-
│ ├── list.js
108-
│ └── update.js
109-
└── public
98+
│ ├── create.py
99+
│ ├── delete.php
100+
│ ├── list.go
101+
│ └── update.swift
102+
└── web
110103
└── index.html
111104
```
112105

113-
You will invoke the function `auth/login.js` via the API end point `https://your-site.com/api/auth/login`.
106+
The APIs are `auth/login`, `auth/logout`, `todos/create`, and so on. An API may be a single file, or built from a set of files within an enclosing directory. You may mix languages, and deploy functions as source, without even building languages that require compilation. To API end point for any of the actions is constructed in the same way. For example the serverless API implemented by `auth/login/index.js` is invoked with the REST end point `https://your-site.com/api/auth/login`.
114107

115-
#### Deploy Netlify Functions on Nimbella Cloud
108+
## Exporting Environment Variables to Serverless APIs
116109

117-
You can deploy your existing Netlify Functions to Nimbella Cloud with very minimal changes.
118-
119-
Specify the `functions` input value under `[plugins.inputs]` inside `netlify.toml`.
120-
121-
```diff
122-
[[plugins]]
123-
package = "netlify-plugin-nimbella"
124-
+ [plugins.inputs]
125-
+ functions = "functions" # Functions source directory. Use this if you would like to use Nimbella to deploy your functions.
126-
```
127-
128-
To be able to pass **environment variables** to functions, you should first set them as Netlify build environment variables and use the below plugin input to selectively forward the variables to functions deployed on Nimbella.
110+
If your serverless APIs require environment variables, you have to export the variables explicitly in the `plugins.input` section of the `netlify.toml` file. This is to avoid exporting the entire environment to your APIs, and instead selecting exporting only the variables the actions need access to.
129111

130112
```toml
131113
[plugins.inputs]
132-
envs = ['ENV_ONE', 'ENV_TWO']
114+
# Export specified environment variables to the serverless APIs
115+
env = ['ENV_ONE', 'ENV_TWO']
133116
```
134117

135-
This plugin builds your functions using a modified version of [netlify-lambda](https://github.com/netlify/netlify-lambda). You can get rid of any build steps you're performing on functions since the plugin handles it for you.
136-
137-
**Notes:**
138-
139-
- Replace occurrences of `/.netlify/functions` in your API calls with `/.netlify/nimbella`, or use `/api`, as your API path instead.
140-
- All Netlify functions are deployed to a "default" package in your Nimbella namespace. The package name is required in the API path. For Netlify functions, the path will be `/.netlify/nimbella/default/` or `/api/default`. For named packages, replace `default` with your package name instead.
141-
142-
## Examples
118+
## Example Projects
143119

144120
These are few sites that use `netlify-plugin-nimbella` to deploy frontend content to Netlify and functions on Nimbella.
145121

@@ -150,7 +126,7 @@ Look at `netlify.toml` of these repositories to get an idea on how the plugin is
150126

151127
## Support
152128

153-
We're always happy to help you with any issues you encounter. You may want to [join our Slack community](https://nimbella-community.slack.com) to engage with us for a more rapid response. Otherwise, open an issue and provide us with details about your situation so we can respond adequately.
129+
We welcome your feedback, and we are happy to help you with any issues you encounter. You may want to [join our Slack community](https://nimbella-community.slack.com) to engage with us for a more rapid response. Otherwise, open an issue and provide us with details about your situation so we can respond adequately.
154130

155131
## License
156132

manifest.yml

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,13 @@
11
name: netlify-plugin-nimbella
22
inputs:
3-
- name: functions
4-
description: The source directory of the functions.
5-
- name: timeout
6-
description: Timeout LIMIT in milliseconds after which the function is terminated (functions input value is required to utilize this option).
7-
default: 6000
8-
- name: memory
9-
description: Maximum memory LIMIT in MB for the function (functions input value is required to utilize this option).
10-
default: 256
11-
- name: envs
12-
description: Specify the names of the environment variables that need to be forwarded from Netlify CI to Nimbella Functions (functions input value is required to utilize this option).
13-
default: []
143
- name: path
15-
description: The API prefix path you would like to use to access your functions.
16-
default: '/api/'
4+
description: The API prefix path for your serverless APIs for single origin.
5+
default: '/api'
6+
7+
- name: web
8+
description: Deploy entire project include web frontend. Proxy domain to Nimbella.
9+
default: false
10+
11+
- name: env
12+
description: Environment variables to forward from Netlify CI to Nimbella Projects.
13+
default: []

0 commit comments

Comments
 (0)