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.
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.Any value that you can set when creating or updating an app can be changed specifically for preview environments.
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 the path of your preview porter.yaml file.
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 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 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: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.
You will also have to create a wildcard record in your DNS provider for the base domain (e.g. *.my-domain.com) that points to the ingress IP for your cluster. The ingress IP can be found in the Networking tab of any of your web services.The ingress IP for your cluster can be found in the Networking tab of any of your web services.