documentation/creating-new-drutopia-site.md

115 lines
5.6 KiB
Markdown
Raw Normal View History

2020-06-22 20:46:43 +00:00
# Deploying Drutopia Sites
Agaric manages a large number of Drupal, primarily [Drutopia](https://drutopia.org/) sites, on a
2020-06-23 00:08:33 +00:00
Please see [the Drutopia Platform README for an overview of hosting and deploying Drutopia sites](https://gitlab.com/drutopia-platform/drutopia_host#introduction )
2020-06-23 14:30:17 +00:00
If you won't be deploying, skip overall setup.
2020-06-23 16:44:26 +00:00
Following this guide requires a working [DDEV](https://ddev.readthedocs.io/en/latest/) installation.
2020-06-23 00:08:33 +00:00
## Overall setup
Strongly recommended to set up locally like this:
```
2020-06-23 14:30:17 +00:00
mkdir -p ~/Projects/drutopia-platform
cd ~/Projects/drutopia-platform
git clone git@gitlab.com:drutopia-platform/build_source.git
git clone git@gitlab.com:drutopia-platform/drutopia_host.git
cd drutopia_host
git clone git@gitlab.com:drutopia-platform/build_artifacts.git
git clone git@gitlab.com:drutopia-platform/hosting_private.git
```
2020-06-23 14:30:17 +00:00
```note
These last two repositories are private to Agaric and others maintaining the Drutopia platform, so if you're following along at home you'll have to create your own analogs, per [the documentation](https://gitlab.com/drutopia-platform/drutopia_host#introduction).
```
2020-06-23 14:30:17 +00:00
Commands for copying throughout will assume this above setup.
2020-06-22 20:46:43 +00:00
## Create a new site project
Ordinarily this will live under https://gitlab.com/agaric/sites (for Agaric clients) or https://gitlab.com/drutopia-platform/sites (for direct Drutopia platform members).
2020-06-23 14:48:43 +00:00
Copy the composer.json used by the appropriate build source, such as the [default build source for the Drutopia Platform](https://gitlab.com/drutopia-platform/build_source).
Replace "example" below with name of the site, usually derived from the main domain name, for instance `example-com`:
2020-06-23 14:48:43 +00:00
```
MY_SITE="example"
mkdir -p ~/Projects/agaric/sites/$MY_SITE
cd ~/Projects/agaric/sites/$MY_SITE
2020-06-23 14:48:43 +00:00
```
Once you have created and are in this directory, whether `agaric/sites` or `drutopia-platform/sites` or wherever you want your project to live within the GitLab namespace, you can copy-paste these commands for a quick start:
```
wget https://gitlab.com/drutopia-platform/build_source/-/raw/master/composer.json
wget https://gitlab.com/drutopia-platform/build_source/-/raw/master/.gitignore
2020-06-23 14:48:43 +00:00
ddev config --docroot=web --project-type=drupal8 --webserver-type=apache-fpm --mariadb-version=10.1 --php-version=7.3 --xdebug-enabled=true --use-dns-when-possible=false
```
```note
2020-06-23 16:44:26 +00:00
Webserver, PHP, and MySQL versions and types are selected here to match those used on Elizabeth and should be adjusted to match your live environment, including double-checking that they are still valid for `elizabeth.mayfirst.org`. Please update this documentation if it changes! The last two options (enabling Xdebug by default and not using DNS for your local site) are optional at the developer's preference. Additional ddev options can be found at https://ddev.readthedocs.io/en/latest/users/cli-usage/
```
## Acquiring a database and configuration for the live instance
In order to get a configuration that has the proper site key, it is easiest to first deploy the site to the production location, and sync that database locally.
If you are creating a specialized build of Drutopia, you will have to add that to the host vars, and build that prior to deploying the site. `ahoy vars-edit` and `ahoy deploy-build <build_target>` are used for this. Note that new builds should be added ONLY as absolutely required. Configuration, and themes should be leveraged as much as possible prior to resorting to a new build. If additional/different modules are required, a new build is required - do *NOT* add them to build_source except when they are known to be required for *ALL* Drutopia basic sites.
Create a new site (member entry) per instructions in Drutopia hosting, and use `ahoy deploy-site <sitename>` to deploy it. This should install the site, when one is not present.
### Configure drush aliases
2020-06-23 16:41:58 +00:00
The [drush site aliases file](https://github.com/drush-ops/drush/blob/9.5.x/examples/example.site.yml) can be used to provide easy access to the live/test instances of a site. From the root of your project directory (e.g. `agaric/sites/example/`), you may create one with:
```
MY_SITE="example-com"
SERVER="drutopia.org"
mkdir -p drush/sites/
cat << EOF > drush/sites/self.site.yml
live:
host: ${SERVER}
paths:
drush-script: /home/${MY_SITE/-/_}_live/site/vendor/bin/drush
root: /home/${MY_SITE/-/_}_live/site/web
uri: 'https://${MY_SITE}-live.drutopia.org/'
user: ${MY_SITE/-/_}_live
test:
host: ${SERVER}
paths:
drush-script: /home/${MY_SITE/-/_}_test/site/vendor/bin/drush
root: /home/${MY_SITE/-/_}_test/site/web
uri: 'https://${MY_SITE}-test.drutopia.org/'
user: ${MY_SITE/-/_}_test
EOF
```
This will create a self.site.yml using the expected pattern of "site_name_INSTANCE" (e.g. example_com_live for the example-com live instance). Supply the URL form of the site name for the MY_SITE variable (i.e. with dashes, rather than underscores).
### Syncing, and setting up configuration
Drutopia releases will expect the configuration in `$project_root/config/sync`. Be sure to set the appropriate variable in settings.ddev.yml (or settings.php) for it to be stored/retrieved from there:
```
$settings['config_sync_directory'] = '../config/sync';
```
Once you also have a working Drush installation and a live instance, you can then aquire and export the initial configuration with:
```
ddev . drush sql-sync @live @self
ddev . drush -y cex
```
Similarly, you can get live data and files down to your local development environment any time with:
```
ddev . drush -y sql-dump > data/paranoia.sql
ddev . drush -y sql-drop
ddev . drush -y sql-sync @live @self
ddev . drush -y rsync @live:%files @self:%files
```