Synchronizing Configuration and code changes

Updating the Configuration of your App using aptible config:set then deploying your app through Dockerfile Deploy or Direct Docker Image Deploy will deploy your App twice:

If you need to update your Configuration and ship new code that depends on it at the same time, this may not be appropriate.

To solve this problem, the Aptible CLI lets you deploy and update Configuration as one atomic operation. Here’s how.

For Dockerfile Deploy

To synchronize a Configuration change and code release when using Dockerfile Deploy, use this approach:

First, push your code to a new deploy branch on Aptible. Any name will do, as long as it’s not master, but we recommend giving it a random-ish name like in the example below:

BRANCH="deploy-$(date "+%s")"
git push aptible "master:$BRANCH"

Since you’re not pushing to master (instead, you’re pushing to a branch called deploy-...), this will not trigger a deploy on Enclave.

However, the new code will be available for future deploys: after pushing, you can deploy this branch along with the new Configuration variables using the aptible deploy command:

aptible deploy \
  --app "$APP_HANDLE" \
  --git-commitish "$BRANCH" \
  FOO=BAR QUX=

Note that some common Configuration variables can be provided directly via CLI arguments. For example, if you needed to provide Private Registry Authentication credentials to let Enclave pull a source Docker image, you can use this command:

aptible deploy \
  --app "$APP_HANDLE" \
  --git-commitish "$BRANCH" \
  --private-registry-username "$USERNAME" \
  --private-registry-password "$PASSWORD"

For Direct Docker Image Deploy

If you are using Direct Docker Image Deploy, you should already be using aptible deploy to deploy your app (if not, read the Direct Docker Image Deploy instructions).

In this case, simply append whatever environment variables you need to the aptible deploy command:

aptible deploy \
  --app "$APP_HANDLE" \
  --docker-image "$DOCKER_IMAGE" \
  FOO=BAR QUX=