Container Environment

Containers on Enclave run with the following environment variables:

You can access those environment variables through whatever facilities your language exposes to access them, such as ENV in Ruby, process.env for Node apps, os.environ in Python.

If there is a name collision, Enclave Metadata takes precedence over App Configuration, which itself takes precedence over Docker Image Variables.

Docker Image Variables

Your Docker Image can specify environment variables. Those are defined via the ENV directive, and will be present when your Containers are started:

ENV FOO=BAR

App Configuration

Your App’s Configuration is injected as environment variables. For example, if you set the keys FOO and BAR:

aptible config:set --app "$APP_HANDLE" \
        FOO=SOME BAR=OTHER

Then your Containers will be run with the environment variables FOO and BAR set respectively to SOME and OTHER.

Enclave Metadata

Finally, Enclave injects a set of metadata keys as environment variables.

Here is the list of variables injected by Enclave:

APTIBLE_PROCESS_TYPE

Represents the name of the Service this Container belongs to.

For example, if you Procfile defines the services:

web: bundle exec rails s
worker: bundle exec sidekiq

Then the Containers for the web Service will run with APTIBLE_PROCESS_TYPE=web, and the Containers for the worker Service will run with APTIBLE_PROCESS_TYPE=worker.

If you do not have a Procfile and instead rely on an Implicit Service (CMD), this will be set to APTIBLE_PROCESS_TYPE=cmd.

APTIBLE_PROCESS_INDEX

All containers for a given Release of a Service are assigned a unique 0-based process index.

For example, if your web service is scaled to 2 containers, one of them will have APTIBLE_PROCESS_INDEX=0, and the other will have APTIBLE_PROCESS_INDEX=1.

APTIBLE_CONTAINER_SIZE

Represents the memory limit in MB of the Container. See Memory Limits for more information.

APTIBLE_LAYER

Set to app or database, representing whether the Container is an App or Database Container.

APTIBLE_GIT_REF

For App Containers using Dockerfile Deploy or Companion Git Repository, the git SHA that was used at the time the Container was deployed.

APTIBLE_ORGANIZATION_HREF

Aptible API URL representing the Organization this container belongs to.

APTIBLE_APP_HREF

Aptible API URL representing the App this container belongs to, if any.

APTIBLE_DATABASE_HREF

Aptible API URL representing the Database this container belongs to, if any.

APTIBLE_SERVICE_HREF

Aptible API URL representing the Service this container belongs to, if any.

APTIBLE_RELEASE_HREF

Aptible API URL representing the Release this container belongs to, if any.

APTIBLE_RESOURCE_HREF

Used internally by Aptible. Do not depend on this value.

APTIBLE_ALLOCATION

Used internally by Aptible. Do not depend on this value.