From c7c3aa823c04a87d0df555ad9abd067816ddca89 Mon Sep 17 00:00:00 2001 From: Joey Orlando Date: Thu, 10 Nov 2022 16:04:30 +0100 Subject: [PATCH] local dev setup - fixes for some minor issues (#821) * use docker compose instead of docker-compose the former is the newer version, latter is being deprecated * default to using latest version of grafana, not main main is "bleeding-edge" grafana, use the more stable "latest" tag * support requirements-enterprise.txt for both docker/non-docker setups * backend-bootstrap make command should install enterprise requirements if the file is there * only mount the sqlite db file in docker-compose if using sqlite as the DB --- Makefile | 21 ++++++++++++++++----- docker-compose-developer.yml | 4 ++-- engine/.gitignore | 2 +- engine/Dockerfile | 2 +- 4 files changed, 20 insertions(+), 9 deletions(-) diff --git a/Makefile b/Makefile index c2ad98d1..d894fe18 100644 --- a/Makefile +++ b/Makefile @@ -16,6 +16,8 @@ DEV_ENV_FILE = $(DEV_ENV_DIR)/.env.dev DEV_ENV_EXAMPLE_FILE = $(DEV_ENV_FILE).example ENGINE_DIR = ./engine +REQUIREMENTS_TXT = $(ENGINE_DIR)/requirements.txt +REQUIREMENTS_ENTERPRISE_TXT = $(ENGINE_DIR)/requirements-enterprise.txt SQLITE_DB_FILE = $(ENGINE_DIR)/oncall.db # -n flag only copies DEV_ENV_EXAMPLE_FILE-> DEV_ENV_FILE if it doesn't already exist @@ -45,12 +47,18 @@ else BROKER_TYPE=$(REDIS_PROFILE) endif -define run_engine_docker_command - DB=$(DB) BROKER_TYPE=$(BROKER_TYPE) docker-compose -f $(DOCKER_COMPOSE_FILE) run --rm oncall_engine_commands $(1) -endef +# SQLITE_DB_FiLE is set to properly mount the sqlite db file +DOCKER_COMPOSE_ENV_VARS := COMPOSE_PROFILES=$(COMPOSE_PROFILES) DB=$(DB) BROKER_TYPE=$(BROKER_TYPE) +ifeq ($(DB),$(SQLITE_PROFILE)) + DOCKER_COMPOSE_ENV_VARS += SQLITE_DB_FILE=$(SQLITE_DB_FILE) +endif define run_docker_compose_command - COMPOSE_PROFILES=$(COMPOSE_PROFILES) DB=$(DB) BROKER_TYPE=$(BROKER_TYPE) docker-compose -f $(DOCKER_COMPOSE_FILE) $(1) + $(DOCKER_COMPOSE_ENV_VARS) docker compose -f $(DOCKER_COMPOSE_FILE) $(1) +endef + +define run_engine_docker_command + $(call run_docker_compose_command,run --rm oncall_engine_commands $(1)) endef # touch SQLITE_DB_FILE if it does not exist and DB is eqaul to SQLITE_PROFILE @@ -128,7 +136,10 @@ endef backend-bootstrap: pip install -U pip wheel - cd engine && pip install -r requirements.txt + pip install -r $(REQUIREMENTS_TXT) + @if [ -f $(REQUIREMENTS_ENTERPRISE_TXT) ]; then \ + pip install -r $(REQUIREMENTS_ENTERPRISE_TXT); \ + fi backend-migrate: $(call backend_command,python manage.py migrate) diff --git a/docker-compose-developer.yml b/docker-compose-developer.yml index 0cc79491..a784459e 100644 --- a/docker-compose-developer.yml +++ b/docker-compose-developer.yml @@ -12,7 +12,7 @@ x-oncall-volumes: &oncall-volumes - ./engine:/etc/app # https://stackoverflow.com/a/60456034 - ${ENTERPRISE_ENGINE:-/dev/null}:/etc/app/extensions/engine_enterprise - - ./engine/oncall.db:/var/lib/oncall/oncall.db + - ${SQLITE_DB_FILE:-/dev/null}:/var/lib/oncall/oncall.db x-env-files: &oncall-env-files - ./dev/.env.dev @@ -235,7 +235,7 @@ services: grafana: container_name: grafana labels: *oncall-labels - image: "grafana/grafana:${GRAFANA_VERSION:-main}" + image: "grafana/grafana:${GRAFANA_VERSION:-latest}" restart: always environment: GF_SECURITY_ADMIN_USER: oncall diff --git a/engine/.gitignore b/engine/.gitignore index 1193cff7..04b9e080 100644 --- a/engine/.gitignore +++ b/engine/.gitignore @@ -1,4 +1,4 @@ -requirements-enterprise.txt +requirements-enterprise*.txt extensions/ uwsgi-local.ini celerybeat-schedule diff --git a/engine/Dockerfile b/engine/Dockerfile index 0367b53a..4c84a01c 100644 --- a/engine/Dockerfile +++ b/engine/Dockerfile @@ -19,7 +19,7 @@ FROM base AS dev RUN apk add sqlite mysql-client postgresql-client FROM dev AS dev-enterprise -RUN pip install -r requirements-enterprise.txt +RUN pip install -r requirements-enterprise-docker.txt FROM base AS prod