Container Environment
Containers on Aptible run with the types of environment variables described in each section below.
You can access these 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, Aptible 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
.
Aptible Metadata
Finally, Aptible injects a set of metadata keys as environment variables.
Here is the list of variables injected by Aptible:
APTIBLE_PROCESS_TYPE
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, this will be set to APTIBLE_PROCESS_TYPE=cmd
.
APTIBLE_PROCESS_INDEX
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
APTIBLE_CONTAINER_SIZE
Represents the memory limit in MB of the Container. See Memory Limits for more information.
APTIBLE_LAYER
APTIBLE_LAYER
Set to app
or database
, representing whether the Container is an App or Database Container.
APTIBLE_GIT_REF
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_ORGANIZATION_HREF
Aptible API URL representing the Organization this container belongs to.
APTIBLE_APP_HREF
APTIBLE_APP_HREF
Aptible API URL representing the App this container belongs to, if any.
APTIBLE_DATABASE_HREF
APTIBLE_DATABASE_HREF
Aptible API URL representing the Database this container belongs to, if any.
APTIBLE_SERVICE_HREF
APTIBLE_SERVICE_HREF
Aptible API URL representing the Service this container belongs to, if any.
APTIBLE_RELEASE_HREF
APTIBLE_RELEASE_HREF
Aptible API URL representing the Release this container belongs to, if any.
APTIBLE_EPHEMERAL_SESSION_HREF
APTIBLE_EPHEMERAL_SESSION_HREF
Aptible API URL representing the current Ephemeral SSH Sessions this container belongs to, if any.
APTIBLE_RESOURCE_HREF
APTIBLE_RESOURCE_HREF
Used internally by Aptible. Do not depend on this value.
APTIBLE_ALLOCATION
APTIBLE_ALLOCATION
Used internally by Aptible. Do not depend on this value.
Updated 12 months ago