From 227aa659a1f7fcca07e7a32874002d9fb3497066 Mon Sep 17 00:00:00 2001 From: Jaimyn Mayer Date: Fri, 4 Aug 2023 09:42:28 +1000 Subject: [PATCH] updated docker compose file --- docker/docker-compose.yml | 83 +++++++++++++++++--------- docs/GETTING_STARTED.md | 14 ++++- memberportal/membermatters/settings.py | 2 +- 3 files changed, 69 insertions(+), 30 deletions(-) diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml index a6f7d3c8..45c2e815 100644 --- a/docker/docker-compose.yml +++ b/docker/docker-compose.yml @@ -1,49 +1,76 @@ version: "3" services: - # MemberMatters - membermatters: - image: membermatters/membermatters:celery + mm-postgres: + image: postgres:15.3-alpine restart: always environment: - PORTAL_ENV: "Production" - MM_REDIS_HOST: 'redis://membermatters-redis:6379/0' - volumes: - - ./:/usr/src/data + - POSTGRES_USER=membermatters + - POSTGRES_PASSWORD=membermatters + - POSTGRES_DB=membermatters ports: - - "8000:8000" + - "5432:5432" + volumes: + - mm-postgres-volume:/var/lib/postgresql/data + healthcheck: + test: ["CMD-SHELL", "pg_isready -U membermatters"] + interval: 5s + timeout: 5s + retries: 5 # MemberMatters Redis - membermatters-redis: + mm-redis: image: redis restart: always depends_on: - - membermatters + - mm-postgres + + # MemberMatters + mm-webapp: + image: membermatters/membermatters + restart: always + environment: + MM_ENV: "Production" + MM_SECRET_KEY: "CHANGE_ME" + MM_USE_POSTGRES: True + MM_REDIS_HOST: "redis://mm-redis:6379/0" + ports: + - "8000:8000" + depends_on: + - mm-postgres + - mm-redis + healthcheck: + test: ["CMD", "curl", "-f", "http://localhost:8000"] + interval: 5s + timeout: 5s + retries: 15 # MemberMatters Celery Worker - membermatters-celery-worker: - image: membermatters/membermatters:celery + mm-celery-worker: + image: membermatters/membermatters restart: always environment: - PORTAL_ENV: "Production" + MM_ENV: "Production" + MM_USE_POSTGRES: True MM_RUN_MODE: "celery_worker" - MM_REDIS_HOST: 'redis://membermatters-redis:6379/0' - volumes: - - ./:/usr/src/data + MM_REDIS_HOST: "redis://mm-redis:6379/0" depends_on: - - membermatters - - membermatters-redis + - mm-webapp + - mm-redis - # MemberMatters Celery Worker - membermatters-celery-beat: - image: membermatters/membermatters:celery + # MemberMatters Celery Beat + mm-celery-beat: + image: membermatters/membermatters restart: always environment: - PORTAL_ENV: "Production" + MM_ENV: "Production" + MM_USE_POSTGRES: True MM_RUN_MODE: "celery_beat" - MM_REDIS_HOST: 'redis://membermatters-redis:6379/0' - volumes: - - ./:/usr/src/data + MM_REDIS_HOST: "redis://mm-redis:6379/0" depends_on: - - membermatters - - membermatters-celery-worker - - membermatters-redis \ No newline at end of file + - mm-webapp + - mm-celery-worker + - mm-redis + +volumes: + mm-postgres-volume: + driver: local diff --git a/docs/GETTING_STARTED.md b/docs/GETTING_STARTED.md index 83056595..945ff6f1 100644 --- a/docs/GETTING_STARTED.md +++ b/docs/GETTING_STARTED.md @@ -35,7 +35,19 @@ docker stop membermatters docker restart membermatters ``` -Once your container is running, you will be able to login with the default admin account details: +Once your container is running, you will probably want to load the initial database fixtures so there's an account you can use to login with. To do so, connect to your running docker container: + +```bash +docker exec -it membermatters bash +``` + +and run the following: + +```bash +python3 manage.py loaddata initial +``` + +Once you've loaded the initial fixtures, you will be able to login with the default admin account details: ``` Email: default@example.com diff --git a/memberportal/membermatters/settings.py b/memberportal/membermatters/settings.py index 79abc5df..c1f90a89 100644 --- a/memberportal/membermatters/settings.py +++ b/memberportal/membermatters/settings.py @@ -146,7 +146,7 @@ "USER": os.environ.get("POSTGRES_USER", "membermatters"), "PASSWORD": os.environ.get("POSTGRES_PASSWORD", "membermatters"), "HOST": os.environ.get( - "POSTGRES_HOST", "membermatters-postgres" + "POSTGRES_HOST", "mm-postgres" ), # default for docker-compose - change if needed "PORT": os.environ.get("POSTGRES_PORT", "5432"), }