Configure multiple environments per Site in xmCloud

Configure multiple environments per Site in xmCloud

Here I will show you how to set up multiple environments for your sites in xmCloud. Usually for each project, you will have multiple environments, like Development, Staging, and Production. Each of these environments may have a different site configuration, the obvious one is the different hostname.

It is pretty easy to set this up. You need to take only two steps:



Configure environment variable on xmCloud Deploy

Open the xmCloud Deploy and navigate to your Project. Choose the environment that you want to configure. On the Variables tab, create a new variable with the name: XMCLOUD_ENVIRONMENT, and in the value add something meaningful for the environment name, for example: XMCLOUD_DEVELOP

Do the same for other environments.

In your code add the following settings and deploy it:

<settings>
    <setting name="XA.Foundation.Multisite.Environment" set:value="$(env:XMCLOUD_ENVIRONMENT)" />
</settings>

Configure the sites based on the environment

Now in xmCloud content editor, navigate to /Settings/Site Grouping/. Choose your Site, in the "Valid for environment " remove the "*" and enter "LOCAL".

After doing this, add the "XMCLOUD_ENVIRONMENT=LOCAL" entry to your docker .env file.

Now you can duplicate the site configuration and add a postfix to it:acme-development.
In the "Valid for environment" add the configured value in xmCloud deploy environment variables.

Adjust the hostname/target hostname. Repeat the step for other environments like staging and production.

This is a powerful feature and using it you can easily maintain the site configurations and deploy them using IAR.