All Projects → sourcebroker → deployer-extended-wordpress

sourcebroker / deployer-extended-wordpress

Licence: MIT license
Deployer based deployment for WordPress with media and database synchronisation.

Programming Languages

PHP
23972 projects - #3 most used programming language

Projects that are alternatives of or similar to deployer-extended-wordpress

Deploy
Ansible role to deploy scripting applications like PHP, Python, Ruby, etc. in a capistrano style
Stars: ✭ 2,141 (+8820.83%)
Mutual labels:  deployment, deployer, deployments
deployer-php-action
Deploy PHP projects using Deployer from Github Actions
Stars: ✭ 57 (+137.5%)
Mutual labels:  deployment, deployer
deployer-extended-database
Deployer tasks to manage database synchronization between application instances.
Stars: ✭ 32 (+33.33%)
Mutual labels:  deployer, deployments
docker-deployer
Docker image for PHP Deployer.
Stars: ✭ 24 (+0%)
Mutual labels:  deployment, deployer
example-deployer-slim
Example project for deployment PHP project (Slim Framwork) by Deployer
Stars: ✭ 32 (+33.33%)
Mutual labels:  deployment, deployer
Github Pages Deploy Action
Automatically deploy your project to GitHub Pages using GitHub Actions. This action can be configured to push your production-ready code into any branch you'd like.
Stars: ✭ 2,507 (+10345.83%)
Mutual labels:  deployment, deployer
Fusioninventory For Glpi
FusionInventory plugin for GLPI
Stars: ✭ 241 (+904.17%)
Mutual labels:  deployment
Dynatrace-OneAgent-Ansible
This Ansible role installs Dynatrace OneAgent.
Stars: ✭ 34 (+41.67%)
Mutual labels:  deployment
Gradle Cargo Plugin
Gradle plugin that provides deployment capabilities to local and remote containers via Cargo
Stars: ✭ 238 (+891.67%)
Mutual labels:  deployment
Mason
Cross platform package manager for C/C++ apps
Stars: ✭ 230 (+858.33%)
Mutual labels:  deployment
slash-heroku
/heroku commands for slack
Stars: ✭ 37 (+54.17%)
Mutual labels:  deployment
vent
Vent is a light-weight platform built to automate network collection and analysis pipelines using a flexible set of popular open source tools and technologies. Vent is python-based, extensible, leverages docker containers, and provides both an API and CLI.
Stars: ✭ 73 (+204.17%)
Mutual labels:  deployment
versio
A version number manager
Stars: ✭ 63 (+162.5%)
Mutual labels:  deployments
Git Auto Deploy
Deploy your GitHub, GitLab or Bitbucket projects automatically on Git push events or web hooks
Stars: ✭ 251 (+945.83%)
Mutual labels:  deployment
buffalo-azure
A gobuffalo plugin for working with Azure.
Stars: ✭ 29 (+20.83%)
Mutual labels:  deployment
Ecspresso
ecspresso is a deployment tool for Amazon ECS
Stars: ✭ 242 (+908.33%)
Mutual labels:  deployment
kafkaer
Template based Kafka topic/cluster/ACL management
Stars: ✭ 37 (+54.17%)
Mutual labels:  deployment
Stretcher
Deployment tool with consul/serf event notification.
Stars: ✭ 232 (+866.67%)
Mutual labels:  deployment
deployment-controller
基于Fabric8模拟Kubernetes的Deployment实现一个Controller
Stars: ✭ 60 (+150%)
Mutual labels:  deployment
static-aws-deploy
A tool for deploying files to an AWS S3 bucket with configurable headers and invalidating AWS Cloudfront Objects.
Stars: ✭ 27 (+12.5%)
Mutual labels:  deployment

deployer-extended-wordpress

What does it do?

This package provides deploy task for deploying WordPress with deployer (deployer.org) and additionally a tasks to synchronize database and media files.

The deployment is simplified in order to have ability to auto-upgrade WordPress and upgrade plugins manually by admin panel (or automatically with tools like InfiniteWP). This is a half way between no deployment at all and deployment fully driven by composer. If you want to manage WordPress and plugins fully with composer then check https://roots.io/ and sourcebroker/deployer-extended-wordpress-composer.

