Skip to content

Commit

Permalink
feat: Add full docker-compose support and documentation
Browse files Browse the repository at this point in the history
* Annotated docker-compose file
* simplified CM config.yaml for docker-compose "base"
* instructions for usage in installation docs
  • Loading branch information
FoxxMD committed Nov 1, 2022
1 parent 1271eee commit e11a1d2
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 49 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ Feature highlights for **Developers and Hosting (Operators):**
* [Database Persistence](/docs/operator/database.md) using SQLite, MySql, or Postgres
* Audit trails for bot activity
* Historical statistics
* [Docker container support](/docs/operator/installation.md#docker-recommended)
* [Docker container](/docs/operator/installation.md#docker-recommended) and [docker-compose](/docs/operator/installation.md#docker-compose) support
* Easy, UI-based [OAuth authentication](/docs/operator/addingBot.md) for adding Bots and moderator dashboard
* Integration with [InfluxDB](https://www.influxdata.com) for detailed [time-series metrics](/docs/operator/database.md#influx) and a pre-built [Grafana](https://grafana.com) [dashboard](/docs/operator/database.md#grafana)

Expand Down
26 changes: 20 additions & 6 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,25 @@ version: '3.7'

services:
app:
build:
context: .
image: foxxmd/context-mod:latest
# use the settings below, instead of 'image', if running context-mod from the repository (developing local changes)
# build:
# context: .
volumes:
- './cmAppData/config:/config'
# Location of config file to use with CM
# The path BEFORE the colon (:) is the path on the host machine
# which defaults to a folder named 'data' in the same directory this file is run in.
- './data:/config'
# For a new installation you should use the config from the repository included for use with docker-compose
# https://github.com/FoxxMD/context-mod/blob/master/docker/config/docker-compose/config.yaml
# Copy config.yaml to /(this directory)/data/config.yaml and then modify to match any changed settings below (see comments on config.yaml)
ports:
- "${CM_WEB-8085}:8085"
environment:
IS_DOCKER: true
# If using a linux host, uncomment these and set them accordingly https://github.com/FoxxMD/context-mod/blob/master/docs/operator/installation.md#linux-host
# PUID: 1000
# PGID: 1000

cache:
image: 'redis:7-alpine'
Expand All @@ -17,15 +30,16 @@ services:
environment:
MYSQL_ROOT_PASSWORD: CHANGE_THIS
MYSQL_USER: cmuser
# this should match the password set in config.yaml
MYSQL_PASSWORD: CHANGE_THIS
MYSQL_DATABASE: ContextMod
volumes:
- './cmAppData/db:/var/lib/mysql'
- './data/db:/var/lib/mysql'

influx:
image: 'influxdb:latest'
volumes:
- './cmAppData/influx:/var/lib/influxdb2'
- './data/influx:/var/lib/influxdb2'
ports:
- "${INFLUX_WEB:-8086}:8086"
profiles:
Expand All @@ -34,7 +48,7 @@ services:
grafana:
image: 'grafana/grafana'
volumes:
- './cmAppData/grafana:/var/lib/grafana'
- './data/grafana:/var/lib/grafana'
ports:
- "${GRAFANA_WEB:-3000}:3000"
environment:
Expand Down
34 changes: 0 additions & 34 deletions docker/config/docker-compose/config.min.yaml

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
operator:
name: #YOUR REDDIT USERNAME HERE
botName: ContextModMain
name: CHANGE_THIS #YOUR REDDIT USERNAME HERE
logging:
# default level for all transports
level: debug
Expand All @@ -24,6 +23,7 @@ databaseConfig:
type: 'mariadb'
host: 'database'
username: 'cmuser'
# This should match the password set in docker-compose.yaml
password: 'CHANGE_THIS'
database: 'ContextMod'
web:
Expand All @@ -32,9 +32,12 @@ web:
session:
storage: cache
port: 8085
influxConfig:
credentials:
url: 'http://influx:8086'
token: 'YourInfluxToken'
org: YourInfluxOrg
bucket: contextmod
#
# Influx/Grafana requires additional configuration. See https://github.com/FoxxMD/context-mod/blob/master/docs/operator/database.md#influx
#
#influxConfig:
# credentials:
# url: 'http://influx:8086'
# token: 'YourInfluxToken'
# org: YourInfluxOrg
# bucket: contextmod
26 changes: 26 additions & 0 deletions docs/operator/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,32 @@ To get the UID and GID for the current user run these commands from a terminal:
docker run -d -v /host/path/folder:/config -p 8085:8085 -e PUID=1000 -e PGID=1000 ghcr.io/foxxmd/context-mod:latest
```

### Docker-Compose

The included [`docker-compose.yml`](/docker-compose.yml) provides production-ready dependencies for CM to use:

* [Redis](https://redis.io/) for caching
* [MariaDB](https://mariadb.org/) for database
* Optionally, [Influx/Grafana](/docs/operator/database.md#influx) instances

#### Setup

For new installations copy [`config.yaml`](/docker/config/docker-compose/config.yaml) into a folder named `data` in the same folder `docker-compose.yml` will be run from. For users migrating their existing CM instances to docker-compose, copy your existing `config.yaml` into the same `data` folder.

Read through the comments in both `docker-compose.yml` and `config.yaml` and makes changes to any relevant settings (passwords, usernames, etc...). Ensure that any settings used in both files (EX mariaDB passwords) match.

To build and start CM:

```bash
docker-compose up -d
```

To include Grafana/Influx dependencies run:

```bash
docker-compose --profile full up -d
```

## Locally

Requirements:
Expand Down

0 comments on commit e11a1d2

Please sign in to comment.