Magento 2

Deploy a highly scalable, self-healing Magento 2 cluster in seconds.

About

Magento 2 is a powerful and highly customizable platform for SMB and enterprise-class eCommerce.

Stack

This template provisions the following components:

ComponentProcess typeHorizontally scalable
NGINXWebYes
PHP-FPM (7.4+)WorkerYes
MariaDB (10.3+)Service-
Redis Cache*Service-
Elasticsearch* (required by Magento 2.4+)Service-
Varnish*Service-

* Optional addon

Supported versions

Magento 2.2 or later

The latest version of Magento is installed by default. Choose Use existing codebase if you're migrating an existing site to Magelify.

Deployment

Magento supports Git push to deploy and pipeline deployments.

Build steps

The following steps runs as part of the CI/CD build pipeline to enable zero-downtime deployments.

  1. Install composer dependencies
  2. Run Magento code compiler and generate static assets

Pre-deploy hooks

When a new version is deployed, the following steps are executed:

  1. Run setup:db:upgrade if there are pending DB changes (e.g. module updates)
  2. Run app:config:import to import config changes from app/etc/config.php
  3. Clean Magento cache
  4. Enable Magento production mode

Configuration

This template automatically manages the app/etc/env.php config file. Database credentials are automatically populated based on the environment, and Redis, Varnish and Elasticsearch is automatically configured based on whether the addon is enabled or not.

Environment variables

The Magento 2 configuration can be customized with the following variables.

Variable nameDescription
MAGE_BASE_URLSets the default store base url
MAGE_DB_TABLE_PREFIXSets a custom database table prefix
MAGE_BACKEND_FRONTNAMESets a custom admin URL path
MAGE_CRYPT_KEYSets the Magento encryption key
MAGE_SESSION_SAVESets the Magento session store (redis|db|files)
Defaults to redis if Redis addon is enabled, otherwise files
MAGE_DISABLE_2FADisable backend 2-Factor authentication (true|false)
MAGE_PRESERVE_CACHEDisable automatic cleaning of cache after deploy (true|false)

Magento Multi-Store

Under Site Dashboard > Settings > Magento Multistore you can create mappings for domains to specific Magento websites/store views.

Add one mapping per line followed by a semi-colon like the example below:

# format: <hostname> <code>[,<type>];
# map requests for magento.com (including subdomains such as www.magento.com) to the store view 'us_store'
.magento.com us_store; # MAGE_RUN_TYPE defaults to 'store'
# map requests for magento.de to the website 'de_store'
magento.de de_store,website; # MAGE_RUN_TYPE explicitly set to 'website'

If you omit type it will default to "store" (store view). The hostname may be prefixed with a . (dot) to also match on subdomains (e.g. www​.).

Cron jobs

This template automatically configures the default Magento cron job. You can customize the schedule or add additional jobs from the Site Dashboard > Settings > Cron jobs section.

Persistent disks

The following directories are mounted by persistent storage volumes.

./pub/media

Contains static assets and product images.

./var

Contains cache, session files, file exports, etc.

Do NOT commit these folders to your Git repository as they will be overwritten. Use SFTP to upload files.

Admin tools

The following utilities are included with this template.

  • n98-magerun2 (alias: magerun) is a command-line interface for Magento 2.
  • phpMyAdmin is a web-based administration tool for your database.