Should I use "deployer-extended-wordpress" or "deployer-extended-wordpress-composer"?

In sourcebroker/deployer-extended-wordpress the WordPress and third party plugins are installed manually. What you have in GIT is basically only your theme/plugins/muplugins. The good thing is that in such case you can update WordPress and plugins automatically. This can be considered as preferable for low budget WordPress websites.

In sourcebroker/deployer-extended-wordpress-composer the WordPress and third party plugins are installed using composer. This way you gain more control over what is installed but at the same time to install new WordPress or new plugin version you need first to modify composer.json or do composer update (depending how big upgrade you do). Then you need to commit composer.json / composer.lock and do deploy which will install new version of WordPress and plugins. This is additional work that can not be easily automated. One of additional advantages of this solution is that you can easily cleanup infected WordPress/plugins files as with each deployment all php files are fresh (part from your GIT and part from composer repositories).

Dependencies

This package depends on following packages:

Installation

  1. Install package with composer:

    composer require sourcebroker/deployer-extended-wordpress
    
  2. Put following lines in your deploy.php:

    require __DIR__ . '/vendor/autoload.php';
    new \SourceBroker\DeployerExtendedWordpress\Loader();
    
  3. Remove task "deploy" from your deploy.php. Otherwise you will overwrite deploy task defined in deployer/deploy/task/deploy.php

  4. Example deploy.php file:

    <?php
    
    namespace Deployer;
    
    require __DIR__.'/vendor/autoload.php';
    new \SourceBroker\DeployerExtendedWordpress\Loader();
    
    set('repository', 'git@my-git:my-project.git');
    
    host('live')
        ->setHostname('example.com')
        ->setRemoteUser('deploy')
        ->set('shared_files', array_merge(get('shared_files'), ['config/.env.live.local']))
        ->set('public_urls', ['https://www.example.com/'])
        ->set('deploy_path', '/var/www/example.com/live');
    
    host('beta')
        ->setHostname('example.com')
        ->setRemoteUser('deploy')
        ->set('shared_files', array_merge(get('shared_files'), ['config/.env.beta.local']))
        ->set('public_urls', ['https://beta.example.com/'])
        ->set('deploy_path', '/var/www/example.com/beta');
    
    host('dev')
        ->set('public_urls', ['https://example-com.ddev.site/'])
        ->set('deploy_path', getcwd());
    

Mind the declaration of host('dev'); Its needed for database tasks to declare domain replacements, and path to store database dumps.

Project's folders structure

This deployment has following assumptions:

  1. WordPress source code is not in GIT in order to have ability to easily upgrade them from admin panel.

  2. wp-content/plugins should be most out of GIT to in order to have ability to easily upgrade them from admin panel. You can have however some plugins in GIT if you like.

  3. wp-content/mu-plugins can be partially out of GIT but you can also have plugins there which are in GIT.

  4. config/environments and use of wp-config and .env idea is back ported from bedrock and extended with idea of symfony/dotenv

  5. Taking the above points into consideration the only files in GIT will be:

    /config/environments/development.php
    /config/environments/staging.php
    /config/application.php
    /config/.env
    /config/.env.beta
    /config/.env.dev
    /config/.env.live
    /config/.env.dev.local.dist
    /config/.htaccess
    /wp-content/plugins/my-plugin-in-git
    /wp-content/mu-plugins/my-mu-plugin.php
    /wp-content/themes/my-theme/
    .gitignore
    deploy.php
    composer.lock
    composer.json
    wp-config.php
    

Mind .env.beta, .env.dev, .env.live - those files stores data which is specific per instance but can be stored in git. For example database name, database user, database host, SMTP settings (without passwords). The passwords should be stored in file which is out of git on each of the instance host .env.beta.local, .env.dev.local, .env.live.local or if you do not mind so much about security you can store them also in git.

You need also to add shared local env file per instance. You can do it like this. Look at line 4:
host('live')
 ->setHostname('example.com')
 ->setRemoteUser('deploy')
 ->set('shared_files', array_merge(get('shared_files'), ['config/.env.live.local']))
 ->set('public_urls', ['https://www.example.com/'])
 ->set('deploy_path', '/var/www/example.com/live');

