Run Drupal and WordPress on Quant Cloud
The app-drupal, app-drupal-cms and app-wordpress templates run a CMS as a Quant Cloud application. Create the application with a managed database. This page covers what is specific to a CMS. For the compose file, variables and cron in general, see the Quant Cloud guides.
Database
Section titled “Database”Quant Cloud sets DB_HOST, DB_PORT, DB_DATABASE, DB_USERNAME and DB_PASSWORD in the environment. The Drupal templates read them in settings.php. The WordPress template maps them to the WORDPRESS_DB_* variables at start-up, and its wp command does the same, so wp works in a one-off command and in a cron job. Do not set DB_* values in the environment: section of the compose file you deploy: they replace the values the platform sets.
Files that must persist
Section titled “Files that must persist”Files that editors create must be on a volume. Anything else in the container is replaced at the next deploy. A volume is shared by every task of the environment.
| Template | Volume |
|---|---|
app-drupal |
./src/web/sites/default/files:/opt/drupal/web/sites/default/files |
app-drupal-cms |
drupal_cms:/opt/drupal (the whole code base, so the update UI works) |
app-wordpress |
./wp-content:/var/www/html/wp-content and wordpress_data:/var/www/html |
Keep these entries in docker-compose.yml, not in docker-compose.override.yml, which is for local use. On app-drupal-cms and app-wordpress the volume keeps its files when you rebuild the image. Code from a new image does not replace code already on the volume, so update WordPress and Drupal CMS inside the environment. On the first start of app-drupal-cms the code is copied onto the volume, which takes a few minutes and shows a placeholder page.
Set QUANT_SMTP_HOST, QUANT_SMTP_PORT (default 587), QUANT_SMTP_USERNAME, QUANT_SMTP_PASSWORD (as a secret), QUANT_SMTP_FROM and QUANT_SMTP_FROM_NAME on the environment. When QUANT_SMTP_HOST is set, the image starts a mail relay and PHP mail() sends through your SMTP provider. Set QUANT_SMTP_RELAY_ENABLED=true to use the full Postfix relay, and QUANT_SMTP_FROM_DOMAIN to set its domain. The WordPress template uses QUANT_SMTP_FROM and QUANT_SMTP_FROM_NAME as the default From address and name.
Create a Cron Job in Quant Cloud for scheduled work:
- Drupal:
drush cron. - WordPress:
wp cron event run --due-now --allow-root. Also setWORDPRESS_CONFIG_EXTRAtodefine('DISABLE_WP_CRON', true);so page views do not start WP-Cron. The official WordPress image readsWORDPRESS_CONFIG_EXTRA, notWP_CONFIG_EXTRA. The variable applies only whenwp-config.phpis first created. For an existing environment runwp config set DISABLE_WP_CRON true --raw --allow-rootwithqc exec run.
A cron job or one-off command runs in a separate container without a web server. A task that needs the Quant “Webserver URL”, such as a seed, must run inside the live container (qc ssh).
Host names behind the proxy
Section titled “Host names behind the proxy”The proxy sends the visitor’s host name to the application.
- Drupal:
$settings['trusted_host_patterns']insrc/settings.phplists only the platform host names. Add your domain, for example'^www\.example\.com$', then deploy. If you do not, Drupal answers “The provided host name is not valid for this server”. Onapp-drupal-cmsthe file was copied onto the volume on first start, so also edit/opt/drupal/web/sites/default/settings.phpin the environment. - WordPress: the template sets
WP_HOMEandWP_SITEURLfrom the request host and treatsX-Forwarded-Proto: httpsas HTTPS, so you do not set the URL per domain.
To serve your own domain, follow Releasing your application on a custom domain. Leave “Cache lifetime” empty so the CMS decides caching, and use 0 for login and admin paths.
Push a static copy as well
Section titled “Push a static copy as well”You can install the Drupal module or WordPress plugin in the Quant Cloud application and push a static copy to a Quant project. Set the Webserver URL to http://localhost and the host header to the public domain. The WordPress template reads the plugin settings from these variables when they are set, and they replace the saved settings on every request: QUANT_ENABLED, QUANT_API_ENDPOINT, QUANT_CUSTOMER, QUANT_PROJECT, QUANT_TOKEN, QUANT_WEBSERVER_URL, QUANT_WEBSERVER_HOST, QUANT_DISABLE_TLS_VERIFY and QUANT_HTTP_REQUEST_TIMEOUT.
