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
This commit is contained in:
Joey Orlando 2022-11-10 16:04:30 +01:00 committed by GitHub
parent f3ac66b8bd
commit c7c3aa823c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 20 additions and 9 deletions

View file

@ -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)

View file

@ -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

2
engine/.gitignore vendored
View file

@ -1,4 +1,4 @@
requirements-enterprise.txt
requirements-enterprise*.txt
extensions/
uwsgi-local.ini
celerybeat-schedule

View file

@ -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