Build a WordPress development environment quickly with Docker

TL;DR

https://github.com/qpSHiNqp/docker-wordpress-dev

If you clone this and docker-compose up, the WordPress environment will start up in an instant.

table of contents

  1. Until you build a WordPress environment with docker
  2. When creating a theme, make the style applied to the content part feel good (just write it in the meantime)

Until you build a WordPress environment with docker

Background

It happened that I had to play with WordPress. Until now, in order to prepare the development environment, set up a MySQL server locally, create a DB, create and arrange around users and privileges, create a PHP environment, create a Web server environment, connect, check the operation .. I was doing my best to do what is called MAMP, but nowadays it is not normal, so I did a little research to build an environment with docker.

How to build

When I looked it up, there was a docker image called wordpress, and of course there was also a docker image for mysql, so I decided to make it with a good feeling, docker-compose.yml.

As for how to make it, it was carefully written in Description of Docker Hub of wordpress, so I will describe it as reference information. In the middle of the page, the section "... via docker stack deploy or docker-compose" is almost the same.

This time I wanted to make a theme or plugin, so I created docker-compose.yml to mount wp-content / themes and wp-content / plugins.

version: '3.1'

services:

  wordpress:
    image: wordpress
    restart: always
    ports:
      - 8080:80
    environment:
      WORDPRESS_DB_HOST: db
      WORDPRESS_DB_USER: exampleuser
      WORDPRESS_DB_PASSWORD: examplepass
      WORDPRESS_DB_NAME: exampledb
    volumes:
      - wordpress:/var/www/html
      - ./wp-content/themes:/var/www/html/wp-content/themes
      - ./wp-content/plugins:/var/www/html/wp-content/plugins

  db:
    image: mysql:5.7
    restart: always
    environment:
      MYSQL_DATABASE: exampledb
      MYSQL_USER: exampleuser
      MYSQL_PASSWORD: examplepass
      MYSQL_RANDOM_ROOT_PASSWORD: '1'
    volumes:
      - db:/var/lib/mysql

volumes:
  wordpress:
  db:

Now, when you open docker-compose up and http: // localhost: 8080, the WordPress setup screen will open immediately, so if you proceed as it is, you can go to the management screen.

When creating a theme, make the style applied to the content part feel good (just write it in the meantime)

From here onward, I just wrote it in the meantime, so I think it can only be used as a memorandum of my own.

When creating my own theme, I think that the layout and appearance are controlled by style.css, but since WordPress is a CMS equipped with a WYSIWYG editor, it is necessary to make use of the layout of the content part that is provided in WordPress.

The built-in style is described in the "WordPress Generated Classes" section of CSS «WordPress Codex. By copying and pasting this to the bottom of my own theme, I was able to reflect the layout specified at the time of editing with WYSIWYG on the actual display.

Initially, the style defined in my own style.css was applied to the elements of the content part, so there was a problem that it looked different from WYSIWYG, but probably the responsibility of markup as follows I feel that the demarcation will generally work.

--On the template / theme side, only the layout of the block element that wraps the content is controlled by HTML + CSS, and <? Php the_content ();?> Does not affect the layout of the content body to be embedded`` I'll make it style.css --If

(or

`) is in charge of displaying the post title, it is better to control the display on the template side. --Styles related to appearance other than layout, such as font color and font, are defined in style.css and made to be applied to the content (strictly speaking, it can be said that the layout will be different if the font is different).

In short, the HTML that WordPress WYSIWYG spits out is unpredictable, so it's probably impossible to control block layout of the content body with your own css. Rather, I feel that the theme creator needs a class / selector design that allows the block layout of the content body to be left uncontrolled.

It was okay to make it support the color palette function, but this time I didn't need to create a general-purpose theme that fully supports WordPress functions, so I implemented it with minimal function support.

Recommended Posts

Build a WordPress development environment quickly with Docker
Build a Wordpress development environment with Docker
Build a PureScript development environment with Docker
Build a Node.js environment with Docker
[Docker] Build a Wordpress environment locally (Win, Mac) quickly
Build a simple Docker + Django development environment
Build a development environment for Django + MySQL + nginx with Docker Compose
Build a development environment for Docker + Rails6 + Postgresql
Build a Laravel / Docker environment with VSCode devcontainer
Build a simple Docker Compose + Django development environment
[Win10] Build a JSF development environment with NetBeans
Build a development environment for Docker, java, vscode
[First team development ②] Build an environment with Docker
Wordpress local environment construction & development procedure with Docker
Create a Spring Boot development environment with docker
Build a Java development environment with VS Code
Build docker environment with WSL
I tried to build a Firebase application development environment with Docker in 2020
[Copy and paste] Build a Laravel development environment with Docker Compose Part 2
How to build a Ruby on Rails development environment with Docker (Rails 6.x)
Build a local development environment for Rails tutorials with Docker (Rails 6 + PostgreSQL + Webpack)
[Copy and paste] Build a Laravel development environment with Docker Compose Participation
How to build a Ruby on Rails development environment with Docker (Rails 5.x)
Template: Build a Ruby / Rails development environment with a Docker container (Ubuntu version)
Template: Build a Ruby / Rails development environment with a Docker container (Mac version)
Easily build a Vue.js environment with Docker + Vue CLI
[Note] Build a Python3 environment with Docker in EC2
Build Java development environment with WSL2 Docker VS Code
[Environment construction] Build a Java development environment with VS Code!
Build WordPress environment with Docker (Local) and AWS (Production)
Try to build a Java development environment using Docker
Create a Vue3 environment with Docker!
Build Couchbase local environment with Docker
Build a Tomcat 8.5 environment with Pleiades 4.8
Build PlantUML environment with VSCode + Docker
Build environment with vue.js + rails + docker
Build Rails environment with Docker Compose
Build jooby development environment with Eclipse
Build a development environment to create Ruby on Jets + React apps with Docker
Build Unity development environment on docker
Build docker + laravel environment with laradock
I made a development environment with rails6 + docker + postgreSQL + Materialize.
Build a "Spring Thorough Introduction" development environment with IntelliJ IDEA
How to build Rails, Postgres, ElasticSearch development environment with Docker
Build a Node-RED environment with Docker to move and understand
I tried to create a padrino development environment with Docker
Until you build a Nuxt.js development environment with Docker and touch it with VS Code
[Rails] [Docker] Copy and paste is OK! How to build a Rails development environment with Docker
Build a local development environment for Open Distro for Elasticsearch with multiple nodes using Docker
How to quit Docker for Mac and build a Docker development environment with Ubuntu + Vagrant
Create a web environment quickly using Docker
Laravel development environment construction with Docker (Mac)
Create a MySQL environment with Docker from 0-> 1
Build a WAS execution environment from Docker
Create Spring Boot-gradle-mysql development environment with Docker
Build a Java development environment on Mac
[Docker] Build Jupyter Lab execution environment with Docker
Build an environment with Docker on AWS
Build an Ultra96v2 development environment on Docker 1
Lightweight PHP 7.4 development environment created with Docker
Build TensorFlow operation check environment with Docker