Environment Variables #

Environment variables are configured with via the env field in the stage definition. The key is the name of the variable provided to your app.

Variable names must comply with the following naming conventions: A key must consist only of letters (a-z, A-Z), numbers (0-9) and underscores (_), starting with a letter or underscore, a total length of 1 to 256 characters and none of the build-in variables.
...
apps:
  <APPNAME>:
    ...
    env:
      <ENV VARIABLE NAME>:
        description: <DESCRIPTION>
        value: <VALUE>
    ...

Like in any other deployments, environment variables store and provide information during the runtime to your application. Please consult the documentation of your app (framework) or respective technology used to determine what environment variables need to be configured.

description (optional) #

Can be used to provide a short description of the environment variable and/or its effect on the app.

value #

Sets the value of the variable.

Only set non-confidential values directly. If you want to pass a confidential value to your application, see the secrets section.

Secrets #

Secrets provide a way to pass confidential / sensitive information to your application during runtime via value templates.

Create a Secret #

A new secret can be defined on stage level by executing secret:create NAME=VALUE.

The secret name must consist only of letters (a-z, A-Z), numbers (0-9) and underscores (_), starting with a letter.
setops -p <PROJECT> -s <STAGE> secret:create secret_key_base=$(openssl rand -hex 64)

Show Secrets #

Use secret to list all secrets for a stage.

setops -p <PROJECT> -s <STAGE> secret
+---------------------------+------------+
|          SECRET           |   VALUE    |
+---------------------------+------------+
| secret_key_base           | ********** |
+---------------------------+------------+

You can show the value in plain text by adding the --values flag.

setops -p <PROJECT> -s <STAGE> secret --values
+---------------------------+------------+
|          SECRET           |   VALUE    |
+---------------------------+------------+
| secret_key_base           | 3A495FA31B |
+---------------------------+------------+

Use a Secret #

You can use secrets by setting a Golang Template String in the value field of an env variable. The secrets are available via the .Secrets map.

...
apps:
  <APPNAME>:
    ...
    env:
      SECRET_KEY_BASE:
        description: The secret key base used for encrypting sessions in Rails
        value: "{{ .Secrets.secret_key_base }}"
    ...

All Golang template features can be used, so you could also combine secrets ("{{ .Secrets.first_secret }}-{{ .Secrets.second_secret }}").

Destroy a Secret #

The command secret:destroy NAME deletes a secret with NAME from the stage.

setops -p <PROJECT> -s <STAGE> secret:destroy NAME

Built-in Variables #

There are some built-in variables which are set by SetOps and therefore cannot be set in the stage definition. Also, environment variables cannot start with SETOPS_ since this namespace is reserved for future environment variables provided by SetOps.

Name Description
SETOPS_IMAGE_TAG The image tag which was used to start the container
SETOPS_PORTS The configured network ports, separated by space
SETOPS_PROTOCOL The configured network protocol
SETOPS_APP_ENV_ID An internal ENV ID to detect changes this the configured environment
PORTS Deprecated: This env variable is set for backwards-compatibility. SETOPS_PORTS should be used from now on.
PORT Deprecated: This env variable is set for backwards-compatibility. SETOPS_PORTS should be used from now on.
PROTOCOL Deprecated: This env variable is set for backwards-compatibility. SETOPS_PROTOCOL should be used from now on.

Going further #

Configure Domains