Docker-compose setup for Servatrice (#3887)

* Docker compose for servatrice

* Update README.md

* Clean up docker-compose specific configuration
This commit is contained in:
Phillip Wheatley 2020-03-17 01:40:58 +00:00 committed by GitHub
parent 17efe8c003
commit 7285f24a29
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 48 additions and 0 deletions

View file

@ -141,6 +141,20 @@ to permit connections to the server.
Find more information on how to use Servatrice with Docker in our [wiki](https://github.com/Cockatrice/Cockatrice/wiki/Setting-up-Servatrice#using-docker). Find more information on how to use Servatrice with Docker in our [wiki](https://github.com/Cockatrice/Cockatrice/wiki/Setting-up-Servatrice#using-docker).
**Docker compose**
There is also a docker-compose file available which will configure and run both a MySQL server and Servatrice. The docker-compose setup scripts can be found in the `servatrice/docker` folder and vary only slightly from the default sql and server .ini files. The setup scripts can either be modified in place, or docker-compose can mount alternative files into the images, as you prefer.
To run Servatrice via docker-compose, first install docker-compose following the [install instructions](https://docs.docker.com/compose/install/). Once installed, run the following from the root of the repository:
```bash
docker-compose build # Build the Servatrice image using the same Dockerfile as above.
docker-compose up # Setup and run both the MySQL server and Servatrice.
```
>Note: Similar to the above Docker setup, this will expose TCP ports 4747 and 4748.
>Note: The first time running the docker-compose setup, the MySQL server will take a little time to run the initial setup scripts. Due to this, the Servatrice instance may fail the first few attempts to connect to the database. Servatrice is set to `restart: always` in the docker-compose.yml, which will allow it to continue attempting to start up. Once the MySQL scripts have completed, Servatrice should then connect automatically on the next attempt.
# License [![GPLv2 License](https://img.shields.io/github/license/Cockatrice/Cockatrice.svg)](https://github.com/Cockatrice/Cockatrice/blob/master/LICENSE) # License [![GPLv2 License](https://img.shields.io/github/license/Cockatrice/Cockatrice.svg)](https://github.com/Cockatrice/Cockatrice/blob/master/LICENSE)
Cockatrice is free software, licensed under the [GPLv2](https://github.com/Cockatrice/Cockatrice/blob/master/LICENSE). Cockatrice is free software, licensed under the [GPLv2](https://github.com/Cockatrice/Cockatrice/blob/master/LICENSE).

27
docker-compose.yml Normal file
View file

@ -0,0 +1,27 @@
version: '3'
services:
mysql:
image: mysql
environment:
- MYSQL_ROOT_PASSWORD=root-password
- MYSQL_DATABASE=servatrice
- MYSQL_USER=servatrice
- MYSQL_PASSWORD=password
volumes:
- $PWD/servatrice/servatrice.sql:/docker-entrypoint-initdb.d/servatrice.sql
servatrice:
build:
context: .
dockerfile: Dockerfile
image: servatrice
depends_on:
- mysql
ports:
- "4747:4747"
- "4748:4748"
entrypoint: "/bin/bash -c 'sleep 10; servatrice --config /tmp/servatrice.ini --log-to-console'"
restart: always
volumes:
- $PWD/servatrice/docker/servatrice-docker.ini:/tmp/servatrice.ini

View file

@ -0,0 +1,7 @@
[database]
type=mysql
prefix=cockatrice
hostname=mysql
database=servatrice
user=servatrice
password=password