AVL Environment Variables

AVL Environment Variables

We expose several environment variables in the lab, which may help you to communicate between containers or provide access to a unique identifier within a container.

List of Variables

AVL_STUDENT_ID=email.address@example.com

AVL_PRIMARY_CONTAINER_NAME=user___XXXXYYYY

AVL_PRIMARY_CONTAINER_DOMAIN=user-XXXXYYYY

AVL_PRIMARY_CONTAINER_INTERNAL_DOMAIN=user-XXXXYYYY

AVL_PRIMARY_CONTAINER_EXTERNAL_DOMAIN=3000-0-ZZZZYYYY.yourdomain.appsembler.com

AVL_PAIRED_CONTAINER_NAME=user___ZZZZYYYY___paired

AVL_PAIRED_CONTAINER_DOMAIN=user-ZZZZYYYY-paired

AVL_PAIRED_CONTAINER_INTERNAL_DOMAIN=user-ZZZZYYYY-paired

AVL_PAIRED_CONTAINER_EXTERNAL_DOMAIN=8000-1-ZZZZYYYY.yourdomain.appsembler.com

AVL_DEPLOY_ID=ZZZZYYYY (v5.3.0+)


You'll note that the unique identifier XXXXYYYY follows the container; we use it in several places. In addition to the env vars listed above, you'll find this unique identifier in the AVL dashboard, so you can use it to search for a given container.

Note: yourdomain.appsembler.com in the example above is the full TLD of your site, whether you use a custom domain or an .appsembler subdomain.

Networking

The AVL_PRIMARY_CONTAINER_INTERNAL_DOMAIN and AVL_PAIRED_CONTAINER_INTERNAL_DOMAIN allows you to communicate with this container within our internal network. So, if you for example you have a database running in the paired container and wish to connect to it from the primary container, you could pass the AVL_PAIRED_CONTAINER_INTERNAL_DOMAIN:8888 to your database configuration (where 8888 is your database's internal port that you opened in the paired container).

Tying the Unique ID to External Services

You can use the unique ID to generate, e.g., a unique S3 bucket for each user by simply using the AVL_PRIMARY_CONTAINER_NAME as the bucket name.

Detecting Student Containers

If you want to detect the difference between student containers and admin containers, for example, if you have a setup script that you don't want to run while you are configuring an image as an admin container, but to run when the image is launched as a project, you can detect the presence of the AVL_STUDENT_ID environment variable as this is not set when running as an admin contaner.  


As an example, you can add the following to the top of a bash script:

#!/bin/bash

if [ ! -v 'AVL_STUDENT_ID' ]

then

echo "Not in a student container, exiting"

exit 0

fi