Production mode

Production mode is the default configuration setting for launching the Docker environment with read-only filesystem permissions. This option builds the Docker environment in production mode and verifies configured service versions.

See Configure Docker for additional information about Docker prerequisites and using the Magento Cloud Docker environment.

To launch the Docker environment in production mode:

  1. Download a Magento application template from the Magento Cloud repository and copy the files to your Magento Cloud Docker project directory. Be careful to select the branch that corresponds with the Magento version.

  2. Add your Magento access credentials to the auth.json file.

  3. Run the installation script, init-docker.sh to install the template dependencies and add the default hostname to your /etc/hosts file.

    1
    
    curl https://raw.githubusercontent.com/magento/magento-cloud-docker/<magento-cloud-docker-package-version>/bin/init-docker.sh | bash
    

    For <package-version>, use the latest release of the magento/magento-cloud-docker.

    You can customize the options for the init-docker.sh initialization script your Docker environment. For example, you can specify the PHP version (default is 7.2) and the Magento Cloud Docker Docker image (default 1.1). We recommend using the latest version. Run the following command to see the available options:

    1
    
    curl https://raw.githubusercontent.com/magento/magento-cloud-docker/<package-version>/bin/init-docker.sh | bash -s -- --help
    
  4. In your local environment, start the Docker configuration generator. You can use the service keys, such as --php, to specify a version.

    1
    
    ./vendor/bin/ece-docker build:compose
    
  5. Optional: If you have a custom PHP configuration file, copy the default configuration DIST file to your custom configuration file and make any necessary changes.

    1
    
    cp .docker/config.php.dist .docker/config.php
    
  6. Build files to containers and run in the background.

    1
    
    docker-compose up -d
    
  7. Install Magento in your Docker environment.

    • Build Magento in the Docker container.

      1
      
      docker-compose run --rm build cloud-build
      
    • Deploy Magento in the Docker container.

      1
      
      docker-compose run --rm deploy cloud-deploy
      
    • Run post-deploy hooks.

      1
      
      docker-compose run --rm deploy cloud-post-deploy
      
  8. Configure and connect Varnish.

    1
    
    docker-compose run --rm deploy magento-command config:set system/full_page_cache/caching_application 2 --lock-env
    
    1
    
    docker-compose run --rm deploy magento-command setup:config:set --http-cache-hosts=varnish
    
  9. Clear the cache.

    1
    
    docker-compose run --rm deploy magento-command cache:clean
    
  10. Optional: Restart services if the static content does not synchronize with all images after generation on build phase.

    1
    
    docker-compose restart
    
  11. Access the local Magento Cloud template by opening one of the following URLs in a browser: