.env files
Download a service's variables
In the console, open the service and its Variables tab, then click Download .env and Download. The file, <service>.env, holds every variable the service gets, the shared ones included:
- Secrets are written with their values, in plain text. Keep the file somewhere safe.
- References such as
${{api.HOST}}are worked out, as the service gets them. - Who can: anyone with deploy access to the project, since deploying can read the values anyway. Each download is written to the audit log.
With the CLI
openpanel env pull writes every variable a service gets, from the project, its environment and the service itself, to a .env file, without the secrets' values:
openpanel env pull --project shop --service api# api's variables from OpenPanel (openpanel env pull).
DATABASE_URL=postgres://db:5432/shop
HOST=api
LOG_LEVEL=info
# STRIPE_KEY= (a secret: its value is never shown; set it yourself)- The file is
.envin the folder you run it from, or the path you give:openpanel env pull .env.local. It is readable by you only. - An existing file is not replaced unless you add
--force. - Secrets are listed as comments without their values, since nobody reads a secret back. Fill them in yourself.
- References are written as you typed them, such as
${{api.HOST}}, not worked out. - Values with spaces or other special characters are written in double quotes.
With .openpanel.json in the folder (from openpanel link), --project and --service can be left out. See Link and deploy.
Import a .env file
In the console, click Import .env on a service's Variables tab, or on the project's Shared variables page to set them for the whole project or one environment. Paste the file and click Import.
- Lines are
NAME=value.export NAME=value, single or double quotes, blank lines and#comments are read too. - A name that is already set gets the new value.
- All or none: if one line is wrong, the dialog says which line and nothing is set. A file sets at most 500 variables and is at most 512 KB.
- Save all as secrets stores every value sealed, never shown again. Leave it off for plain variables, and import secrets in a separate paste.
- When they apply: at the service's next deploy, like every variable change.
You need deploy access to the project.
With the CLI
openpanel env set takes several NAME=value pairs at once, so you can set a file's lines in one command:
openpanel env set NODE_ENV=production CACHE_TTL=60 LOG_LEVEL=info --project shop --service apiSet secrets on their own, with --secret and the value on standard input. See Secrets. The API has no import of a whole file.