# Configuration File

{% code title="default cma.js" %}

```javascript
/** @type {import('@scandipwa/magento-scripts').CMAConfiguration} */
module.exports = {
    magento: {
        first_name: 'Scandiweb',
        last_name: 'Developer',
        email: 'developer@scandipwa.com',
        user: 'admin',
        password: 'scandipwa123',
        adminuri: 'admin',
        mode: 'developer',
        edition: 'community'
    },
    configuration: {}
};

```

{% endcode %}

The configuration file is created when you start the project `cma.js`, it's a tool that allows you to be in control of important parts of the project without headaches.

## Magento

Magento configuration is located in `magento` field and contains the following fields:

* `first_name`  - Admin first name
* `last_name` - Admin last name
* `email` - Admin email
* `user` - Admin user name
* `password` Admin password
* `adminuri` - Admin panel URL
* `mode` - Magento mode (description and list of available modes are located [here](https://devdocs.magento.com/guides/v2.4/config-guide/bootstrap/magento-modes.html))
* `edition` - Magento edition. Allowed values: `community`, `enterprise`.

## Services

In the `configuration` field we can configure PHP, Composer and Docker services.

### PHP

PHP configuration is located in the `php` field and contains the following fields:

* `baseImage` - PHP image without XDebug installed. You can select an image from the [PHP image list](https://docs.create-magento-app.com/container-images/php-images).
* <mark style="color:red;">`debugImage`</mark> - PHP image with XDebug installed. You can select an image from the [PHP image list](https://docs.create-magento-app.com/container-images/php-images). <mark style="color:orange;">(deprecated since</mark> <mark style="color:orange;"></mark><mark style="color:orange;">**magento-scripts\@2.4.0**</mark><mark style="color:orange;">)</mark>&#x20;
* `configTemplate` - `php.ini` template file location. With this option, you can define your own `php.ini` file that will be used by PHP. (Original `php.template.ini` file can be found [here](https://github.com/scandipwa/create-magento-app/blob/master/build-packages/magento-scripts/lib/config/templates/php.template.ini))
* `debugTemplate` - `xdebug.ini` template file location. With this option you can tweak the XDebug configuration used in together with `debugImage`. (Original `php-debug.template.ini` file can be found [here](https://github.com/scandipwa/create-magento-app/blob/master/build-packages/magento-scripts/lib/config/templates/php-debug.template.ini))
* `fpmConfigTemplate` - `php-fpm.conf` template file location. With this option you can tweak the PHP-FPM configuration used by PHP-FPM. (Original `php-fpm.template.conf` file can be found [here](https://github.com/scandipwa/create-magento-app/blob/master/build-packages/magento-scripts/lib/config/templates/php-fpm.template.conf))
* `extensions` - Map of extensions that will be used for the project. By default, it contains the following extensions that are required by Magento. You can add an extension that will be required by some Composer package, CMA will automatically install it with the correct version.\
  Learn more about installing extensions in our guide on [Configuring PHP](https://docs.create-magento-app.com/usage-guide/configuring-php)!
* `env` - Environment variables for container **Record\<string, string>**.
* `platform` - Select the platform mode for the service. Working values are `linux/amd64` and `linux/arm64`, but they are limited only to supported platforms by Docker. Default value `''` , which will tell magento-scripts to select the appropriate platform automatically. Recommended to use default value unless you specifically need to change platform to support a legacy Magento installation.

Example to install `fileinfo` extension:

```javascript
/** @type {import('@scandipwa/magento-scripts').CMAConfiguration} */
module.exports = {
    magento: { ... },
    configuration: {
        php: {
            // let's add some extensions
            extensions: {
                fileinfo: {}
            }
        }
    }
};
```

{% content-ref url="../usage-guide/configuring-php" %}
[configuring-php](https://docs.create-magento-app.com/usage-guide/configuring-php)
{% endcontent-ref %}

Example to edit environment variable of  PHP container:

```javascript
/** @type {import('@scandipwa/magento-scripts').CMAConfiguration} */
module.exports = {
    magento: { ... },
    configuration: {
        php: {
            // and add custom env variable
            env: {
                COMPOSER_MEMORY_LIMIT: -1
            }
        }
    }
};
```

### Nginx

Nginx configuration is located in the `nginx` field and contains the following fields:

* `image` - Container image **string**. For Nginx default version is `nginx:1.18.0` .
* `configTemplate` - Nginx template file location **string**. With this option, you can define your own nginx.conf file that will be used by Nginx. (Original `nginx.template.conf` file can be found [here](https://github.com/scandipwa/create-magento-app/blob/master/build-packages/magento-scripts/lib/config/templates/nginx.template.conf))
* `platform` - Select the platform mode for the service. Working values are `linux/amd64` and `linux/arm64`, but they are limited only to supported platforms by Docker. Default value `''` , which will tell magento-scripts to select the appropriate platform automatically. Recommended to use default value unless you specifically need to change platform to support a legacy Magento installation.

{% hint style="info" %}
Nginx image is pulled from [Docker Hub](https://hub.docker.com/_/nginx).
{% endhint %}

```javascript
/** @type {import('@scandipwa/magento-scripts').CMAConfiguration} */
module.exports = {
    magento: { ... },
    configuration: {
        nginx: {
            // lets change nginx image to 1.19.0
            image: 'nginx:1.19.0',
            // and use custom nginx template
            configTemplate: './nginx.conf.template'
        }
    }
};
```

### MariaDB

MariaDB configuration is located in the `mariadb` field and contains the following fields:

* `image` - Container image. **string**.
* `useOptimizerSwitch` - MariaDB specific setting. **string** or **boolean**.\
  By default set to **true** for MariaDB 10.4 and newer version.\
  During template file compilation **true** will be transformed to the following configuration:

  ```
  rowid_filter=off
  ```

  Can be set to any valid configuration from [feature documentation](https://mariadb.com/kb/en/optimizer-switch/).
* `platform` - Select the platform mode for the service. Working values are `linux/amd64` and `linux/arm64`, but they are limited only to supported platforms by Docker. Default value `''` , which will tell magento-scripts to select the appropriate platform automatically. Recommended to use default value unless you specifically need to change platform to support a legacy Magento installation.

{% hint style="info" %}
MariaDB image is pulled from [Docker Hub](https://hub.docker.com/_/mariadb).
{% endhint %}

```javascript
/** @type {import('@scandipwa/magento-scripts').CMAConfiguration} */
module.exports = {
    magento: { ... },
    configuration: {
        mariadb: {
            // lets change mariadb image to 10.4
            image: 'mariadb:10.4',
            
            // and use optimizer switch with desired flag
            useOptimizerSwitch: 'rowid_filter=off'
        }
    }
};
```

### SearchEngine (OpenSearch / ElasticSearch)

SearchEngine configuration is located in the `searchengine` field and allows you to select **elasticsearch** and **opensearch** as options.

```javascript
/** @type {import('@scandipwa/magento-scripts').CMAConfiguration} */
module.exports = {
    magento: { ... },
    configuration: {
        searchengine: 'opensearch'
    }
};
```

For Magento 2.4.7 and older CMA by default will select **elasticsearch** for `searchengine` configuration.\
From Magento 2.4.8 and newer CMA by default will select **opensearch** for `searchengine` configuration.

#### ElasticSearch

ElasticSearch configuration is located in the `elasticsearch` field and contains the following fields:

* `image` - Container image **string**.
* `env` - Environment variables for container **object**.
* `platform` - Select the platform mode for the service. Working values are `linux/amd64` and `linux/arm64`, but they are limited only to supported platforms by Docker. Default value `''` , which will tell magento-scripts to select the appropriate platform automatically. Recommended to use default value unless you specifically need to change platform to support a legacy Magento installation.

{% hint style="info" %}
ElasticSearch image is pulled from [ElasticSearch Hub](https://www.docker.elastic.co/r/elasticsearch).
{% endhint %}

{% hint style="warning" %}
Magento 2.2.10 - 2.3.4 are using our [custom ElasticSearch image ](https://docs.create-magento-app.com/container-images/elasticsearch-images/elasticsearch-6.8)that works on **amd64** and **arm64** architectures.
{% endhint %}

```javascript
/** @type {import('@scandipwa/magento-scripts').CMAConfiguration} */
module.exports = {
    magento: { ... },
    configuration: {
        elasticsearch: {
            // lets change elasticsearch image version to 7.13.1
            image: 'elasticsearch:7.13.1',
            env: {
                // add additional environment variables
                ES_JAVA_OPTS: '-Xms2048m -Xmx4096m'
            }
        }
    }
};
```

#### OpenSearch

ElasticSearch configuration is located in the `opensearch` field and contains the following fields:

* `image` - Container image **string**.
* `env` - Environment variables for container **object**.
* `platform` - Select the platform mode for the service. Working values are `linux/amd64` and `linux/arm64`, but they are limited only to supported platforms by Docker. Default value `''` , which will tell magento-scripts to select the appropriate platform automatically. Recommended to use default value unless you specifically need to change platform to support a legacy Magento installation.

{% hint style="info" %}
OpenSearch image is pulled from [Docker Hub](https://hub.docker.com/r/opensearchproject/opensearch).
{% endhint %}

```javascript
/** @type {import('@scandipwa/magento-scripts').CMAConfiguration} */
module.exports = {
    magento: { ... },
    configuration: {
        opensearch: {
            // lets change opensearch image version to 2.13.0
            image: 'opensearchproject/opensearch:2.13.0',
            env: {
                // add additional environment variables
                OPENSEARCH_JAVA_OPTS: '-Xms2048m -Xmx4096m'
            }
        }
    }
};
```

{% content-ref url="../usage-guide/opensearch" %}
[opensearch](https://docs.create-magento-app.com/usage-guide/opensearch)
{% endcontent-ref %}

### Redis

Redis configuration is located in the `redis` field and contains the following fields:

* `image` - Container image **string**.
* `platform` - Select the platform mode for the service. Working values are `linux/amd64` and `linux/arm64`, but they are limited only to supported platforms by Docker. Default value `''` , which will tell magento-scripts to select the appropriate platform automatically. Recommended to use default value unless you specifically need to change platform to support a legacy Magento installation.

{% hint style="info" %}
Redis image is pulled from [Docker Hub](https://hub.docker.com/_/redis).
{% endhint %}

```javascript
/** @type {import('@scandipwa/magento-scripts').CMAConfiguration} */
module.exports = {
    magento: { ... },
    configuration: {
        redis: {
            // lets change redis image version to 6.2.4
            image: 'redis:6.2.4'
        }
    }
};
```

### Composer

Composer configuration is located in the `composer` field and contains the following fields:

* `version` - Composer version **string**. You can also use the `latest-stable`, `latest-preview`, `latest-1.x`, `latest-2.x` and `latest-2.2.x`.
* `plugins` - Map of Composer global plugins with a configuration that will be added to project image.
* `plugins[name].enabled` - a `boolean` which determines if the plugin should be enabled. For example, if you are using an older Magento version with Composer 1 [Prestissimo](https://github.com/hirak/prestissimo) plugin is enabled by default to speed-up installation and you can disable it!
* `plugins[name].options` - a `string` with additional options for `composer global require <name> <options>` command.

Examples:

<pre class="language-javascript"><code class="lang-javascript"><strong>/** @type {import('@scandipwa/magento-scripts').CMAConfiguration} */
</strong>module.exports = {
    magento: { ... },
    configuration: {
        composer: {
            // lets change composer version to 2.8.8
            version: '2.8.8'
        }
    }
};
</code></pre>

<pre class="language-javascript"><code class="lang-javascript"><strong>// Define composer version from a channel
</strong><strong>
</strong><strong>/** @type {import('@scandipwa/magento-scripts').CMAConfiguration} */
</strong>module.exports = {
    magento: { ... },
    configuration: {
        composer: {
            // lets change composer version to latest-2.2.x (LTS)
            version: 'latest-2.2.x'
        }
    }
};
</code></pre>

```javascript
// Install any composer plugin:

/** @type {import('@scandipwa/magento-scripts').CMAConfiguration} */
module.exports = {
    magento: { ... },
    configuration: {
        composer: {
            plugins: {
                // <plugin vendor/plugin name>
                'hirak/prestissimo': {
                    enabled: true
                }
            }
        }
    }
};
```

### Varnish

Varnish configuration is located in the `varnish` field and contains the following fields:

* `enabled` - A **boolean** option to manually enable or disable Varnish in the setup. (Default: `false`)
* `configTemplate` - `varnish.vcl` template file location. With this option, you can define your own `varnish.vcl` file that will be used by Varnish. (Original `varnish.template.vcl` file can be found [here](https://github.com/scandipwa/create-magento-app/blob/master/build-packages/magento-scripts/lib/config/templates/varnish.template.vcl))
* `image` - Varnish image **string**.
* `healthCheck` - A **boolean** option to manually enable or disable Varnish HealthCheck in the setup. (Default: `false`)
* `platform` - Select the platform mode for the service. Working values are `linux/amd64` and `linux/arm64`, but they are limited only to supported platforms by Docker. Default value `''` , which will tell magento-scripts to select the appropriate platform automatically. Recommended to use default value unless you specifically need to change platform to support a legacy Magento installation.

{% hint style="info" %}
Varnish image is pulled from [Docker Hub](https://hub.docker.com/_/varnish).
{% endhint %}

{% hint style="warning" %}
&#x20;Varnish is disabled by default since **magento-scripts\@2.4.0**.
{% endhint %}

```javascript
/** @type {import('@scandipwa/magento-scripts').CMAConfiguration} */
module.exports = {
    magento: { ... },
    configuration: {
        varnish: {
            // lets change composer version to 6.0
            image: 'varnish:6.0'
        }
    }
};
```

### SSL Terminator (Nginx)

SSL Terminator is an Nginx instance, its configuration is located in `sslTerminator` field and contains the following fields:

* `image` - Container image **string**.
* `configTemplate` - SSL Terminator template file location **string**. With this option, you can define your own `ssl-terminator.template.conf` - File that will be copied inside the `$CMA_CACHE/ssl-terminator/conf.d/` folder which is mounted in Nginx container to `/etc/nginx/conf.d/` folder. **string** (Original `ssl-terminator.template.conf` file can be found [here](https://github.com/scandipwa/create-magento-app/blob/master/build-packages/magento-scripts/lib/config/templates/ssl-terminator.template.conf))
* `platform` - Select the platform mode for the service. Working values are `linux/amd64` and `linux/arm64`, but they are limited only to supported platforms by Docker. Default value `''` , which will tell magento-scripts to select the appropriate platform automatically. Recommended to use default value unless you specifically need to change platform to support a legacy Magento installation.

{% hint style="info" %}
Nginx image is pulled from [Docker Hub](https://hub.docker.com/_/nginx).
{% endhint %}

```javascript
/** @type {import('@scandipwa/magento-scripts').CMAConfiguration} */
module.exports = {
    magento: { ... },
    configuration: {
        sslTerminator: {
            // lets change nginx image version to 1.19
            image: 'nginx:1.19.0',
            // and use custom ssl-terminator nginx template
            configTemplate: './ssl-terminator.conf.template'
        }
    }
};
```

### NewRelic

{% hint style="warning" %}
Available only on Linux. WSL/MacOS are not supported.
{% endhint %}

NewRelic is a monitoring service for applications and uses the following configurations fileds:

* `enabled` - Boolean indicating if NewRelic is used in the application or not. Default is `false`.
* `licenseKey` - License key **string**. Located in API Keys section on NewRelic.

```javascript
/** @type {import('@scandipwa/magento-scripts').CMAConfiguration} */
module.exports = {
    magento: { ... },
    configuration: {
        newRelic: {
            enabled: true,
            licenseKey: '<LICENSE_KEY>'
        }
    }
};
```

{% hint style="info" %}
Learn about adding NewRelic to your application [here](https://docs.create-magento-app.com/usage-guide/configuring-newrelic).
{% endhint %}

## Domain

{% hint style="info" %}
Available in `magento-scripts` \~2.0.x and \~2.1.x
{% endhint %}

The host configuration is a string located in `host` field and by default, it is set to `localhost` .\
You can put your own host domain that will be set to nginx config as `server_name` and set Magento secure and unsecure base\_url values.

```javascript
/** @type {import('@scandipwa/magento-scripts').CMAConfiguration} */
module.exports = {
    magento: { ... },
    host: 'scandipwa.local'
};

```

{% hint style="info" %}
Learn about adding a localhost domain to your application [here](https://docs.create-magento-app.com/usage-guide/setup-custom-domain).
{% endhint %}

## Multi-Store Domains

{% hint style="info" %}
Since `magento-scripts` 2.2.x!
{% endhint %}

`storeDomains` allows to set different domains for Magento stores.

Use `store code` as `key` and domain as a `value`.

```javascript
/** @type {import('@scandipwa/magento-scripts').CMAConfiguration} */
module.exports = {
    magento: { ... },
    storeDomains: {
        admin: 'scandipwa.local'
    }
};
```

{% hint style="info" %}
Learn about configuring Multi-Store domains in your application [here](https://docs.create-magento-app.com/usage-guide/configuring-multi-store).
{% endhint %}

## SSL

SSL configuration is located in the `ssl` field and contains the following values:

* `enabled` - Enables or disables SSL in the application. **boolean** (`false` by default)
* `external_provider` - Allows to use external SSL provider in the application. **boolean** (`false` by default)
* `ssl_certificate` - SSL certificate file location **string**. You can put there your SSL certificate file location relative to the project root folder or use absolute value.
* `ssl_certificate_key` - SSL certificate key file location **string**. You can put there your SSL certificate file location relatively to the project root folder or use absolute value.

```javascript
/** @type {import('@scandipwa/magento-scripts').CMAConfiguration} */
module.exports = {
    magento: { ... },
    ssl: {
        enabled: true,
        external_provider: false,
        ssl_certificate: './path/to/my/certificate',
        ssl_certificate_key: './path/to/my/certificate-key.pem'
    }
};

```

{% hint style="info" %}
Learn about enabling SSL in your application [here](https://docs.create-magento-app.com/usage-guide/enabling-ssl).
{% endhint %}

## Prefix

Prefix configuration is a boolean located in the `prefix` field and by default, it is set to `true` .

But what prefixes are used for?\
Prefix is a unique identifier that will be appended to docker container and volume names to prevent possible interference between folders with similar names. (Interference between folders look like [that](https://github.com/scandipwa/create-magento-app/issues/13))\
Setting `prefix` to `false` is generally **not recommended** but might be necessary for legacy projects.

```javascript
/** @type {import('@scandipwa/magento-scripts').CMAConfiguration} */
module.exports = {
    magento: { ... },
    prefix: false
};

```
