diff options
| author | 2021-09-17 13:34:15 +0100 | |
|---|---|---|
| committer | 2021-09-17 13:34:15 +0100 | |
| commit | 3c1cc75371fa8be3e1de3affa7b5a1f54b55da6b (patch) | |
| tree | 5eebf3132bbcb0573c6a27ac7bbace708537c8bb | |
| parent | Merge pull request #1826 from python-discord/ignore-voting (diff) | |
Add metricity to docker-compose
By adding metricity to the compose, we allow it to migrate itself, rather than needing the site to do it.
Defaulting 'USE_METRICITY' to false means that it will run migrations, but not actually start the bot. This means we don't add another service that needs to run all the time, which could impact some contribs on lower powered hardware.
| -rw-r--r-- | .gitignore | 1 | ||||
| -rw-r--r-- | docker-compose.yml | 22 | 
2 files changed, 22 insertions, 1 deletions
diff --git a/.gitignore b/.gitignore index f74a142f3..177345908 100644 --- a/.gitignore +++ b/.gitignore @@ -116,6 +116,7 @@ log.*  # Custom user configuration  config.yml  docker-compose.override.yml +metricity-config.toml  # xmlrunner unittest XML reports  TEST-**.xml diff --git a/docker-compose.yml b/docker-compose.yml index 0f0355dac..b3ca6baa4 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -23,6 +23,11 @@ services:        POSTGRES_DB: pysite        POSTGRES_PASSWORD: pysite        POSTGRES_USER: pysite +    healthcheck: +      test: ["CMD-SHELL", "pg_isready -U pysite"] +      interval: 2s +      timeout: 1s +      retries: 5    redis:      << : *logging @@ -31,6 +36,21 @@ services:      ports:        - "127.0.0.1:6379:6379" +  metricity: +    << : *logging +    restart: on-failure  # USE_METRICITY=false will stop the container, so this ensures it only restarts on error +    depends_on: +      postgres: +        condition: service_healthy +    image: ghcr.io/python-discord/metricity:latest +    env_file: +      - .env +    environment: +      DATABASE_URI: postgres://pysite:pysite@postgres/metricity +      USE_METRICITY: ${USE_METRICITY-false} +    volumes: +      - .:/tmp/bot:ro +    snekbox:      << : *logging      << : *restart_policy @@ -56,7 +76,7 @@ services:        - "127.0.0.1:8000:8000"      tty: true      depends_on: -      - postgres +      - metricity      environment:        DATABASE_URL: postgres://pysite:pysite@postgres:5432/pysite        METRICITY_DB_URL: postgres://pysite:pysite@postgres:5432/metricity  |