From 7153b366e52f3784ec4cbfeae0d059a34cdb9a05 Mon Sep 17 00:00:00 2001 From: Ru Singh Date: Wed, 19 May 2021 19:19:39 +0530 Subject: [PATCH] chore(docker): improve repeat contributions workflow (#1057) * This change adds two new commands to gracefully stop and remove the Postgres and Clickhouse docker containers. To do so, it also gives them a recognizable name. * Additionally, the Postgres container is updated to use a named volume for its data. This lower friction for repeat contributions where one would otherwise sign up and activate their accounts again and again each time. --- CONTRIBUTING.md | 7 +++++++ Makefile | 10 ++++++++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 3f96b4fd6..1435daf2b 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -23,3 +23,10 @@ Make sure Docker, Elixir, Erlang and Node.js are all installed on your developme 3. Fill in the rest of the forms and for the domain use `dummy.site` 4. Run `make dummy_event` from the terminal to generate a fake pageview event for the dummy site. 5. You should now be all set! + +### Stopping Docker containers + +1. Stop and remove the Postgres container with `make postgres-stop`. +2. Stop and remove the Clickhouse container with `make clickhouse-stop`. + +Volumes are preserved. You'll find that the Postgres and Clickhouse state are retained when you bring them up again the next time: no need to re-register and so on. \ No newline at end of file diff --git a/Makefile b/Makefile index e669b6326..5e7c5c94e 100644 --- a/Makefile +++ b/Makefile @@ -1,8 +1,14 @@ clickhouse: - docker run --detach -p 8123:8123 --ulimit nofile=262144:262144 --volume=$$PWD/.clickhouse_db_vol:/var/lib/clickhouse yandex/clickhouse-server:21.3.2.5 + docker run --detach -p 8123:8123 --ulimit nofile=262144:262144 --volume=$$PWD/.clickhouse_db_vol:/var/lib/clickhouse --name plausible_clickhouse yandex/clickhouse-server:21.3.2.5 + +clickhouse-stop: + docker stop plausible_clickhouse && docker rm plausible_clickhouse postgres: - docker run --detach -e POSTGRES_PASSWORD="postgres" -p 5432:5432 postgres:12 + docker run --detach -e POSTGRES_PASSWORD="postgres" -p 5432:5432 --volume=plausible_db:/var/lib/postgresql/data --name plausible_db postgres:12 + +postgres-stop: + docker stop plausible_db && docker rm plausible_db dummy_event: curl 'http://localhost:8000/api/event' \