A collection of tools and examples to demonstrate building and deploying Sakai using Docker and/or Docker Swarm.
Features of the files you will find here:
- Example Swarm stacks
- Sakai + Mysql
- Sakai + Mysql + Elasticsearch + Cerebro + Mailcatcher
Docker provides an installation script for most Linux distributions, With Ubuntu and RHEL/CentOS being the most used. This script is located at https://get.docker.com/ and has the following instructions at the top of the file:
This script is meant for quick & easy install via:
$ curl -fsSL https://get.docker.com -o get-docker.sh
$ sh get-docker.sh
This will install and prepare everything needed to build images and run them in standalone mode. Additionally, docker has a built-in container orchestration platform called "Docker Swarm". Swarm needs to be enabled to use any of these deployment example scripts, this can be enabled by simply running:
$ docker swarm init
You will need to provide at a minimum a sakai.properties
configuration containing a minimal database configuration. In the examples here, a MySQL configuration is provided.
These are basic examples, that do not include mounting storage volumes to persist data.
To start the example Sakai and Mysql stack follow these steps:
- From this folder.
- Execute
docker stack deploy -c sakai_docker.yml sakai
- This creates a stack named
sakai
using the compose filesakai_docker.yml
- Services in the stack are named <StackName>_<ServiceName> (e.g. sakai_mysql and sakai_sakai)
- The configuration file
conf/sakai.properties
is mounted inside the container in /usr/local/sakai/properties - Sakai will be located at
http://<dockerhost>:8080/portal
- This creates a stack named
To start the example Sakai, Mysql, Elasticsearch, Cerebro, and Mailcatcher stack follow these steps:
- From this folder.
- Execute
docker stack deploy -c sakai_es_docker.yml sakai
- This creates a stack named
sakai
using the compose filesakai_es_docker.yml
- Services in the stack are named <StackName>_<ServiceName> (e.g. sakai_mysql and sakai_sakai)
- The configuration file
conf/sakai.properties
is mounted inside the container in /usr/local/sakai/properties - The secrets file
secrets/security.properties
is deployed using Docker Secrets and placed in /usr/local/tomcat/sakai/ - Sakai will be located at
http://<dockerhost>:8080/portal
- Mailcatcher will be located at
http://<dockerhost>:8081/
- Cerebro (Elasticsearch Management) will be located at
http://<dockerhost>:8082/
- Use ES Node address:
http://elasticsearch:9200/
- This creates a stack named
Now that the stack has started you can monitor with the Swarm commands:
- List running stacks with
docker stack ls
- List services running in the sakai stack with
docker stack services sakai
- List containers running in the sakai service with
docker service ps sakai_sakai
- View (tail) the logs from the Sakai container with
docker service logs -f sakai_sakai
You can manage using Swarm commands:
- Restart the sakai service with
docker service update --force sakai_sakai
- Stop and remove the stack with
docker stack rm sakai
In this example you will start a standalone MySQL container and a linked standalone sakai container.
- From this folder.
- Start a MySQL 5.5 container with:
-
docker run -d \ --name mysql \ -e MYSQL_ROOT_PASSWORD=examplerootpassword \ -e MYSQL_DATABASE=sakai -e MYSQL_USER=sakai \ -e MYSQL_PASSWORD=examplepassword \ mysql:5.5 \ --character-set-server=utf8 \ --collation-server=utf8_general_ci
-
- Monitor MySQL startup with
docker logs -f mysql
and hit Ctrl-C once MySQL has finished starting. - Start a Sakai Container with the MySQL container linked to it:
-
docker run -d \ --name sakai \ -p 8080:8080 \ -v $(pwd)/config/sakai.properties:/usr/local/sakai/properties/sakai.properties \ --link mysql:mysql \ sakai
-
- Monitor Sakai startup with
docker logs -f sakai
and hit Ctrl-C once Sakai has finished starting. - Sakai should be available on port 8080 of the Dockerhost.
You may need to monitor the containers
- View logs of the sakai container with
docker logs -f sakai
- Inspect the sakai container configuration with
docker inspect sakai
You may need to manage the containers
- Stop the running sakai container with
docker kill sakai
- Remove the sakai container with
docker rm sakai