The only required, out of git file on instance is /config/.env.local where you set info what instance it is. The content of /config/.env.local should be only WP_INSTANCE='live' etc depending on which instance it is.

Look at sourcebroker/wordpress-starter for example how you can use in your WordPress.

The shared dirs defined in deployer/set.php are:
set('shared_dirs', [
        'wp-content/uploads',
        'wp-content/languages',
        'wp-content/upgrade',
    ]
);
The shared files defined in ``deployer/set.php``are:
set('shared_files', [
    '.htaccess',
    'config/.env.local',
]);

Composer

You can set proper version of composer with composer_channel (values: 1, 2, stable, prelive, snapshot) or with composer_version which takes exact tags as arguments (https://github.com/composer/composer/tags). For stability and security its advised that you set composer_channel with value 1 or 2 so it will be automatically updated but will not install any new major version in future so your deploy will remain fairly stable.

set('composer_channel', 2);

Synchronizing database

Database synchronization is done with sourcebroker/deployer-extended-database. Example of command for synchronizing database from live to local instance:

dep db:pull live

Domain replacement

The "post_command" task "db:import:post_command:wp_domains" will change domains declared in "public_urls". Domain replacement is done with cli command "search-replace" from wp-cli/wp-cli.

Please mind to have the same amount of "public_urls" for each of instances because replacement on domains is done for every pair of corresponding urls.

Look at following example to give you idea:

host('live')
    ->setHostname('example.com')
    ->setRemoteUser('deploy')
    ->set('shared_files', array_merge(get('shared_files'), ['config/.env.live.local']))
    ->set('public_urls', ['https://www.example.com', 'https://sub.example.com'])
    ->set('deploy_path', '/var/www/example.com.live');

host('beta')
    ->setHostname('example.com')
    ->setRemoteUser('deploy')
    ->set('shared_files', array_merge(get('shared_files'), ['config/.env.live.local']))
    ->set('public_urls', ['https://beta.example.com', 'https://beta-sub.example.com'])
    ->set('deploy_path', '/var/www/example.com.beta');

host('dev')
    ->set('public_urls', ['https://example-com.ddev.site', 'https://sub-example-com.ddev.site'])
    ->set('deploy_path', getcwd());

The if you will do:

dep db:pull live

the following commands will be done automatically after database import:

wp search-replace https://www.example.com https://example-com.dev
wp search-replace https://sub.example.com https://sub-example-com.dev

Configuration

Mind that "deploy.php" file must be the same on all instance before you can start to do database synchronization.

Synchronizing media & WordPress / plugins code

Media synchronization is done with package sourcebroker/deployer-extended-media. The command for synchronizing media & php files which are out of git is:

dep media:pull live

Because we do not use composer to get WordPress and plugins therefore we will treat here code of WordPress and plugins as kind of media to synchronize. This is a bit o misuse of sourcebroker/deployer-extended-media but if we think of media as part of project which is out of git that needs to be synchronized between instances then our WordPress and plugins php code which is also out of git is bunch of files that needs to be synchronized between instances.

Therefore our config to synchronize files media & WordPress / plugins code looks like this:

set('media',
    [
        'filter' => [
            '+ /wp-content/',
            '- /wp-content/mu-plugins/*',
            '- /wp-content/themes/*',
            '+ /wp-content/**',
            '+ /wp-admin/',
            '+ /wp-admin/**',
            '+ /wp-includes/',
            '+ /wp-includes/**',
            '+ .htaccess',
            '+ wp-activate.php',
            '+ wp-blog-header.php',
            '+ wp-comments-post.php',
            '+ wp-config-sample.php',
            '+ wp-config.php',
            '+ wp-cron.php',
            '+ wp-links-opml.php',
            '+ wp-load.php',
            '+ wp-login.php',
            '+ wp-mail.php',
            '+ wp-settings.php',
            '+ wp-signup.php',
            '+ wp-trackback.php',
            '+ xmlrpc.php',
            '+ index.php',
            '- *'
        ]
    ]);
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].