Giter VIP home page Giter VIP logo

existing-wordpress-development-docker's Introduction

Existing WordPress site development - Docker

Expanded from https://github.com/lumonald/existing-wordpress-development-docker. Minor changes to ports, specify new URL, and addition of phpMyAdmin.

Brings up an existing WordPress site from wp-content and a MySQL backup. Allows changing the configured URL, which speeds up developing on a local machine or easily switching domains. By default it will start on http://localhost:8000 for local preview.

Requires Docker and docker-compose. Since the wordpress image includes an Apache webserver it would be possible to pare this down further e.g. by exposing the container on default web port 80, but to avoid conflicts and allow deployment with an nginx proxy the default port is 8000.

The docker-compose.yml file defines 2 containers -

  • wordpress - for the website files.
  • db - for the associated MySQL database.

In addition, docker-compose-phpmyadmin.yml starts a phpMyAdmin interface to interact with the database. To run this alongside the site, use e.g:

docker-compose -f docker-compose.yml -f docker-compose-phpmyadmin.yml up 

The wordpress container has 2 volumes -

  1. The site/wp-content folder - Copy the wp-content folder from the production site. It's used for all customisations outside of the core WordPress code. This includes the themes, plugins, uploads etc.

  2. init/prep.sh - Disables plugins as defined in the .env file. It also makes the wp-content folder the same owner/group as the rest of the site.

Note: The wp-config.php file gets auto generated for this local WordPress instance.

The db container has 3 volumes -

  1. database - A folder for all of the MySQL files, this gets automatically generated by docker and can remain untouched for average usage.

  2. mysqldumps/backup.sql.gz - This is a snapshot taken from the production instance via mysqldump, place the file in this location and it will get imported on the first run of the container automatically.

  3. init/migrate.sh - A URL migration script, this updates the URL stored in the database, this also gets run automatically when the containers are spun up for the first time.

Usage

  1. Clone or download this project.

  2. Create a mysqldump from your pre-existing site and place in location: mysqldumps/backup.sql.gz (ensure file is named backup.sql.gz)

  3. Obtain copy of wp-content folder from pre-existing site and place in location: site/wp-content

  4. Copy env-template as .env and enter your configuration variables.

  5. Navigate to the root of this project locally and run:

    docker-compose up -d && docker-compose exec wordpress prep.sh

  6. For additional insight into the database, optionally run phpMyAdmin with:

    docker-compose -f docker-compose.yml -f docker-compose-phpmyadmin.yml up

By default, the website will then be available at http://localhost:8000 and the WordPress dashboard at http://localhost:8000/wp-admin. phpMyAdmin is set to http://localhost:8001. If you specified a different new_url in the .env file then wordpress will attempt to redirect there, so you may require some DNS and webserver configuration to bring the site up. Below is a minimal example for running an nginx reverse proxy in front of wordpress:

server {
    server_name example.com;

    location / {
        proxy_pass        http://localhost:8000/;
        proxy_set_header  X-Real-IP $remote_addr;
        proxy_set_header  X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header  X-Forwarded-Proto $scheme;
        proxy_set_header  Host $host;
    }
}

existing-wordpress-development-docker's People

Contributors

lumonald avatar steven-eardley avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.