Skip to content

MCLOUD-5511: Add Multi-website Support into Cloud Docker #167

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Mar 19, 2020

Conversation

mohanelamurugan
Copy link
Contributor

@mohanelamurugan mohanelamurugan commented Mar 12, 2020

Description

Added multi website support in cloud docker(Appended magneto-vars.php to php.ini) .

https://jira.corp.magento.com/browse/MCLOUD-5511:

  1. Start the magento cloud docker, set to developer deploy mode following this tutorial: https://devdocs.magento.com/guides/v2.3/cloud/docker/docker-config.html
  2. Set up a new website, store, store view and use this tutorial to set up a new website: https://devdocs.magento.com/guides/v2.3/cloud/project/project-multi-sites.html
  3. Assuming we plan to have http://second.magento2.docker/ for the new website that we are adding, Add second.magento2.docker to hosts file.
  4. Visit http://second.magento2.docker/

Fixed Issues (if relevant)

MCD-104

Manual testing scenarios

  1. Add both websites base url to hosts
  2. Visit each website's URL from browser
  3. Secondary website URL should redirect to the secondary website instead of redirecting to the base website's URL.

Contribution checklist

  • Pull request has a meaningful description of its purpose
  • All commits are accompanied by meaningful commit messages

@@ -7,3 +7,4 @@ always_populate_raw_post_data = -1
max_input_vars = 10000
session.gc_probability = 1
opcache.enable = 1
auto_append_file = /app/magento-vars.php
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add new line

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added. Pls review again

@andriyShevtsov
Copy link
Contributor

Created internal task MAGECLOUD-5584

@shiftedreality
Copy link
Member

shiftedreality commented Mar 17, 2020

To run in Production mode:

  1. Create file docker-compose.override.yaml:
version: '2.1'
services:
  web:
    volumes:
      - './magento-vars.php:/app/magento-vars.php:ro'

@andriyShevtsov
Copy link
Contributor

@shiftedreality Please take a look. With production mode and docker-compose.override.yaml I have error
Fatal error: Cannot redeclare isHttpHost() (previously declared in /app/magento-vars.php:20) in /app/magento-vars.php on line 20

@shiftedreality
Copy link
Member

shiftedreality commented Mar 18, 2020

@andriyShevtsov it looks like the trick with docker-compose.override.yml is not needed. This issue somehow relates to Docker itself and can be avoided by simple adjustment:

if (!function_exists('isHttpHost')) {
    function isHttpHost($host)
    {
        if (!isset($_SERVER['HTTP_HOST'])) {
            return false;
        }
        return strpos(str_replace('---', '.', $_SERVER['HTTP_HOST']), $host) === 0;
    }
}

@shiftedreality
Copy link
Member

I just realized it will break the default behavior.

@mohanelamurugan could you please check this PR in Production mode if you have the same problem?

@mohanelamurugan
Copy link
Contributor Author

mohanelamurugan commented Mar 18, 2020

Sure @shiftedreality , Let me check this

@mohanelamurugan
Copy link
Contributor Author

mohanelamurugan commented Mar 19, 2020

@shiftedreality

I didn't use the docker-compose.override.yml
I tested it in production mode. I was able to run deploys, post deploys, cache clean, index:reindex as well.
Also multi site redirections are also working fine.
The first one runs in the URL magento2.docker whereas the other one is second.magento2.docker.
Also from the attached image below, You can find that the setup is running in production mode.
PFA
Screen Shot 2020-03-19 at 4 45 47 PM
Screen Shot 2020-03-19 at 4 45 53 PM
Screen Shot 2020-03-19 at 5 18 08 PM

@andriyShevtsov
Copy link
Contributor

Thank you. Most likely that issue was not related to your PR. QA approved.

@shiftedreality shiftedreality merged commit 09533c9 into magento:develop Mar 19, 2020
@YPyltiai YPyltiai added the community PR/issue origin label Apr 22, 2020
@mveeramneni mveeramneni changed the title Add Multi-website Support into Cloud Docker MCLOUD-5511: Add Multi-website Support into Cloud Docker Apr 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants