======[[https://hub.docker.com/r/oems/wikkawiki/ Using Docker for development WikkaWiki]]====== {{Category}} {{image class="center" alt="Docker logo" title="Docker main page" url="https://raw.githubusercontent.com/oemunoz/wikkawiki/master/images/docker.png" link="https://www.docker.com/"}} [[https://www.docker.com 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 [[https://hub.docker.com/r/oems/wikkawiki/ 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 [[https://www.docker.com docker main page]]. This article assumes that you have successfully installed docker. =====Why use Docker for Development of WikkaWiki?===== {{image class="center" alt="Wikka" title="Wikka Docker" url="https://raw.githubusercontent.com/oemunoz/wikkawiki/master/images/wikkawikiWizzard.png" link="https://hub.docker.com/r/oems/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 [[https://github.com/oemunoz/wikkawiki/blob/master/Dockerfile 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?===== {{image class="center" alt="Work flow" title="Docker Work flow" url="https://raw.githubusercontent.com/oemunoz/wikkawiki/master/images/ImpDevWoFlow.png" link="http://www.slideshare.net/Flux7Labs/how-docker-quickly-advanced-development-of-an-iot-application"}} 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: %%(bash;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: %%(bash;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 %% And then use the inspect docker command to check specific characteristics like network settings of the instance: %%(bash;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" } } ..... %% 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: %%(bash;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 %% ===**__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. Testing your wikka.config.php %%(bash) 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 %%(bash) 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 %% Then run the instance: %%(bash;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. %%(bash;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 [[https://hub.docker.com/r/oems/wikkawiki/ docker]] is for a production environment? > R: No, is a help to the developers, I hope that in some time the [[https://hub.docker.com/r/oems/wikkawiki/ docker]], will gonna to be used by all and be approved to be the preferred on the project. - This [[https://hub.docker.com/r/oems/wikkawiki/ docker]] come with additional plugins, handlers or something else? > R: No, the principal goal of this [[https://hub.docker.com/r/oems/wikkawiki/ 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#.f2hcratjc)