Skip to content
This repository has been archived by the owner on Aug 18, 2021. It is now read-only.

Lando multisite support #31

Merged
merged 3 commits into from
Jul 31, 2020
Merged

Conversation

netsuso
Copy link
Contributor

@netsuso netsuso commented Jul 29, 2020

Add multisite support to the Lando dev environment.

There are two new commands:

  1. lando setup-multisite
    This will install the network and add the required tables for multisite Wordpress

  2. lando add-site --slug=<slug> --title="<title>"
    This adds a subsite that can be accessed on http://<slug>.vip-go-dev.lndo.site/.

Note: I'm using subdomain mode for multisite as it suits better for this use case. It know we use subdirectory mode in production (although we end up setting a different domain), but I don't know if this difference can have any consequence on functionality.

Suso Bravo-Alvarez added 3 commits July 29, 2020 11:52
New tooling commands created:
- lando setup-multisite  # Converts a single site installation into multisite
- lando add-site --slug=<slug> --title=<title>  # Creates a site
After adding multisite support for subdirectory mode, it was
easy to notice that it was actually the same as subdomain mode.
This way we avoid needing to change url options and the domain
in wp_blogs, and manually created sites will work directly
without changing their url.
The site title was being created with literal quotes ("VIP Go Dev"),
as --title="VIP Go Dev" was being quoted, but there was no need for that.
@netsuso netsuso requested a review from a team July 29, 2020 19:52
@@ -55,7 +55,7 @@ echo_heading "Installing WordPress $WP_VERSION"
wp core install \
--path=$LANDO_WEBROOT \
--url="http://vip-go-dev.lndo.site" \
'--title="VIP Go Dev"' \
--title="VIP Go Dev" \
--admin_user="vipgo" \
Copy link
Contributor Author

@netsuso netsuso Jul 29, 2020

Choose a reason for hiding this comment

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

I've removed these quotes as they were creating the WordPress site with the title "VIP Go Dev", quotes included

@brandon-m-skinner
Copy link
Contributor

Do we want to be able to revert to a single site or rely on ./vip-init.sh --destroy to make that happen?

@mjangda
Copy link
Member

mjangda commented Jul 30, 2020

Do we want to be able to revert to a single site

The process involves removing the multisite constants and (optionally) deleting the extra tables. Although, that's not a clean revert as I think the multisite process also adds some additional columns to some of the core tables as well.

I think --destroy should be good enough.

Aside: what would be interesting is the ability to have a multi-tenant version of vip-go-mu-dev so I could have multiple instances of it running (e.g. one multisite, one single site, etc.).

@netsuso
Copy link
Contributor Author

netsuso commented Jul 30, 2020

Agree on not being able to go back to single site installation, using --destroy should be enough for most cases.

Regarding the multi-tenant feature, I've just tested that lando can manage several projects, provided they have a different name. The proxy container is common to all of them, and it will redirect different lndo.site domains to the corresponding project (of course, these domains need to be different).

But apart from that, it doesn't support managing several projects from the same directory. I see two options:

  1. A wrapper script that should be run instead of lando. It receives an instance number and it builds a .lando.yml (or .lando.local.yml) for that instance and then executes lando (like lando-wrapper <instance_number> <lando_command>, e.g. lando-wrapper 2 wp shell)
  2. vip_init.sh creates a separate directory for every instance, where it clones all repos it needs (or maybe reuses them with symlinks), and creates a .lando.yml file in that directory (so no .lando.yml file in the root of vip-go-mu-dev). Then you just cd into that directory and can run normal lando commands.

I prefer the second option, as it has a better user experience: every instance has its own separate directory (that can be easily removed, including its cloned repos), and you can use the standard lando command instead of a wrapper.

@netsuso
Copy link
Contributor Author

netsuso commented Jul 30, 2020

I've pushed a quick PoC for the second option, you can find it here: #32 (and sorry for hijacking this PR)

Copy link
Contributor

@brandon-m-skinner brandon-m-skinner left a comment

Choose a reason for hiding this comment

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

Works great 👍

@brandon-m-skinner brandon-m-skinner merged commit 7e90207 into master Jul 31, 2020
@brandon-m-skinner brandon-m-skinner deleted the add/lando-multisite-support branch July 31, 2020 20:09
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants