Makefile 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. .PHONY: help install server clickhouse clickhouse-prod clickhouse-stop postgres postgres-prod postgres-stop
  2. help:
  3. @perl -nle'print $& if m{^[a-zA-Z_-]+:.*?## .*$$}' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
  4. install: ## Run the initial setup
  5. mix deps.get
  6. mix ecto.create
  7. mix ecto.migrate
  8. mix download_country_database
  9. npm install --prefix assets
  10. npm install --prefix tracker
  11. npm run deploy --prefix tracker
  12. server: ## Start the web server
  13. mix phx.server
  14. CH_FLAGS ?= --detach -p 8123:8123 -p 9000:9000 --ulimit nofile=262144:262144 --name plausible_clickhouse
  15. clickhouse: ## Start a container with a recent version of clickhouse
  16. docker run $(CH_FLAGS) --volume=$$PWD/.clickhouse_db_vol:/var/lib/clickhouse clickhouse/clickhouse-server:latest-alpine
  17. clickhouse-prod: ## Start a container with the same version of clickhouse as the one in prod
  18. docker run $(CH_FLAGS) --volume=$$PWD/.clickhouse_db_vol_prod:/var/lib/clickhouse clickhouse/clickhouse-server:23.3.7.5-alpine
  19. clickhouse-stop: ## Stop and remove the clickhouse container
  20. docker stop plausible_clickhouse && docker rm plausible_clickhouse
  21. PG_FLAGS ?= --detach -e POSTGRES_PASSWORD="postgres" -p 5432:5432 --name plausible_db
  22. postgres: ## Start a container with a recent version of postgres
  23. docker run $(PG_FLAGS) --volume=plausible_db:/var/lib/postgresql/data postgres:latest
  24. postgres-prod: ## Start a container with the same version of postgres as the one in prod
  25. docker run $(PG_FLAGS) --volume=plausible_db_prod:/var/lib/postgresql/data postgres:15
  26. postgres-stop: ## Stop and remove the postgres container
  27. docker stop plausible_db && docker rm plausible_db