From 7285f24a29b06786a1076931225b506ba13058ae Mon Sep 17 00:00:00 2001 From: Phillip Wheatley Date: Tue, 17 Mar 2020 01:40:58 +0000 Subject: [PATCH] Docker-compose setup for Servatrice (#3887) * Docker compose for servatrice * Update README.md * Clean up docker-compose specific configuration --- README.md | 14 +++++++++++++ docker-compose.yml | 27 +++++++++++++++++++++++++ servatrice/docker/servatrice-docker.ini | 7 +++++++ 3 files changed, 48 insertions(+) create mode 100644 docker-compose.yml create mode 100644 servatrice/docker/servatrice-docker.ini diff --git a/README.md b/README.md index 7271960e..0266fab4 100644 --- a/README.md +++ b/README.md @@ -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). +**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) Cockatrice is free software, licensed under the [GPLv2](https://github.com/Cockatrice/Cockatrice/blob/master/LICENSE). diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 00000000..515aeb64 --- /dev/null +++ b/docker-compose.yml @@ -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 diff --git a/servatrice/docker/servatrice-docker.ini b/servatrice/docker/servatrice-docker.ini new file mode 100644 index 00000000..59af1caf --- /dev/null +++ b/servatrice/docker/servatrice-docker.ini @@ -0,0 +1,7 @@ +[database] +type=mysql +prefix=cockatrice +hostname=mysql +database=servatrice +user=servatrice +password=password