Skip to content
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

Add setup-domain-multistore script #697

Open
wants to merge 13 commits into
base: master
Choose a base branch
from

Conversation

TerrorSquad
Copy link

@TerrorSquad TerrorSquad commented Apr 26, 2022

I've added a number of files that would allow implementing this script. I think this is a bit rough, so please suggest improvements.

The idea is to first set up a project locally by following the README file. Once the project is up you should do the following steps:

  1. Run the bin/setup-domain-multistore script
  2. Uncomment the two new bind mounts in docker-compose.linux.yml file
  3. Restart the app service
  4. Run sudo bin/add-base-urls-to-hosts

Notes:

  • In order to get the multistore setup working, I have included the latest nginx.conf (config/nginx/nginx.conf.sample) and I've added the config/nginx/default.conf file (contents taken from dev docs).
    - To fetch the data from store table I added a small SQL file that defines the JSON_ARRAYAGG function. The reason for that is: in some older mysql/mariadb versions the function is not available.
    - store data is later parsed with jq in helper scripts (INTRODUCES jq as a dependency)

I used jq mainly because I wanted a json structure that I could work with in the bash scripts.

Resolves #696

@rangerz
Copy link
Contributor

rangerz commented Apr 27, 2022

jq is working on MacOS, but other OS may require additional installation.

Another general way to execute command in the container, ex: PHP

bin/n98-magerun2 dev:console '$a = 1; call cache:flush; ls; exit;'

@TerrorSquad
Copy link
Author

@rangerz I could then do this bin/n98-magerun2 sys:store:list --format=json | grep -iv warning | jq. It will simplify things quite a bit a remove the need for SQL code.

@TerrorSquad TerrorSquad marked this pull request as ready for review April 27, 2022 10:33
@rangerz
Copy link
Contributor

rangerz commented Apr 27, 2022

@TerrorSquad Good, it's simpler !

But I think jq command should be removed.

Be replaced by common bash command

# for example
STORE_ID=$(bin/n98-magerun2 sys:store:list --format=csv | tail -n + 2 | cut -d ',' -f1)
STORE_CODE=$(bin/n98-magerun2 sys:store:list --format=csv | tail -n + 2 | cut -d ',' -f2)

@TerrorSquad
Copy link
Author

@rangerz I've refactored the code to be in line with your example.

@markshust
Copy link
Owner

Is it possible for you to update the readme with instructions on how to use this? Perhaps we can also make the config files contain "multistore" in the filenames, so it is apparent these are only intended for multistore setups?

@TerrorSquad
Copy link
Author

Hi @markshust I'll update it later today or tomorrow. Did you have the time to test it out?

@TerrorSquad
Copy link
Author

Hi @markshust I've updated the readme as well as the names of nginx config files. Since I am working on Linux and don't have a mac I wasn't able to test this out on a mac. Hopefully, it will work the same.

@markshust
Copy link
Owner

@TerrorSquad sorry it took so long for me to get back to this. I just ran shellcheck and it appears to be complaining about a few things. Can you take a look?

Notice: ./compose/bin/generate-store-setters:17:22: note: See if you can use ${variable//search/replace} instead. [SC2001]
Notice: ./compose/bin/generate-nginx-mapping:6:8: note: Expressions don't expand in single quotes, use double quotes for that. [SC2016]
Notice: ./compose/bin/generate-nginx-mapping:11:25: note: See if you can use ${variable//search/replace} instead. [SC2001]
Notice: ./compose/bin/add-base-urls-to-hosts:13:22: note: See if you can use ${variable//search/replace} instead. [SC2001]

@TerrorSquad
Copy link
Author

@markshust it should be all good now.

@markshust
Copy link
Owner

Appreciate it. I'm currently re-building the PHP images for NodeJS/NPM support, but will circle back around right after to actually test out this PR against those images, then make a subsequent release if all looks good.

@what-the-diff
Copy link

what-the-diff bot commented Dec 13, 2022

  • Added a new script bin/setup-multistore
  • Updated the README file with instructions on how to setup multistore projects
  • Created two files: compose/.gitignore, and config/nginx/default.conf. The first one is used by git, while the second one contains nginx configuration for multiple stores (see below).
  • Modified three scripts: bin/add-base-urls-to-hosts, bin/generate_store_setters and update_nginx_config in order to support multi store installations of Magento 2 using docker compose as development environment tooling (see below)
  • Added a new file nginx.conf.multistore.sample
  • Modified the existing file nginx.conf sample to include multistore configuration

@TerrorSquad
Copy link
Author

Hi @rangerz @markshust

Can you guys test this out and possible merge if it's working correctly?

@markshust
Copy link
Owner

@TerrorSquad wow it's been a while since I looked at this one.

I don't have time this week due to holidays and etc., but I'll try to circle back in a couple weeks unless someone else wants to test this all out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Automate configuration of multi store projects
3 participants