When dealing with dozens of environment variables, it can be tedious to import them one by one. This is where the Qovery CLI with the env vars import feature helps. In this tutorial, you will learn how to import your environment variables and secrets via the Qovery CLI.
Before you begin, this page assumes the following:
- Your dotenv (
.env
) file is compliant to the following specs - You have created your application in Qovery
Install Qovery CLI
- Linux
- MacOS
- Windows
- Docker
- *nix
- Arch Linux
- Manual
To download and install Qovery CLI on any Linux distribution:
$ curl -s https://get.qovery.com | bash
Set your context
Once you are authenticated with qovery auth
, you must choose the application where you want to set the environment variables with the command qovery context set
.
$ qovery auth
~/Desktop $ qovery context setQovery: Current context:Organization | Qovery CommunityProject | posthogEnvironment | prodApplication | proxyQovery: Select new contextOrganization:✔ Qovery RealmProject:✔ PosthogEnvironment:✔ prodApplication:✔ nginx-proxyQovery: New context:Organization | Qovery RealmProject | PosthogEnvironment | prodApplication | nginx-proxy
Import
With Qovery, you make the distinction between Environment Variables and Secrets. Basically, the value of a Secret is encrypted and cannot be revealed.
Let's say that we have the following dotenv file .env.development
that we want to import:
STRAPI_API_KEY=x.xxyyyzzzCOLOR_BACKGROUND=fffAUTH0_API_KEY_SECRET=0xb33fAPI_URL=https://api.mytld.com
The STRAPI_API_KEY
and AUTH0_API_KEY_SECRET
are Secrets. COLOR_BACKGROUND
and API_URL
are Environment Variables.
Environment Variables
To import the Environment Variables from this file we run the command qovery env import <dotenv file>
and we select the environment variables to import:
$ qovery env import .env.developmentQovery: dot env file to import: '.env.development'? Do you want to import Environment Variables or Secrets? Environment Variables? What environment variables do you want to import? [Use arrows to move, space to select, <right> to all, <left> to none, type to filter][x] COLOR_BACKGROUND=fff[ ] AUTH0_API_KEY_SECRET=0xb33f> [x] API_URL=https://api.mytld.com[ ] STRAPI_API_KEY=x.xxyyyzzz
Once validated you will see the following import validation:
? What environment variables do you want to import? COLOR_BACKGROUND=fff, API_URL=https://api.mytld.comQovery: ✅ Environment Variables successfully imported!
If during the import something goes wrong, you will see the errors and why it failed.
Secrets
To import the Secrets, you need to run the same command qovery env import <dotenv file>
and select the secrets to import.
$ qovery env import .env.developmentQovery: dot env file to import: '.env.development'? Do you want to import Environment Variables or Secrets? Secrets? What environment variables do you want to import? [Use arrows to move, space to select, <right> to all, <left> to none, type to filter][ ] COLOR_BACKGROUND=fff[x] AUTH0_API_KEY_SECRET=0xb33f[ ] API_URL=https://api.mytld.com> [x] STRAPI_API_KEY=x.xxyyyzzz
Once validated you will see the following import validation:
? What environment variables do you want to import? STRAPI_API_KEY=x.xxyyyzzz, AUTH0_API_KEY_SECRET=0xb33Qovery: ✅ Secrets successfully imported!
Check
Open your environment variables console to check that everything has been set correctly.