Last active
January 2, 2023 18:42
-
-
Save laryn/3746763cd10ed3be4f652c4c3670acfd to your computer and use it in GitHub Desktop.
Opinionated Backdrop + XDebug Lando sandbox configuration file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Opinionated Lando + Backdrop + XDebug sandbox configuration file. | |
name: sandbox | |
# Use existing Backdrop recipe, then customise below. | |
recipe: backdrop | |
config: | |
# Where Backdrop resides, relative to this file. | |
webroot: web | |
# Prefer MariaDB over MySQL. | |
database: mariadb | |
# Optionally set specific PHP version. | |
php: '8.1' | |
services: | |
# Install phpMyAdmin. | |
phpmyadmin: | |
type: phpmyadmin | |
# Link it to the default database service (see `lando info`). | |
hosts: database | |
appserver: | |
webroot: web | |
xdebug: debug | |
config: | |
php: .vscode/php.ini | |
build_as_root: | |
# Install Backdrop Console (`bee`). | |
- wget -qO bee.zip https://github.com/backdrop-contrib/bee/archive/1.x-1.x.zip | |
- unzip -q bee.zip && rm bee.zip | |
- mv bee-1.x-1.x /usr/local/bin/bee | |
overrides: | |
environment: | |
XDEBUG_MODE: | |
database: | |
portforward: 3307 | |
tooling: | |
# Allow Bee and Drush to be run from any directory. | |
bee: | |
service: appserver | |
cmd: /usr/local/bin/bee/bee.php --root=/app/web | |
drush: | |
service: appserver | |
cmd: drush --root=/app/web --uri=http://sandbox.lndo.site | |
xdebug-on: | |
service: appserver | |
description: Enable xdebug for Apache. | |
cmd: rm -f /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini && docker-php-ext-enable xdebug && /etc/init.d/apache2 reload && echo "Xdebug enabled" | |
user: root | |
xdebug-off: | |
service: appserver | |
description: Disable xdebug for Apache. | |
cmd: rm -f /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini && /etc/init.d/apache2 reload && echo "Xdebug disabled" | |
user: root | |
phpunitdebug: | |
service: appserver | |
cmd: php -d xdebug.remote_port=9003 vendor/bin/phpunit | |
# Create a snapshot of the site. | |
snapshot: | |
service: appserver | |
description: Create a snapshot of the site | |
cmd: | |
- mysqldump --add-drop-database -Bu root -h database -P 3306 backdrop > /app/backdrop.sql | |
- gzip -f /app/backdrop.sql | |
- cd /app/web/files/config_* && tar -czf /app/config.tar.gz active | |
- echo 'Snapshot created successfully' | |
# Reset the site using the snapshot. | |
reset: | |
service: appserver | |
description: Reset the site using the snapshot | |
cmd: | |
- cd /app/web/files/config_* && rm -r active && tar -xzf /app/config.tar.gz | |
- gunzip /app/backdrop.sql.gz | |
- mysql -u root -h database -P 3306 backdrop < /app/backdrop.sql | |
- gzip -f /app/backdrop.sql | |
- echo 'Site reset successfully' | |
proxy: | |
# Add a custom sub-domain for phpMyAdmin. | |
phpmyadmin: | |
- db.sandbox.lndo.site |
Next I'd like to allow to specify the name of the snapshot to save or reset to, with backdrop
being the default. This should be fairly painless with https://docs.lando.dev/core/v3/tooling.html#options-driven-tooling
For example, on a contrib module repo that I've set up in Lando for testing, this would make an easy way to save/reset various configurations.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The database port number is optional but useful if you will be using the site a lot and want to be able to save a bookmark in a visual database application like BeeKeeper Studio.