8000 GitHub - artpi/wp-local-docker: A simple Docker based development environment for WordPress.
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

artpi/wp-local-docker

 
 

Repository files navigation

WordPress Docker Development Environment

This is a Docker based local development environment for WordPress. It is designed to be used with a production site. It contains a docker image - virtual environment to run Wordpress installation the same way on all computers. It also contains an assortment of scripts that can be ran in this virtual environment. These tools help to keep your WordPress instalation in GIT.

This repository runs the site on your local computer. You will be able to develop site without internet - and what is more important - without a risk of breaking production.

Developing WordPress

All the files you should concern yourself about are in ./wp-content. There is a most recent Database dump in ./db-dump/production-dump.sql.

Setup with an existing production site.

  1. Make sure you have Docker toolbox for windows (important: select 'install git for windows' during installation. You will need GIT as well) or Docker for mac installed.
  2. After docker installation restart computer please.
  3. Windows only: Docker installs "Oracle VM Virtualbox Manager". Open it,
    • Go to Settings->Network->Advanced->Port Forwarding
    • Set up a rule with Host IP 127.0.0.1, Host port 80 and guest port 80
    • Image here
    • if "default" image is running, stop it and start it
  4. Open "Docker quickstart terminal" on Win or Terminal.app on mac.
  5. Set up your SSH Github, Bitbucket. Add keys to your account where this repository is.
  6. Navigate to where you want to have your project on disk using cd command. Example: cd /c/Users/artpi/Desktop/project in case of windows and "Docker quickstart terminal"
  7. git clone https://github.com/artpi/wp-local-docker
  8. cd wp-local-docker
  9. docker-compose up -d
  10. Set up databases and WordPress
    • Enter the container: docker-compose exec --user www-data phpfpm bash
    • Set everything up: /var/scripts/setup.sh
  11. Once everything is set up, you can see the site under http://localhost

Multisite.

If you have a multisite, the short tutorial is:

  1. docker-compose up
  2. docker-compose exec --user www-data phpfpm /var/scripts/setup.sh
  3. Now you have to edit wordpress/wp-config.php
// This is assuming you have your whole network under `artpi.pl`

define( 'WP_ALLOW_MULTISITE', true );
define( 'MULTISITE', true );
define( 'SUBDOMAIN_INSTALL', true );
$base = '/';
define( 'PRODUCTION_DOMAIN_CURRENT_SITE', 'artpi.pl' );
define( 'DOMAIN_CURRENT_SITE', 'dev.local' );
define( 'PATH_CURRENT_SITE', '/' );
define( 'SITE_ID_CURRENT_SITE', 1 );
define( 'BLOG_ID_CURRENT_SITE', 1 );
  1. Add 127.0.0.1 dev.local and 127.0.0.1 subdomain.dev.local for every subdomain in /etc/hosts
  2. Now run docker-compose exec --user www-data phpfpm /var/scripts/import-db-from-prod-dump.sh to set up everything.
  3. You are good.

Running scripts on container

There are some scripts in bin/docker directory. To run them, you have to enter the virtual machine command line: docker-compose exec --user www-data phpfpm bash

And then you can just run them /var/scripts/scriptname.

Advanced tools

Rebasing