From 19e7fc4c007155f290ed4b9370ce9351dea5de1d Mon Sep 17 00:00:00 2001 From: Joey Orlando Date: Wed, 23 Nov 2022 19:31:26 +0100 Subject: [PATCH] remove hostess tool + add extra_hosts entry to oncall backend containers --- Makefile | 19 +------------------ docker-compose-developer.yml | 18 +++++++++++++++++- 2 files changed, 18 insertions(+), 19 deletions(-) diff --git a/Makefile b/Makefile index 7fc5b021..79f3fbaa 100644 --- a/Makefile +++ b/Makefile @@ -62,12 +62,6 @@ define run_engine_docker_command endef # touch SQLITE_DB_FILE if it does not exist and DB is eqaul to SQLITE_PROFILE -# -# hostess installation (crossplatform/idempotent modification of /etc/hosts file) -# see here (https://github.com/cbednarski/hostess#installation) for docs -# basically this is needed because oncall api has been configured locally to communicate w/ grafana @ -# http://grafana:3000. This becomes a problem in certain parts of OnCall where we generate "public" URLs -# and the user tries to access them via their browser. start: ifeq ($(DB),$(SQLITE_PROFILE)) @if [ ! -f $(SQLITE_DB_FILE) ]; then \ @@ -75,17 +69,6 @@ ifeq ($(DB),$(SQLITE_PROFILE)) fi endif - @if [ ! -x "$$(command -v hostess)" ]; then \ - echo "installing hostess"; \ - git clone https://github.com/cbednarski/hostess "${HOME}/hostess"; \ - cd "${HOME}/hostess"; \ - make install; \ - fi - - @if ! hostess has grafana; then \ - sudo hostess add grafana 127.0.0.1; \ - fi - $(call run_docker_compose_command,up --remove-orphans -d) init: @@ -168,4 +151,4 @@ backend-command: $(call backend_command,$(CMD)) backend-manage-command: - $(call backend_command,python manage.py $(CMD)) \ No newline at end of file + $(call backend_command,python manage.py $(CMD)) diff --git a/docker-compose-developer.yml b/docker-compose-developer.yml index b76d5734..e8208bbb 100644 --- a/docker-compose-developer.yml +++ b/docker-compose-developer.yml @@ -20,7 +20,19 @@ x-env-files: &oncall-env-files x-env-vars: &oncall-env-vars BROKER_TYPE: ${BROKER_TYPE} - GRAFANA_API_URL: http://grafana:3000 + GRAFANA_API_URL: http://localhost:3000 + +# basically this is needed because the oncall backend containers have been configured to communicate w/ grafana via +# http://localhost:3000 (GRAFANA_API_URL). This URL is used in two scenarios: +# 1. oncall backend -> grafana API communication (happens within docker) +# 2. accessing templated URLs generated by the oncall backend - meant to be accessed via a browser on your host machine +# The alternative is to set GRAFANA_API_URL to http://grafana:3000. However, this would only work in scenario #1 +# as http://grafana:3000 would not be resolvable on the host machine (without modifying /etc/hosts) +# +# by adding this extra_host entry to the oncall backend containers any calls to localhost will get routed to the docker +# gateway, onto the host machine, where localhost:3000 points to grafana +x-extra-hosts: &oncall-extra-hosts + - "localhost:host-gateway" services: oncall_ui: @@ -49,6 +61,7 @@ services: env_file: *oncall-env-files environment: *oncall-env-vars volumes: *oncall-volumes + extra_hosts: *oncall-extra-hosts ports: - "8080:8080" depends_on: @@ -68,6 +81,7 @@ services: env_file: *oncall-env-files environment: *oncall-env-vars volumes: *oncall-volumes + extra_hosts: *oncall-extra-hosts profiles: # no need to start this except from within the Makefile - _engine_commands @@ -81,6 +95,7 @@ services: env_file: *oncall-env-files environment: *oncall-env-vars volumes: *oncall-volumes + extra_hosts: *oncall-extra-hosts depends_on: oncall_db_migration: condition: service_completed_successfully @@ -95,6 +110,7 @@ services: env_file: *oncall-env-files environment: *oncall-env-vars volumes: *oncall-volumes + extra_hosts: *oncall-extra-hosts depends_on: postgres: condition: service_healthy