Changing Values and Variables

It is frequently the case that the configuration you are using for your app in production will be different from what you’d want to use in a preview environment. For example, you might want to bump down the resources your app consumes or use development API keys. Porter allows you to easily change the configuration of your app for preview environments by defining overrides in the dashboard or in your porter.yaml file.

Using the Dashboard

After enabling previews, you will be directed to a form where you can define what you want your app to look like when deployed to a preview environment. Any value that you can set when creating or updating an app can be changed specifically for preview environments. Newly created previews will use these values. Note that you can always change this configuration later. Updating Values Any value that you can set when creating or updating an app can be changed specifically for preview environments.

Using porter.yaml (Optional)

You can also define a separate porter.yaml file to be used specifically for preview apps. The values in this file will override any values that are set while configuring the preview app template in the dashboard. The format of this file is the same as non-preview porter.yaml files (full reference here). When creating the preview app template, you will be prompted to select the path of your preview porter.yaml file. Selecting Preview porter.yaml File Selecting the path of your preview porter.yaml file.

Setting Environment Variables

Porter will by default use the environment variables from the base app, but strip out any environment groups that you have attached. This is because environment groups are typically used to define values that are specific to a particular environment. If there are any variables that you want to ensure are set in preview environments, you can add them to the app’s environment variables, or create a new environment group specifically for preview environments and add it to the preview app configuration in the dashboard.

Preview App URLs

Preview apps can be made accessible via a unique URL that is generated when the preview is created. Similarly to environment groups, custom domains defined on your base app are also stripped out when creating the preview app in order to prevent collisions. If you want to make a preview web service accessible via a unique URL, make sure that the service is configured to be public.

Custom Domains

Custom domains can be configured based on the PR branch name by using the {BRANCH} placeholder in the custom domain name while configuring the preview app template: Custom Domains Using the {BRANCH} placeholder in the custom domain name will result in a custom domain that is based on the PR branch name for each preview. For example, if you set the custom domain to {BRANCH}.my-domain.com and have a branch named my-feature-branch, the preview app will be accessible via my-feature-branch.my-domain.com. Note that in order to be compatible with this feature, the branch name must consist of lower case alphanumeric characters, ’-’ or ’.’, and must start and end with an alphanumeric character.