-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: enviroment variables updates #100
base: main
Are you sure you want to change the base?
Changes from all commits
a4543b4
5dfe8e1
2cb037f
69488f6
f64f7a4
4df81d0
931cc55
2e8a660
dcf4d98
da0f37b
9754846
ae45a83
31b6591
9209592
3bb9b16
9149230
c971558
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -63,26 +63,57 @@ It is always necessary to redeploy your application when updating or creating en | |
|
||
## Setting secret variables | ||
|
||
Use secret variables to store passwords, tokens and other sensitive information that shouldn't be part of your repository and listed in zerops.yml. | ||
There are several ways to set secret variables to your project/services using Zerops GUI: | ||
|
||
### With Import Dialog | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As said above, it's not just the dialog, but also with a zcli command, so the title could be something more general. You can add a mention about the zcli to the sentence below. |
||
|
||
When importing services/project using yaml config via Zerops dashboard, you can assign secret variables to your services in your yaml using the `envSecrets` parameter: | ||
|
||
```yaml | ||
services: | ||
- hostname: app | ||
type: nodejs@latest | ||
envSecrets: | ||
SECRET_KEY: <@generateRandomString(<32>)> | ||
S3_ACCESS_KEY_ID: 'P8cX1vVVb' | ||
S3_ACCESS_SECRET: 'ogFthuiLYki8XoL73opSCQ' | ||
``` | ||
|
||
### From Project > Services > Secrets | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would rather say e.g. "In the service detail", it is used throughout the docs. |
||
|
||
You can assign secret variables to your services from the **Project > Service > Environment variables** page. | ||
Use secret variables to store tokens and other sensitive information that shouldn't be public and assigned in `zerops.yml`. | ||
|
||
<p align="center"> | ||
<Image | ||
lightImage="/img/screenshots/runtime_secret_variables.png" | ||
darkImage="/img/screenshots/runtime_secret_variables.png" | ||
alt="Runtime Secret Variables" | ||
lightImage="/img/gui/secrets.webp" | ||
darkImage="/img/gui/secrets.webp" | ||
alt="Secret Variables" | ||
/> | ||
</p> | ||
|
||
To configure environment variables for an existing service, go to the service detail and find **Environment variables** in the left menu. Click on the **Add secret variable** button and set values for `Key` and `Value`. | ||
You can add or manage secret variables in your service in two ways: | ||
|
||
To edit an environment variable, click on the menu <svg xmlns="http://www.w3.org/2000/svg" style={{ marginBottom: -5 + 'px' }} height="24px" viewBox="0 -960 960 960" width="24px" fill="#e8eaed"><path d="M480-160q-33 0-56.5-23.5T400-240q0-33 23.5-56.5T480-320q33 0 56.5 23.5T560-240q0 33-23.5 56.5T480-160Zm0-240q-33 0-56.5-23.5T400-480q0-33 23.5-56.5T480-560q33 0 56.5 23.5T560-480q0 33-23.5 56.5T480-400Zm0-240q-33 0-56.5-23.5T400-720q0-33 23.5-56.5T480-800q33 0 56.5 23.5T560-720q0 33-23.5 56.5T480-640Z"/></svg> on the right side of its row. | ||
1. To add a single individual variable, click the `Add secret variable` button and set values for `Key` and `Value`. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. according to discord please update titles and buttons/sections references in this file |
||
2. Click `Edit multiple secret variables in .env format` to manage/add multiple variables at once using the editor. | ||
|
||
After making changes, click the **Commit x changes** button to apply your updates. Zerops will automatically propagate these changes to the environment variables across all containers in your project's services. | ||
After you make the changes, Zerops will automatically propagate/commit these changes to the environment variables in your service. | ||
|
||
:::note | ||
It is necessary to restart the service whenever you commit changes in environment variables. | ||
::: | ||
|
||
### Individual editing | ||
<p align="center"> | ||
<Image | ||
lightImage="/img/gui/env-editing.png" | ||
darkImage="/img/gui/env-editing.png" | ||
alt="Secret Variables" | ||
/> | ||
</p> | ||
|
||
To edit an existing variable, click on <svg xmlns="http://www.w3.org/2000/svg" style={{ marginBottom: -5 + 'px' }} height="24px" viewBox="0 -960 960 960" width="24px" className="fill-[#212121] dark:fill-[#e8eaed]"><path d="M480-160q-33 0-56.5-23.5T400-240q0-33 23.5-56.5T480-320q33 0 56.5 23.5T560-240q0 33-23.5 56.5T480-160Zm0-240q-33 0-56.5-23.5T400-480q0-33 23.5-56.5T480-560q33 0 56.5 23.5T560-480q0 33-23.5 56.5T480-400Zm0-240q-33 0-56.5-23.5T400-720q0-33 23.5-56.5T480-800q33 0 56.5 23.5T560-720q0 33-23.5 56.5T480-640Z"/></svg> to open the edit dialog and save your preferred changes. | ||
|
||
## Restrictions | ||
|
||
### Key | ||
|
@@ -91,11 +122,15 @@ It is necessary to restart the service whenever you commit changes in environmen | |
- Keys in the same service must be unique | ||
- Keys are case-sensitive | ||
|
||
eg. `DATABASE_URL`, `NODE_ENV`, etc | ||
|
||
### Value | ||
|
||
- Must contain only ASCII characters | ||
- Any EOL character is forbidden | ||
|
||
eg. `postgresql://username:password@host:port/database`, `3000`, etc | ||
|
||
These restrictions apply to all [types of environment variables](#types-of-environment-variables). | ||
|
||
## Referencing other environment variables | ||
|
@@ -151,7 +186,9 @@ run: | |
|
||
## Generated environment variables | ||
|
||
Zerops automatically generates several variables when a runtime service is created, such as `hostname` and `PATH`. Some of these variables (like `hostname`) are read-only, while others (like `PATH`) can be edited. These variables cannot be deleted and are always listed at the bottom of the **Environment Variables** page. | ||
Zerops automatically generates several variables when a runtime service is created, such as `hostname` and `PATH`. Some of these variables (like `hostname`) are read-only, while others (like `PATH`) can be edited. | ||
|
||
These variables cannot be deleted and are always listed at the bottom of the **Environment Variables** page. | ||
|
||
<GroupCards emoji="🙌" heading="Quick Links to Runtime-Specific Guides" items={languages} /> | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -48,6 +48,11 @@ You can [reference](/nodejs/how-to/env-variables#reference-a-local-variable-in-a | |
|
||
Use secret variables to store passwords, tokens and other sensitive information that shouldn't be part of your repository and listed in zerops.yml. | ||
|
||
You can manage secret variables in two ways: | ||
|
||
1. **Individual editing**: Add or edit variables one by one | ||
2. **Bulk editing**: Manage multiple variables at once using .env format | ||
|
||
<p align="center"> | ||
<img | ||
src="/img/screenshots/runtime_secret_variables.png" | ||
|
@@ -57,17 +62,24 @@ Use secret variables to store passwords, tokens and other sensitive information | |
/> | ||
</p> | ||
|
||
You can set env variables when you [create](/nodejs/how-to/create) a new Node.js service or you can set them later. | ||
### Individual editing | ||
|
||
To configure env variables for an existing service, go to the service detail and choose **Environment variables** in the left menu. Scroll to the **Secret variables** section and click on the **Add secret variable** button and set variable key and value. | ||
To configure individual variables, go to the service detail and choose **Environment variables** in the left menu. Click the **Add secret variable** button and set variable key and value. | ||
|
||
You can edit or delete env variables that you've created by clicking on the menu on the right side of each row. | ||
You can edit or delete variables by clicking on the menu on the right side of each row. | ||
|
||
The changes you've made in the list of env variables need to be committed. Click on the **Commit x changes** button and Zerops will update the env variables in all containers of your project's services. | ||
### Bulk editing | ||
|
||
:::caution | ||
You need to **restart** the runtime service after you commit the changes in env variables. The Node.js process running in the container receives the list env variables only when it starts. Update of the env variables while the Node.js process is running does not affect your application. | ||
::: | ||
Click "Edit multiple secret variables in .env format" to open an editor where you can manage multiple variables at once using standard .env file format: | ||
|
||
```env | ||
# Add or update variables | ||
DB_USER=admin | ||
API_KEY=abc123 | ||
DEBUG_MODE=true | ||
|
||
# Delete variables by removing their lines | ||
``` | ||
|
||
## Set basic build env variables in zerops.yml | ||
|
||
|
@@ -195,3 +207,24 @@ You can use runtime env variables in the build environment using the `RUNTIME_` | |
If you create a secret env variable and a basic runtime env variable with the same key, Zerops saves the basic runtime env variable from your zerops.yml and ignores the secret env variable. | ||
|
||
If you create a basic build env variable and a runtime env variable with the same key, Zerops saves both because the build and runtime environments have separate sets of env variables. | ||
|
||
## Setting secret variables | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Take only line 217 - 226 and add them to line 83 with a title ### Set secret env variables when importing a service |
||
|
||
You can set secret variables in two ways: | ||
|
||
### With Import Dialog | ||
|
||
When importing a Node.js service using YAML configuration, you can define secret variables using the `envSecrets` map: | ||
|
||
```yaml | ||
services: | ||
- hostname: app | ||
type: nodejs@latest | ||
envSecrets: | ||
S3_ACCESS_KEY_ID: 'P8cX1vVVb' | ||
S3_ACCESS_SECRET: 'ogFthuiLYki8XoL73opSCQ' | ||
``` | ||
|
||
### In Zerops GUI | ||
|
||
Use secret variables to store passwords, tokens and other sensitive information that shouldn't be part of your repository and listed in zerops.yml. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would say only ".. to your services ..". (Project envs work a bit differently and they will be documented in a separate page later)
Also, it is possible to import a service both in this dialog and also with a zcli command, so the sentence could finish with "..to your services."