πΊ Managing Environment Variables
π» Local Developmentβ
Installing the CLI Toolβ
The Infisical CLI is a powerful command-line tool that can be used to retrieve, modify, export, and inject secrets into any process or application as environment variables. You can use it across various environments, whether itβs local development, CI/CD, staging, or production.
Logging in with the CLIβ
infisical login
- Select your hosting option:
Self Hosting - Domain:
https://env.byt.so
Initializing Infisical for Your Projectβ
# Navigate to your project
cd /path/to/project
# Initialize Infisical
infisical init
Injecting Environment Variablesβ
Pass environment variables from Infisical into your application.
- Use the command
infisical runto inject environment variables into your application. infisical run --env=dev -- [your application start command] # e.g. npm run dev, npm run start, npm run build, etc
"scripts": {
# Other scripts
"dev": "infisical run --env=dev -- next dev",
# Other scripts
},
- Update the above command in your application scripts.
- π Start your application with [your application start command] # e.g.
npm run dev. - Infisical Core Commands
π CI/CDβ
Using Machine Identityβ
-
Create an Identity.
-
Set
CLIENT_ID,CLIENT_SECRET,PROJECTIDin GitLab CI/CD variables.
curl -1sLf \
'https://dl.cloudsmith.io/public/infisical/infisical-cli/setup.deb.sh' \
| sudo -E bash
sudo apt-get update && sudo apt-get install -y infisical
export INFISICAL_API_URL="https://env.byt.so"
export INFISICAL_TOKEN=$(infisical login --method=universal-auth --client-id=$CLIENT_ID --client-secret=$CLIENT_SECRET --silent --plain)
infisical run --env=dev --projectId=$PROJECTID [application start command]
- The
--plainflag will output only the token, so it can be fed to an environment variable. The--silentflag will disable any update messages.