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 lando config #1973

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,4 @@ sftp-config.json
*.sublime-workspace
.phpintel
selenium-debug.log
.lando.wp-cli.yml
.lando.yml
/wordpress
96 changes: 96 additions & 0 deletions .lando.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
name: rtmedia
recipe: wordpress
config:
via: nginx
php: "8.0"
webroot: wordpress
database: mariadb
# Keep it empty, to enable xdebug use `lando xdebug <xdebug mode>` instead
xdebug: ""
config:
php: .lando/php.ini
database: .lando/mysql.cnf
vhosts: .lando/nginx.conf
services:
database:
volumes:
mariadb: { }
type: compose
creds:
user: wordpress
password: wordpress
database: wordpress
services:
image: mariadb:10.6.5
command: docker-entrypoint.sh mariadbd
volumes:
- mariadb:/var/lib/mysql
environment:
MARIADB_ALLOW_EMPTY_ROOT_PASSWORD: 1
MARIADB_DATABASE: wordpress
MYSQL_DATABASE: wordpress
MARIADB_USER: wordpress
MARIADB_PASSWORD: wordpress
rediscache:
type: redis
mailhog:
type: mailhog
portforward: false
hogfrom:
- appserver
appserver:
overrides:
environment:
# Support debugging Drush with XDEBUG.
PHP_IDE_CONFIG: "serverName=appserver"
PROFILER_OUTPUT_DIR: "profiler-output" # If changing this value, change in .gitignore also
volumes:
- '.lando/wp-cli.yml:/wp-cli.yml'
- './mu-plugins:/app/wordpress/wp-content/mu-plugins'
- './plugins:/app/wordpress/wp-content/plugins'
- './rt-config:/app/wordpress/wp-content/rt-config'
- './themes:/app/wordpress/wp-content/themes'
- './uploads:/app/wordpress/wp-content/uploads'
build_as_root:
- curl -sL https://deb.nodesource.com/setup_14.x | bash -
- apt-get install -y nodejs
build:
- wp core download --force --skip-content
run:
- sleep 5 # For some reason, we have to wait at least a second till database is up.
- | # Create WordPress config file and add necessary constants and custom config
wp config create --dbhost=database --dbname=wordpress --dbuser=wordpress --dbpass=wordpress --dbprefix=wp_ --force --extra-php <<PHP
if ( file_exists( __DIR__ . '/wp-content/rt-config/rt-config.php' ) ) {
require_once( __DIR__ . '/wp-content/rt-config/rt-config.php' );
}
PHP
- wp config set WP_DISABLE_FATAL_ERROR_HANDLER true --raw
- wp config set WP_DEBUG true --raw
- wp config set WP_DEBUG_LOG true --raw
- wp config set WP_DEBUG_DISPLAY false --raw
- wp config set AUTOMATIC_UPDATER_DISABLED true --raw
- wp config set DISALLOW_FILE_EDIT true --raw
- wp config set WP_ENVIRONMENT_TYPE 'local'
- wp config set WP_REDIS_HOST rediscache
- | # Let's check if WordPress is not installed, then install it
if ! wp core is-installed; then
wp core install --url=https://$LANDO_APP_NAME.$LANDO_DOMAIN \
--title=$LANDO_APP_NAME \
--admin_user=rtcamp \
--admin_password=goodwork \
[email protected] \
--skip-email
wp theme install --activate twentytwentyone
wp plugin install --activate redis-cache
wp redis enable
fi
tooling:
xdebug:
description: Loads Xdebug in the selected mode.
cmd:
- appserver: /app/.lando/xdebug.sh
user: root
node:
service: appserver
npm:
service: appserver
16 changes: 16 additions & 0 deletions .lando/mysql.cnf
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[mysqld]
disable_log_bin
innodb_buffer_pool_size = 1G
innodb_buffer_pool_instances = 1
max_heap_table_size = 64M
collation_server = utf8mb4_unicode_ci
character_set_server = utf8mb4
innodb_flush_log_at_trx_commit=0
innodb_flush_log_at_timeout=10
innodb_doublewrite=off
innodb_fast_shutdown=0
join_buffer_size=20M
sort_buffer_size=2M
read_rnd_buffer_size=20M
innodb_flush_method=O_DIRECT_NO_FSYNC
innodb_io_capacity=4000
84 changes: 84 additions & 0 deletions .lando/nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
# WordPress single site rules. Custom
# Designed to be included in any server {} block.

# Upstream to abstract backend connection(s) for php
upstream php {
server fpm:9000;
}

server {

listen 80 default_server;
listen 443 ssl;

server_name localhost;

ssl_certificate /certs/cert.crt;
ssl_certificate_key /certs/cert.key;
ssl_verify_client off;

ssl_session_cache shared:SSL:1m;
ssl_session_timeout 5m;

ssl_ciphers HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;

port_in_redirect off;
client_max_body_size 100M;

## Your only path reference.
root "/app/wordpress";

## This should be in your http block and if it is, it's not needed here.
index index.php;

location @dynamiccycletour {
# IP of production site
proxy_pass https://10.0.0.1;
# Hostname of production site
proxy_set_header Host example.com;
}

location ~ "^(.*)/wp-content/uploads/(.*)$" {
access_log off;
error_page 404 = @dynamiccycletour;
location ~ \.php$ {
#Prevent Direct Access Of PHP Files From Web Browsers
deny all;
}
}

location = /favicon.ico {
log_not_found off;
access_log off;
}

location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}

location / {
# This is cool because no php is touched for static content.
# include the "?$args" part so non-default permalinks doesn't break when using query string
try_files $uri $uri/ /index.php?$args;
}

location ~ \.php$ {
#NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_TRANSLATED $document_root$fastcgi_script_name;
include fastcgi_params;
fastcgi_intercept_errors on;
fastcgi_pass php;
fastcgi_buffers 16 16k;
fastcgi_buffer_size 32k;
}

location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
expires max;
log_not_found off;
}

}
2 changes: 2 additions & 0 deletions .lando/php.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
memory_limit = 1G
xdebug.start_with_request = trigger
1 change: 1 addition & 0 deletions .lando/wp-cli.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
path: /app/wordpress
26 changes: 26 additions & 0 deletions .lando/xdebug.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/bash

if [ "$#" -ne 1 ] || [ "$1" = "off" ]; then
echo "Xdebug has been turned off, please use the following syntax: 'lando xdebug <mode>'."
echo "Valid modes: https://xdebug.org/docs/all_settings#mode."
echo xdebug.mode = off > /usr/local/etc/php/conf.d/zzz-lando-xdebug.ini
if [ -f "/usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini" ]; then
rm /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
fi
pkill -o -USR2 php-fpm
else
mode="$1"
echo xdebug.mode = "$mode" > /usr/local/etc/php/conf.d/zzz-lando-xdebug.ini
if [ ! -f "/usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini" ]; then
docker-php-ext-enable xdebug
fi
if [[ $mode = *"profile"* ]]; then
if [ ! -d "$PROFILER_OUTPUT_DIR" ]; then
mkdir "$PROFILER_OUTPUT_DIR"
chown $LANDO_HOST_UID:$LANDO_HOST_GID "$PROFILER_OUTPUT_DIR"
fi
echo xdebug.output_dir = "/app/$PROFILER_OUTPUT_DIR" >> /usr/local/etc/php/conf.d/zzz-lando-xdebug.ini
fi
pkill -o -USR2 php-fpm
echo "Xdebug is loaded in "$mode" mode."
fi