Sign inSign up

200ms/wpapache_dev2

By 200ms

•Updated 11 months ago

WordPress with WP-CLI, XDebug and more out of the box.

Image
Developer tools
Content management system
0

4.9K

200ms/wpapache_dev2 repository overview

⁠Wordpress at Apache Dev^2 container

This project is a source of 200ms/wpapache_dev2 docker image. 200ms/wpapache_dev2 belongs to a set of images that can be described as "Dev^2 suit". The idea behind this is to develop Docker images and complementing tools aimed to ease development and testing of LAMP applications.

The main goals are:

  • Eliminate password hassle and boring tasks (e.g. manual account creation)
  • Provide debugging out-of the box
  • Add network insight capabilities

Wordpress is internet's number one web publishing software originally developed as a blogging platform in 2003, but nowadays being an advanced framework for building a web services. Image 200ms/wpapache_dev2 has been developed with purpose to support Wordpress development. It provides:

  • Apache server with XDebug extension
  • WP-CLI⁠ (wp command)
  • Set of helper scripts

Apache server and Wordpress are pre-configured to support development, for instance 'WP_DEBUG' variable is set to 'true' to provide verbose messaging out of the box.

200ms/wpapache_dev2 can be launched as:

  • independent container - which launches local MySQL database alongside with Apache in a one container, or
  • linked to an external MySQL database - where 200ms/wpapache_dev2 provides Apache server and extra tools but database must be handled elsewhere

User can provide desired theme and plugin names, and also other parameters. Basing upon, container will perform setup automatically. If container is 'independent container' - hosting also database, there is no need to pass any database related information - container just starts as one (Wordpress and MariaDb).

Docker image can be pulled with:

docker pull 200ms/wpapache_dev2

Other images implementing that idea:


⁠NOTE 1: 200ms/wpapache_dev2 image has NOT been tested on other OS then Linux. Therefore at this point only this OS is supported.


⁠NOTE 2: Some functionalities are under development, however current version is very useful support for my everyday work as developer. Feature requests, bug reports can be reported here: BitBucket⁠.

⁠FUSE and extra permissions

This image internally uses Dev2FS⁠ that requires Linux FUSE⁠ module to be loaded but also elevated privileges for each Docker container based on this image. It might be required to modprobe fuse prior to using all features of the image. Moreover it is required to run container with:

docker ... --cap-add SYS_ADMIN --device /dev/fuse ...

parameters. Or in the case of docker-compose.yaml:

services:
  proj:
    ...
    cap_add: ['SYS_ADMIN']
    devices:
      - /dev/fuse
    ...

This elevates container's permissions allowing FUSE based Dev2FS to work.

Dev2FS has been developed to fix mismatch of shared file permissions, therefore it is actually one of the key elements of Dev2 suit.

⁠Special directory

PHP code and other files must be shared between container and host. For 200ms/wpapache_dev2 directory named:

/code

has been chosen as a code share point. Data shared with /code is accessed by Apache server, additionally container will handle proper uid:gid remapping.

⁠Usage

Launch empty WP installation:

mkdir app # see NOTE 3

docker run --cap-add SYS_ADMIN --device /dev/fuse \
    --name "dev2wp_hithere" \
    -it -p 8080:80 -v $(pwd)/app:/code \
    200ms/wpapache_dev2

In above examples /code is shared with app directory. Before container launch app should be an empty directory. At first run container will palace Wordpress files under this location. If there is something already under app container will fail with Wordpress deployment.


⁠NOTE 3: Before docker compose up make sure to create directory that is to be shared. If missed Docker will create it but with a root permissions, thus not too practical from project development perspective.

To access Wordpress open: http://localhost:8080/

Credentials are printed at the console right after container launch:

************************* ...
* Login credentials:
admin / TEST0ff7cc
************************* ...

or, if it has not been noted it can be reset with:

docker exec -it dev2wp_hithere wp-ext resetpass

To install WP with a certain plugins and selected theme:

docker run --cap-add SYS_ADMIN --device /dev/fuse \
    --name "wp_dev2" \
    -e WP_THEME_ACTIVATE="newsup" \
    -e WP_PLUGIN_LIST="smart-grid-gallery" \
    -e SITETITLE="WP test 2" \
    -it -p 8080:80 -v $(pwd)/app:/code \
    200ms/wpapache_dev2

or, if already prepared MySQL DB is somewhere in a network:

docker run --cap-add SYS_ADMIN --device /dev/fuse \
    --name "wp_dev2_extdb" \
    -e MYSQL_HOST=mydbhost.local
    -e DB_NAME=wp -e DB_USER=wpuser -e DB_PASS=notgoodidea
    -e WP_THEME_ACTIVATE="newsup" \
    -e WP_PLUGIN_LIST="smart-grid-gallery" \
    -e SITETITLE="WP test 2 ext db" \
    -it -p 8080:80 -v $(pwd)/app:/code \
    200ms/wpapache_dev2
⁠Theme and plugin development

Feature to come soon.

⁠Environment variables

Below the list of environment variables that can be used to instruct Wordpress deployment.

⁠Wordpress settings
⁠WP_THEME_LIST

Space or comma separated list of themes for installation. Theme that is provided as first on the list will become an active one. But if WP_THEME_ACTIVE is set the theme indicated in this variable will become active.

⁠WP_THEME_PATH (NOT IMPLEMENTED)

Theme path.

⁠WP_THEME_ACTIVE

Name of the theme to be activated. This name does not need to be listed in WP_THEME_LIST nor be a name of WP_THEME_PATH theme. If missing appropriate theme will be searched for installation and activation.

⁠WP_PLUGIN_LIST

Space or comma separated list of plugins for installation, plugins are automatically activated.

⁠WP_PLUGIN_INACT_LIST

Space or comma separated list of plugins that should be installed but not activated. If plugin name is listed in both WP_PLUGIN_INACT_LIST and WP_PLUGIN_LIST it will be installed and not activated - the same action as it would be listed in WP_PLUGIN_INACT_LIST only.

⁠MULTISITE

If set to yes, y or 1 prepare multisite Wordpress installation. Default not set.

⁠Site settings
⁠SITETITLE

Blog's site title

⁠TAGLINE

Blog's description

⁠ADMIN_USER

Admin's user name

⁠ADMIN_EMAIL

Admin's email

⁠Database settings
⁠MYSQL_HOST

If MYSQL_HOST variable is not set, or set to indicate localhost, Wordpress will be configured for using internal (in the same container) MySQL database. In order to use an external database, MYSQL_HOST should be set to point other host then 'localhost'.

⁠MYSQL_ROOT_PASS

Set database root password, if container uses internal database and this variable is skipped, a random password will be generated.

⁠DB_USER

Database user name if not set default 'user' is used.

⁠DB_PASS

Password for given user name, if not set random password is generated.

⁠DB_NAME

Name of the MySQL database to be used by Wordpress, if omitted 'mydb' is set.

Example WordPress deployment here⁠ - YouTube.

200ms tools YouTube channel click⁠.

Tag summary

Content type

Image

Digest

sha256:0f706d66e…

Size

399.4 MB

Last updated

11 months ago

docker pull 200ms/wpapache_dev2