Skip to content

Commit bfd4e18

Browse files
authored
Merge pull request #1183 from vmassol/patch-5
Document new features of the XWiki docker image
2 parents 1a7c240 + 164f470 commit bfd4e18

File tree

1 file changed

+145
-0
lines changed

1 file changed

+145
-0
lines changed

xwiki/content.md

Lines changed: 145 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,142 @@ volumes:
190190
xwiki-data: {}
191191
```
192192

193+
### Using Docker Swarm
194+
195+
Here are some examples of using this image with Docker Swarm. These examples leverage additional features of Docker Swarm such as Docker secrets, and Docker configs. As such, these examples require Docker to be in swarm mode.
196+
197+
You can read more about these features and Docker swarm mode here:
198+
199+
- [Docker swarm mode](https://docs.docker.com/engine/swarm/)
200+
- [Creating Docker secrets](https://docs.docker.com/engine/reference/commandline/secret_create/)
201+
- [Creating Docker configs](https://docs.docker.com/engine/reference/commandline/config_create/)
202+
203+
#### MySQL Example
204+
205+
This example presupposes the existence of the Docker secrets `xwiki-db-username`, `xwiki-db-password` and `xwiki-db-root-password`, and the Docker config `xwiki-mysql-config`.
206+
207+
You can create these secrets and configs with the following:
208+
209+
- `echo ${MY_XWIKI_USER:-xwiki} | docker secret create xwiki-db-username -`
210+
- `echo $(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 16 | head -n 1) | docker secret create xwiki-db-password -`
211+
- `echo $(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 16 | head -n 1) | docker secret create xwiki-db-root-password -`
212+
- `docker config create xwiki-mysql-config /path/to/mysql/xwiki.cnf`
213+
214+
To deploy this example, save the following YAML as `xwiki-stack.yaml`, then run:
215+
216+
- `docker stack deploy -c xwiki-stack.yaml xwiki`
217+
218+
```yaml
219+
version: '3.3'
220+
services:
221+
web:
222+
image: "xwiki:mysql-tomcat"
223+
ports:
224+
- "8080:8080"
225+
environment:
226+
- DB_USER_FILE=/run/secrets/xwiki-db-username
227+
- DB_PASSWORD_FILE=/run/secrets/xwiki-db-password
228+
- DB_DATABASE=xwiki
229+
- DB_HOST=db
230+
volumes:
231+
- xwiki-data:/usr/local/xwiki
232+
secrets:
233+
- xwiki-db-username
234+
- xwiki-db-password
235+
db:
236+
image: "mysql:5.7"
237+
volumes:
238+
- mysql-data:/var/lib/mysql
239+
environment:
240+
- MYSQL_ROOT_PASSWORD=/run/secrets/xwiki-db-root-password
241+
- MYSQL_USER_FILE=/run/secrets/xwiki-db-username
242+
- MYSQL_PASSWORD_FILE=/run/secrets/xwiki-db-password
243+
- MYSQL_DATABASE=xwiki
244+
secrets:
245+
- xwiki-db-username
246+
- xwiki-db-password
247+
- xwiki-db-root-password
248+
configs:
249+
- source: mysql-config
250+
target: /etc/mysql/conf.d/xwiki.cnf
251+
volumes:
252+
mysql-data:
253+
xwiki-data:
254+
secrets:
255+
xwiki-db-username:
256+
external:
257+
name: xwiki-db-username
258+
xwiki-db-password:
259+
external:
260+
name: xwiki-db-password
261+
xwiki-db-root-password:
262+
external:
263+
name: xwiki-db-root-password
264+
configs:
265+
mysql-config:
266+
external:
267+
name: xwiki-mysql-config
268+
```
269+
270+
#### PostgreSQL Example
271+
272+
This example presupposes the existence of the Docker secrets `xwiki-db-username`, `xwiki-db-password`, and `xwiki-db-root-password`.
273+
274+
You can create these secrets with the following:
275+
276+
- `echo ${MY_XWIKI_USER:-xwiki} | docker secret create xwiki-db-username -`
277+
- `echo $(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 16 | head -n 1) | docker secret create xwiki-db-password -`
278+
- `echo $(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 16 | head -n 1) | docker secret create xwiki-db-root-password -`
279+
280+
To deploy this example, save the following YAML as `xwiki-stack.yaml` then run:
281+
282+
- `docker stack deploy -c xwiki-stack.yaml xwiki`
283+
284+
```yaml
285+
version: '3.3'
286+
services:
287+
web:
288+
image: "xwiki:mysql-postgres"
289+
ports:
290+
- "8080:8080"
291+
environment:
292+
- DB_USER_FILE=/run/secrets/xwiki-db-username
293+
- DB_PASSWORD_FILE=/run/secrets/xwiki-db-password
294+
- DB_DATABASE=xwiki
295+
- DB_HOST=db
296+
volumes:
297+
- xwiki-data:/usr/local/xwiki
298+
secrets:
299+
- xwiki-db-username
300+
- xwiki-db-password
301+
db:
302+
image: "postgres:9.5"
303+
volumes:
304+
- postgres-data:/var/lib/postgresql/data
305+
environment:
306+
- POSTGRES_ROOT_PASSWORD_FILE=/run/secrets/xwiki-db-root-password
307+
- POSTGRES_USER_FILE=/run/secrets/xwiki-db-username
308+
- POSTGRES_PASSWORD_FILE=/run/secrets/xwiki-db-password
309+
- POSTGRES_DB=xwiki
310+
secrets:
311+
- xwiki-db-username
312+
- xwiki-db-password
313+
- xwiki-db-root-password
314+
volumes:
315+
postgres-data:
316+
xwiki-data:
317+
secrets:
318+
xwiki-db-username:
319+
external:
320+
name: xwiki-db-username
321+
xwiki-db-password:
322+
external:
323+
name: xwiki-db-password
324+
xwiki-db-root-password:
325+
external:
326+
name: xwiki-db-root-password
327+
```
328+
193329
## Building
194330

195331
This allows you to rebuild the XWiki docker image locally. Here are the steps:
@@ -229,6 +365,15 @@ The first time you create a container out of the %%IMAGE%% image, a shell script
229365
- `DB_DATABASE`: The name of the XWiki database to use/create.
230366
- `DB_HOST`: The name of the host (or docker container) containing the database. Default is "db".
231367

368+
In order to support [Docker secrets](https://docs.docker.com/engine/swarm/secrets/), the configuration values can also be given to the container as files containing that value.
369+
370+
- `DB_USER_FILE`: The location, inside the container, of a file containing the value for `DB_USER`
371+
- `DB_PASSWORD_FILE`: The location, inside the container, of a file containing the value for `DB_PASSWORD`
372+
- `DB_DATABASE_FILE`: The location, inside the container, of a file containing the value for `DB_DATABASE`
373+
- `DB_HOST_FILE`: The location, inside the container, of a file containing the value for `DB_HOST`
374+
375+
*Note:* For each configuration value, the normal environment variable and \_FILE environment variable are mutually exclusive. Providing values for both variables will result in an error.
376+
232377
The main XWiki configuration files (`xwiki.cfg`, `xwiki.properties` and `hibernate.cfg.xml`) are available in the mapped local directory for the permanent directory on your host.
233378

234379
If you need to perform some advanced configuration, you can execute another container and attach to the running XWiki container by issuing (but note that these won't be saved if you remove the container):

0 commit comments

Comments
 (0)