diff --git a/apps/docs/content/features/env-variables.mdx b/apps/docs/content/features/env-variables.mdx index 5cfddf92..8341f256 100644 --- a/apps/docs/content/features/env-variables.mdx +++ b/apps/docs/content/features/env-variables.mdx @@ -23,11 +23,11 @@ You do not have to create an `.env` file. Zerops handles the environment variabl ## Types of environment variables -### Build & Runtime Variables +### Build & runtime variables These are variables defined in your `zerops.yml` file and are accessible within the build or runtime containers. -### Secret Variables +### Secret variables **Secret variables** are used to store all the sensitive data you don't want to store in your source repository, they are also useful for testing, where you need to frequently change the environment values. @@ -63,26 +63,56 @@ 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 services: + +### Using Import Features + +When importing services/project using yaml config via Zerops, 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' +``` + +### In service detail +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`.
+
-You can set env variables when you [create](/java/how-to/create) a new Java service or you can set them later. +### Individual editing + +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 variables by clicking on the menu on the right side of each row. -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. +### Bulk editing -You can edit or delete env variables that you've created by clicking on the menu on the right side of each row. +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 +``` -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. +Zerops will automatically update the env variables in all containers of your project's services. :::caution -You need to **restart** the runtime service after you commit the changes in env variables. The Java process running in the container receives the list env variables only when it starts. Update of the env variables while the Java process is running does not affect your application. +You need to **restart** the runtime service after updating env variables. The Java process running in the container receives the list env variables only when it starts. Update of the env variables while the Java process is running does not affect your application. ::: ## Set basic build env variables in zerops.yml diff --git a/apps/docs/content/nodejs/how-to/env-variables.mdx b/apps/docs/content/nodejs/how-to/env-variables.mdx index d62ac85a..367c88a9 100644 --- a/apps/docs/content/nodejs/how-to/env-variables.mdx +++ b/apps/docs/content/nodejs/how-to/env-variables.mdx @@ -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 +
-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 secret env variables when importing a service + +You can set secret variables in two ways: + +### Using Import Features + +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. ## Set basic build env variables in zerops.yml diff --git a/apps/docs/content/python/how-to/env-variables.mdx b/apps/docs/content/python/how-to/env-variables.mdx index 4fba2d41..26f22ce5 100644 --- a/apps/docs/content/python/how-to/env-variables.mdx +++ b/apps/docs/content/python/how-to/env-variables.mdx @@ -49,6 +49,11 @@ You can [reference](/python/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 +
-You can set env variables when you [create](/python/how-to/create) a new Python service or you can set them later. +### Individual editing + +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 variables by clicking on the menu on the right side of each row. + +### Bulk editing + +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: -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. +```env +# Add or update variables +DB_USER=admin +API_KEY=abc123 +DEBUG_MODE=true You can edit or delete env variables that you've created 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. +Zerops will automatically update the env variables in all containers of your project's services. :::caution -You need to **restart** the runtime service after you commit the changes in env variables. The Python process running in the container receives the list env variables only when it starts. Update of the env variables while the Python process is running does not affect your application. +You need to **restart** the runtime service after updating env variables. The Python process running in the container receives the list env variables only when it starts. Update of the env variables while the Python process is running does not affect your application. ::: ## Set basic build env variables in zerops.yml diff --git a/apps/docs/static/img/gui/env-editing.png b/apps/docs/static/img/gui/env-editing.png new file mode 100644 index 00000000..3df09990 Binary files /dev/null and b/apps/docs/static/img/gui/env-editing.png differ diff --git a/apps/docs/static/img/gui/secrets.webp b/apps/docs/static/img/gui/secrets.webp new file mode 100644 index 00000000..094eb795 Binary files /dev/null and b/apps/docs/static/img/gui/secrets.webp differ