Skip to main content

Setting environment variables

You might want to configure extra environment variables that will be passed to the app at runtime, such as database credentials.

Environment Variables Available by Default

Every Deploio app is automatically provided with the following environment variables:

  • PORT — The port number your app is exposed on.
  • DEPLOIO_APP_NAME — The name of your application.
  • DEPLOIO_PROJECT_NAME — The name of the project your app belongs to.
  • DEPLOIO_RELEASE_NAME — The name of the currently active release.

Set environment variables on app creation

You can specify env variables on app creation with nctl using the --env flag:

--env=KEY=VALUE;...    Environment variables which are passed to the app at runtime.

$ nctl create app rails-example --env=RAILS_ENV=dev

Multiple environment variables can be added by using the --env option multiple times or by using a semicolon to separate them:

$ nctl create app rails-example --env=RAILS_ENV=dev --env=MAIL_USERNAME=test
$ nctl create app rails-example --env='RAILS_ENV=dev;MAIL_USERNAME=test'

Updating environment variables

On existing applications you can use nctl update app to set new environment variables or change the values of already set ones.

$ nctl update app rails-example --env=RAILS_ENV=prod

To delete existing environment variables you can use the --delete-env flag

$ nctl update app rails-example --delete-env=RAILS_ENV

Listing the set environment variables

To see the currently set environment variables, you can use the nctl get app command and specifying the yaml output format.

$ nctl get app rails-example -o yaml

kind: Application
apiVersion: apps.nine.ch/v1alpha1
metadata:
name: rails-example
...
spec:
forProvider:
config:
env:
- name: MAIL_USERNAME
value: test
...