| Matthias Andreas Benkard | aa40464 | 2019-12-31 13:23:47 +0100 | [diff] [blame^] | 1 | # TikiWiki Docker Image | 
|  | 2 |  | 
|  | 3 | TikiWiki is full featured content management system written in PHP. You can | 
|  | 4 | find more useful information at http://tiki.org | 
|  | 5 |  | 
|  | 6 | ## Pulling | 
|  | 7 |  | 
|  | 8 | ``` | 
|  | 9 | docker pull tikiwiki/tikiwiki:19.x | 
|  | 10 | ``` | 
|  | 11 |  | 
|  | 12 | ## Running | 
|  | 13 |  | 
|  | 14 | ### Variables | 
|  | 15 |  | 
|  | 16 | Some env variables are provided to setup the database, but you can also mount | 
|  | 17 | your configurations files inside container. The env vars and the default values | 
|  | 18 | are listed below and the names are self explanatory. | 
|  | 19 |  | 
|  | 20 | ``` | 
|  | 21 | TIKI_DB_VERSION=19 | 
|  | 22 | TIKI_DB_HOST='db' | 
|  | 23 | TIKI_DB_USER | 
|  | 24 | TIKI_DB_PASS | 
|  | 25 | TIKI_DB_NAME=tikiwiki | 
|  | 26 | ``` | 
|  | 27 |  | 
|  | 28 | ### Single container | 
|  | 29 |  | 
|  | 30 | Example to get a running container below. | 
|  | 31 |  | 
|  | 32 | ``` | 
|  | 33 | docker run --rm --name tiki --link mariadb:db \ | 
|  | 34 | -e TIKI_DB_USER=tiki \ | 
|  | 35 | -e TIKI_DB_PASS=wiki \ | 
|  | 36 | -p 80:80 \ | 
|  | 37 | -d tikiwiki/tikiwiki | 
|  | 38 | ``` | 
|  | 39 |  | 
|  | 40 | ### docker-compose | 
|  | 41 |  | 
|  | 42 | The following creates and start two containers: | 
|  | 43 |  | 
|  | 44 | 1. TikiWiki with por 80 published on host | 
|  | 45 | 2. MariaDB instance with the schema `tikiwiki` | 
|  | 46 |  | 
|  | 47 | ```yml | 
|  | 48 | version: '2' | 
|  | 49 | services: | 
|  | 50 | tiki: | 
|  | 51 | image: tikiwiki/tikiwiki:19.x | 
|  | 52 | ports: | 
|  | 53 | - "80:80" | 
|  | 54 | depends_on: | 
|  | 55 | - db | 
|  | 56 | environment: | 
|  | 57 | - TIKI_DB_USER=tiki | 
|  | 58 | - TIKI_DB_PASS=wiki | 
|  | 59 | - TIKI_DB_NAME=tikiwiki | 
|  | 60 | db: | 
|  | 61 | image: mariadb | 
|  | 62 | environment: | 
|  | 63 | - MYSQL_USER=tiki | 
|  | 64 | - MYSQL_PASSWORD=wiki | 
|  | 65 | - MYSQL_DATABASE=tikiwiki | 
|  | 66 | - MYSQL_ROOT_PASSWORD=tkwkiiii | 
|  | 67 | - TERM=dumb | 
|  | 68 | ``` | 
|  | 69 |  | 
|  | 70 | ### scalable mode with docker-compose | 
|  | 71 |  | 
|  | 72 | The following recipe makes possible to grow the amount of TikiWiki | 
|  | 73 | containers, so in this way, it is possible to use more resources from | 
|  | 74 | host to handle incoming traffic. | 
|  | 75 |  | 
|  | 76 | Concerning about this mode: | 
|  | 77 |  | 
|  | 78 | 1. It it not compatible to web installer, so installing database using | 
|  | 79 | command line is needed. | 
|  | 80 | 2. It is needed to have a reverse proxy load balancing traffic to TikiWiki | 
|  | 81 | containers. | 
|  | 82 |  | 
|  | 83 | #### docker-compose.yml | 
|  | 84 |  | 
|  | 85 | This setup uses `eeacms/haproxy` container as reverse proxy and load balancer and | 
|  | 86 | declare a set of volumes. When new **tiki** containers are created, they will share | 
|  | 87 | the same set of volumes. | 
|  | 88 |  | 
|  | 89 | ```yml | 
|  | 90 | version: '3.7' | 
|  | 91 |  | 
|  | 92 | services: | 
|  | 93 | haproxy: | 
|  | 94 | image: eeacms/haproxy | 
|  | 95 | depends_on: | 
|  | 96 | - tiki | 
|  | 97 | ports: | 
|  | 98 | - "80:5000" | 
|  | 99 | environment: | 
|  | 100 | BACKENDS: "tiki" | 
|  | 101 | DNS_ENABLED: "true" | 
|  | 102 | LOG_LEVEL: "info" | 
|  | 103 | tiki: | 
|  | 104 | image: tikiwiki/tikiwiki:19.x | 
|  | 105 | depends_on: | 
|  | 106 | - db | 
|  | 107 | deploy: | 
|  | 108 | replicas: 2 | 
|  | 109 | environment: | 
|  | 110 | - TIKI_DB_USER=tiki | 
|  | 111 | - TIKI_DB_PASS=wiki | 
|  | 112 | - TIKI_DB_NAME=tikiwiki | 
|  | 113 | volumes: | 
|  | 114 | - tiki_files:/var/www/html/files/ | 
|  | 115 | - tiki_img_trackers:/var/www/html/img/trackers/ | 
|  | 116 | - tiki_img_wiki_up:/var/www/html/img/wiki_up/ | 
|  | 117 | - tiki_img_wiki:/var/www/html/img/wiki/ | 
|  | 118 | - tiki_modules_cache:/var/www/html/modules/cache/ | 
|  | 119 | - tiki_storage:/var/www/html/storage/ | 
|  | 120 | - tiki_temp:/var/www/html/temp/ | 
|  | 121 | - tiki_sessions:/var/www/sessions/ | 
|  | 122 | db: | 
|  | 123 | image: mariadb | 
|  | 124 | environment: | 
|  | 125 | - MYSQL_USER=tiki | 
|  | 126 | - MYSQL_PASSWORD=wiki | 
|  | 127 | - MYSQL_DATABASE=tikiwiki | 
|  | 128 | - MYSQL_ROOT_PASSWORD=tkwkiiii | 
|  | 129 | - TERM=dumb | 
|  | 130 | volumes: | 
|  | 131 | tiki_files: | 
|  | 132 | tiki_img_trackers: | 
|  | 133 | tiki_img_wiki_up: | 
|  | 134 | tiki_img_wiki: | 
|  | 135 | tiki_modules_cache: | 
|  | 136 | tiki_storage: | 
|  | 137 | tiki_temp: | 
|  | 138 | tiki_sessions: | 
|  | 139 | ``` | 
|  | 140 |  | 
|  | 141 | #### Starting containers | 
|  | 142 |  | 
|  | 143 | First it is needed to copy the YML above in a folder with | 
|  | 144 | a descriptive name, like `example.com`. | 
|  | 145 |  | 
|  | 146 | Then, inside the folder `example.com`, the following command | 
|  | 147 | starts all container from docker-compose.yml. | 
|  | 148 |  | 
|  | 149 | ```sh | 
|  | 150 | docker-compose up -d | 
|  | 151 | ``` | 
|  | 152 |  | 
|  | 153 | After wait all containers to start and the console prompt appears | 
|  | 154 | again, the following command shows the containers running for | 
|  | 155 | docker-compose.yml on folder `example.com`. | 
|  | 156 |  | 
|  | 157 | ``` | 
|  | 158 | docker-compose ps | 
|  | 159 | ``` | 
|  | 160 |  | 
|  | 161 | The output should be like: | 
|  | 162 |  | 
|  | 163 | ``` | 
|  | 164 | Name                      Command               State          Ports | 
|  | 165 | ------------------------------------------------------------------------------------ | 
|  | 166 | examplecom_db_1        docker-entrypoint.sh mysqld      Up      3306/tcp | 
|  | 167 | examplecom_haproxy_1   /docker-entrypoint.sh hapr ...   Up      0.0.0.0:80->5000/tcp | 
|  | 168 | examplecom_tiki_1      /entrypoint.sh apache2-for ...   Up      443/tcp, 80/tcp | 
|  | 169 | ``` | 
|  | 170 |  | 
|  | 171 | There is 1 container running for each service (**db**, **haproxy**, **tiki**) | 
|  | 172 | in **example.com** folder. | 
|  | 173 |  | 
|  | 174 |  | 
|  | 175 | #### Installing database | 
|  | 176 |  | 
|  | 177 | There is a command line installer available in tiki folder that should be used | 
|  | 178 | to install the database. **WE CAN NOT USE THE WEB INSTALLER!**. The following | 
|  | 179 | command installs Tiki database | 
|  | 180 |  | 
|  | 181 | ```sh | 
|  | 182 | docker-compose exec tiki php console.php database:install | 
|  | 183 | ``` | 
|  | 184 |  | 
|  | 185 | #### Scaling containers | 
|  | 186 |  | 
|  | 187 | If more Tiki container is wanted, the following command launch new containers. | 
|  | 188 |  | 
|  | 189 | ```sh | 
|  | 190 | docker-compose scale tiki=3 | 
|  | 191 | ``` | 
|  | 192 |  | 
|  | 193 | Now, the following containers will be listed on `docker-compose ps`: | 
|  | 194 |  | 
|  | 195 | ```sh | 
|  | 196 | Name                      Command               State          Ports | 
|  | 197 | ------------------------------------------------------------------------------------ | 
|  | 198 | examplecom_db_1        docker-entrypoint.sh mysqld      Up      3306/tcp | 
|  | 199 | examplecom_haproxy_1   /docker-entrypoint.sh hapr ...   Up      0.0.0.0:80->5000/tcp | 
|  | 200 | examplecom_tiki_1      /entrypoint.sh apache2-for ...   Up      443/tcp, 80/tcp | 
|  | 201 | examplecom_tiki_2      /entrypoint.sh apache2-for ...   Up      443/tcp, 80/tcp | 
|  | 202 | examplecom_tiki_3      /entrypoint.sh apache2-for ...   Up      443/tcp, 80/tcp | 
|  | 203 | ``` |