Revision [23549]
This is an old revision of Wikka-Docker made by OeMunoz on 2016-12-20 12:22:11.
Using Docker for development WikkaWiki
Docker is a useful tool for deployment, but also for development too. This article is dedicated to easily show you how use docker for development WikkaWiki (plugins, database, new themes, etc). If you have some previusly experence on docker and WikkaWiki, maybe you only have to check the basic dockerhub WikkaWiki build.
On the other hand, this article don't cover the installation and configuration of docker, the way to install docker is
widely on the web and the docker main page. This article assumes that you have successfully installed docker.
Why use Docker for Development of WikkaWiki?
Here’s a few of the reasons why you could use Docker for WikkaWiki development.
- All developers use the same OS, same system libraries, same language runtime, no matter what host OS they are using (even Windows if you can believe it).
- You can check the DockerFile for the installations steeps.
- You only need Docker to develop. You don’t need to install a bunch of databases engines, language environments or a set of unknown library's on your Operation System.
- You can set multiple "hackarounds" (like different php versions) without installing it on your machine, the hackarounds are isolated using docker.
- Can still use your favorite editor/IDE as you normally do. No need for running a VMs or remote directory's in and developing from the shell just so you can build/run on a Linux box.
How to use Docker for Development?
Let's suppose that you want to setup a new development environment for your new plugin, you have to remember that WikkaWiki is a web application (runs over a Web server like Apache) and is build using PHP language, and also WikkaWiki store the data on a Mysql database. This meaning that you have to setup the follows systems for your new develop environment:
- Physical/Virtual machine with a operation system compatible (setup network, disk space, etc).
- Web Server with the PHP 5/7 engine.
- Mysql database server with some basic or specific information for your new development.
This is hard work if you have to generate a new environment every time you want to test a new crazy idea. There is where docker gonna to help you. On the follow items, we gonna to check how to easily setup a new development environment.
Checking a new WikkaWiki release without operation system setup effort.
When you want to evaluate a new release, to see the new features of the system or check the behavior and system requirements:
evaluate a new release
oems@mydockerserver:~/$ docker run --rm -it oems/wikkawiki:v1.3.7
Running on the docker on this way give you the opportunity to check the release 1.3.7, to check which id is using your docker you can use:
get ID
oems@mydockerserver:~/$ docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
2ba9a0d95d51 oems/wikkawiki:v1.3.7 "/usr/bin/supervisord" 31 seconds ago Up 28 seconds admiring_fermi
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
2ba9a0d95d51 oems/wikkawiki:v1.3.7 "/usr/bin/supervisord" 31 seconds ago Up 28 seconds admiring_fermi
And then use the inspect docker command to check specific characteristics like network settings of the instance:
check specific characteristics like network
oems@mydockerserver:~/$ docker inspect 2ba9a0d95d51
.....
"MacAddress": "02:42:ac:11:00:03",
"Networks": {
"bridge": {
"IPAMConfig": null,
"Links": null,
"Aliases": null,
"NetworkID": "985853b847895aecae730901560bffcc5ea42a130dd25358029b74c1eb5c4501",
"EndpointID": "a036a000115ccce8c94a205a9739866d1e5dda8692b1a8e69f0aac89f6c377c8",
"Gateway": "172.17.0.1",
"IPAddress": "172.17.0.3",
"IPPrefixLen": 16,
"IPv6Gateway": "",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"MacAddress": "02:42:ac:11:00:03"
}
}
.....
.....
"MacAddress": "02:42:ac:11:00:03",
"Networks": {
"bridge": {
"IPAMConfig": null,
"Links": null,
"Aliases": null,
"NetworkID": "985853b847895aecae730901560bffcc5ea42a130dd25358029b74c1eb5c4501",
"EndpointID": "a036a000115ccce8c94a205a9739866d1e5dda8692b1a8e69f0aac89f6c377c8",
"Gateway": "172.17.0.1",
"IPAddress": "172.17.0.3",
"IPPrefixLen": 16,
"IPv6Gateway": "",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"MacAddress": "02:42:ac:11:00:03"
}
}
.....
by last, you can access to the WikkaWiki installation page pointing to http://172.17.0.3 on your browser.
I want to get inside the docker for a quick edit.
You can easily get into the docker for some check specific field using:
get into the docker
oems@mydockerserver:~/$ docker exec -it 2ba9a0d95d51 bash
root@2ba9a0d95d51:/# ps -fea
UID PID PPID C STIME TTY TIME CMD
root 1 0 0 14:37 ? 00:00:00 /usr/bin/python /usr/bin/supervisord -c /etc/supervisord.conf
root 60 1 0 14:37 ? 00:00:00 /bin/sh /usr/bin/mysqld_safe
root 251 1 0 14:37 ? 00:00:00 /usr/sbin/apache2 -k start
mysql 420 60 0 14:37 ? 00:00:01 /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib/mysql/plugin --user=mysql --lo
www-data 454 251 0 14:37 ? 00:00:00 /usr/sbin/apache2 -k start
www-data 455 251 0 14:37 ? 00:00:00 /usr/sbin/apache2 -k start
www-data 456 251 0 14:37 ? 00:00:00 /usr/sbin/apache2 -k start
www-data 457 251 0 14:37 ? 00:00:00 /usr/sbin/apache2 -k start
www-data 458 251 0 14:37 ? 00:00:00 /usr/sbin/apache2 -k start
root 595 0 0 14:52 ? 00:00:00 bash
root 610 595 0 14:52 ? 00:00:00 ps -fea
root@2ba9a0d95d51:/# ps -fea
UID PID PPID C STIME TTY TIME CMD
root 1 0 0 14:37 ? 00:00:00 /usr/bin/python /usr/bin/supervisord -c /etc/supervisord.conf
root 60 1 0 14:37 ? 00:00:00 /bin/sh /usr/bin/mysqld_safe
root 251 1 0 14:37 ? 00:00:00 /usr/sbin/apache2 -k start
mysql 420 60 0 14:37 ? 00:00:01 /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib/mysql/plugin --user=mysql --lo
www-data 454 251 0 14:37 ? 00:00:00 /usr/sbin/apache2 -k start
www-data 455 251 0 14:37 ? 00:00:00 /usr/sbin/apache2 -k start
www-data 456 251 0 14:37 ? 00:00:00 /usr/sbin/apache2 -k start
www-data 457 251 0 14:37 ? 00:00:00 /usr/sbin/apache2 -k start
www-data 458 251 0 14:37 ? 00:00:00 /usr/sbin/apache2 -k start
root 595 0 0 14:52 ? 00:00:00 bash
root 610 595 0 14:52 ? 00:00:00 ps -fea
I want to use my own copy of configuration files of WikkaWiki for testing it.
The wikka.config.php file, is a set of configurations options, if you want to check with a specific database or some specific theme, you have to edit this file and run a new configuration.
1. Testing your wikka.config.php
docker run --rm -it -v $PWD/wikka.config.php:/var/www/html/wikka/wikka.config.php oems/wikkawiki
I want to use my own copy of all PHP and directory's files of WikkaWiki for testing it.
You can copy you own WikkaWiki instance to a specific directory, for example
oems@mydockerserver:~/$ cp -r /var/www/htdocs/wikka wikkawiki
oems@mydockerserver:~/$ ls wikkawiki
3rdparty badwords.txt.php docs handlers index.php intranet libs localization.php phpinfo.php README.md setup templates version.php wikka.php
actions config formatters images interwiki.conf lang locale mime_types.txt plugins scripts sql uploads wikka.config.php
oems@mydockerserver:~/$ ls wikkawiki
3rdparty badwords.txt.php docs handlers index.php intranet libs localization.php phpinfo.php README.md setup templates version.php wikka.php
actions config formatters images interwiki.conf lang locale mime_types.txt plugins scripts sql uploads wikka.config.php
Then run the instance:
check if the new release is compatible with you
oems@mydockerserver:~/$ docker run --rm -it -v $PWD/wikkawiki/:/var/www/html/wikka/ oems/wikkawiki
This is very useful when you want to check if the new release is compatible with your themes (css styles, js stuff, etc).
I want to use all my own copy of all PHP and directory's files and database WikkaWiki for testing it.
This command runs a database directory, a base directory and even a plugins directory and uploads. All directory's can be shared between dockers instances, except the Mysql directory, because MySql don't accept concurrent multiple instances access, but this is not really a problem if you use btrfs/lvm snapshots.
all option on one
docker run -d -p 80:80 -v $PWD/mysql:/var/lib/mysql -v $PWD/wikka.config.php:/var/www/html/wikka/wikka.config.php -v $PWD/uploads:/var/www/html/wikka/uploads -v $PWD/plugins:/var/www/html/wikka/plugins oems/wikkawiki
FAQs and TODOs
- This docker is for a production environment?
> R: No, is a help to the developers, I hope that in some time the docker, will gonna to be used by all and be approved to be the preferred on the project.
- This docker come with additional plugins, handlers or something else?
> R: No, the principal goal of this docker is to be a clean and basic base line of WikkaWiki
- [ ] TODO: Add a section for plugins directory and uploads actions.
- [ ] TODO: Add Some images.
References:
- [WikkaWiki](http://wikkawiki.org/HomePage) is a flexible, standards-compliant and lightweight wiki engine written in PHP, which uses MySQL to store pages.- [Why and How to Use Docker for Development](https://medium.com/iron-io-blog/why-and-how-to-use-docker-for-development-a156c1de3b24#.qwcr62gmu)