2022-11-09 07:21:33 +01:00
|
|
|
version: "3.9"
|
2022-06-03 08:09:47 -06:00
|
|
|
|
2022-11-07 16:34:43 +01:00
|
|
|
x-labels: &oncall-labels
|
|
|
|
|
- "com.grafana.oncall.env=dev"
|
|
|
|
|
|
2023-06-13 12:56:06 +02:00
|
|
|
x-user: &oncall-user "appuser"
|
2023-06-08 13:12:00 +06:00
|
|
|
|
2022-11-07 16:34:43 +01:00
|
|
|
x-oncall-build: &oncall-build-args
|
|
|
|
|
context: ./engine
|
2022-11-09 07:21:33 +01:00
|
|
|
target: ${ONCALL_IMAGE_TARGET:-dev}
|
2022-11-07 16:34:43 +01:00
|
|
|
labels: *oncall-labels
|
|
|
|
|
|
|
|
|
|
x-oncall-volumes: &oncall-volumes
|
|
|
|
|
- ./engine:/etc/app
|
2023-06-07 12:51:58 +02:00
|
|
|
# see all the fun answers/comments here on why we need to do this
|
|
|
|
|
# tldr; using /dev/null as a default leads to a lot of fun problems
|
2022-11-09 07:21:33 +01:00
|
|
|
# https://stackoverflow.com/a/60456034
|
2023-06-07 12:51:58 +02:00
|
|
|
- ${ENTERPRISE_ENGINE:-/dev/null}:${ENTERPRISE_ENGINE_VOLUME_MOUNT_DEST_DIR:-/tmp/empty:ro}
|
2022-11-10 16:04:30 +01:00
|
|
|
- ${SQLITE_DB_FILE:-/dev/null}:/var/lib/oncall/oncall.db
|
2022-11-29 09:41:56 +01:00
|
|
|
# this is mounted for testing purposes. Some of the authorization tests
|
|
|
|
|
# reference this file
|
|
|
|
|
- ./grafana-plugin/src/plugin.json:/etc/grafana-plugin/src/plugin.json
|
2022-11-07 16:34:43 +01:00
|
|
|
|
|
|
|
|
x-env-files: &oncall-env-files
|
|
|
|
|
- ./dev/.env.dev
|
|
|
|
|
- ./dev/.env.${DB}.dev
|
|
|
|
|
|
|
|
|
|
x-env-vars: &oncall-env-vars
|
|
|
|
|
BROKER_TYPE: ${BROKER_TYPE}
|
2022-11-23 19:31:26 +01:00
|
|
|
GRAFANA_API_URL: http://localhost:3000
|
2022-12-20 12:41:34 +01:00
|
|
|
GOOGLE_APPLICATION_CREDENTIALS: /etc/app/gcp_service_account.json
|
2023-05-22 14:32:21 +01:00
|
|
|
FCM_PROJECT_ID: oncall-mobile-dev
|
2022-11-23 19:31:26 +01:00
|
|
|
|
|
|
|
|
# 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"
|
2022-11-07 16:34:43 +01:00
|
|
|
|
2022-06-03 08:09:47 -06:00
|
|
|
services:
|
2022-11-07 16:34:43 +01:00
|
|
|
oncall_ui:
|
|
|
|
|
container_name: oncall_ui
|
|
|
|
|
labels: *oncall-labels
|
|
|
|
|
build:
|
|
|
|
|
context: ./grafana-plugin
|
|
|
|
|
dockerfile: Dockerfile.dev
|
|
|
|
|
labels: *oncall-labels
|
2022-11-21 16:26:00 +01:00
|
|
|
environment:
|
|
|
|
|
ONCALL_API_URL: http://host.docker.internal:8080
|
2022-12-20 12:41:34 +01:00
|
|
|
MOBILE_APP_QR_INTERVAL_QUEUE: 290000 # 4 minutes and 50 seconds
|
2022-11-07 16:34:43 +01:00
|
|
|
volumes:
|
|
|
|
|
- ./grafana-plugin:/etc/app
|
2023-05-17 22:12:51 +02:00
|
|
|
- node_modules_dev:/etc/app/node_modules
|
2022-11-09 07:21:33 +01:00
|
|
|
# https://stackoverflow.com/a/60456034
|
2023-06-13 12:56:06 +02:00
|
|
|
# see the explaination above that uses the $ENTERPRISE_ENGINE env var
|
|
|
|
|
- ${ENTERPRISE_FRONTEND:-/dev/null}:${ENTERPRISE_FRONTEND_VOLUME_MOUNT_DEST_DIR:-/tmp/empty:ro}
|
2022-11-07 16:34:43 +01:00
|
|
|
profiles:
|
|
|
|
|
- oncall_ui
|
|
|
|
|
|
|
|
|
|
oncall_engine:
|
|
|
|
|
container_name: oncall_engine
|
|
|
|
|
labels: *oncall-labels
|
|
|
|
|
build: *oncall-build-args
|
2022-06-03 08:09:47 -06:00
|
|
|
restart: always
|
2023-06-08 13:12:00 +06:00
|
|
|
user: *oncall-user
|
2023-02-02 09:08:48 +00:00
|
|
|
command: sh -c "uwsgi --disable-logging --py-autoreload 3 --ini uwsgi.ini"
|
2022-11-07 16:34:43 +01:00
|
|
|
env_file: *oncall-env-files
|
|
|
|
|
environment: *oncall-env-vars
|
|
|
|
|
volumes: *oncall-volumes
|
2022-11-23 19:31:26 +01:00
|
|
|
extra_hosts: *oncall-extra-hosts
|
2022-06-03 08:09:47 -06:00
|
|
|
ports:
|
2022-11-07 16:34:43 +01:00
|
|
|
- "8080:8080"
|
|
|
|
|
depends_on:
|
|
|
|
|
oncall_db_migration:
|
|
|
|
|
condition: service_completed_successfully
|
|
|
|
|
profiles:
|
|
|
|
|
- engine
|
|
|
|
|
|
|
|
|
|
# used to invoke one-off commands, primarily from the Makefile
|
|
|
|
|
# oncall_engine couldn't (easily) be used due to it's depends_on property
|
|
|
|
|
# we could alternatively just use `docker run` however that would require
|
|
|
|
|
# duplicating the env-files, volume mounts, etc in the Makefile
|
|
|
|
|
oncall_engine_commands:
|
|
|
|
|
container_name: oncall_engine_commands
|
|
|
|
|
labels: *oncall-labels
|
|
|
|
|
build: *oncall-build-args
|
2023-06-08 13:12:00 +06:00
|
|
|
user: *oncall-user
|
2022-11-07 16:34:43 +01:00
|
|
|
env_file: *oncall-env-files
|
|
|
|
|
environment: *oncall-env-vars
|
|
|
|
|
volumes: *oncall-volumes
|
2022-11-23 19:31:26 +01:00
|
|
|
extra_hosts: *oncall-extra-hosts
|
2022-11-07 16:34:43 +01:00
|
|
|
profiles:
|
|
|
|
|
# no need to start this except from within the Makefile
|
|
|
|
|
- _engine_commands
|
|
|
|
|
|
|
|
|
|
oncall_celery:
|
|
|
|
|
container_name: oncall_celery
|
|
|
|
|
labels: *oncall-labels
|
|
|
|
|
build: *oncall-build-args
|
|
|
|
|
restart: always
|
2023-06-08 13:12:00 +06:00
|
|
|
user: *oncall-user
|
2022-11-07 16:34:43 +01:00
|
|
|
command: "python manage.py start_celery"
|
|
|
|
|
env_file: *oncall-env-files
|
|
|
|
|
environment: *oncall-env-vars
|
|
|
|
|
volumes: *oncall-volumes
|
2022-11-23 19:31:26 +01:00
|
|
|
extra_hosts: *oncall-extra-hosts
|
2022-11-07 16:34:43 +01:00
|
|
|
depends_on:
|
|
|
|
|
oncall_db_migration:
|
|
|
|
|
condition: service_completed_successfully
|
|
|
|
|
profiles:
|
|
|
|
|
- engine
|
|
|
|
|
|
2022-12-20 12:41:34 +01:00
|
|
|
flower:
|
|
|
|
|
container_name: flower
|
|
|
|
|
labels: *oncall-labels
|
|
|
|
|
image: mher/flower:1.2.0
|
|
|
|
|
environment:
|
|
|
|
|
# TODO: make this work properly w/ BROKER_TYPE env var
|
|
|
|
|
CELERY_BROKER_URL: "redis://redis:6379/0"
|
|
|
|
|
ports:
|
|
|
|
|
- "5555:5555"
|
|
|
|
|
depends_on:
|
|
|
|
|
oncall_celery:
|
|
|
|
|
condition: service_started
|
|
|
|
|
profiles:
|
|
|
|
|
- engine
|
|
|
|
|
|
2022-11-07 16:34:43 +01:00
|
|
|
oncall_db_migration:
|
|
|
|
|
container_name: oncall_db_migration
|
|
|
|
|
labels: *oncall-labels
|
|
|
|
|
build: *oncall-build-args
|
2023-06-08 13:12:00 +06:00
|
|
|
user: *oncall-user
|
2022-11-07 16:34:43 +01:00
|
|
|
command: "python manage.py migrate --noinput"
|
|
|
|
|
env_file: *oncall-env-files
|
|
|
|
|
environment: *oncall-env-vars
|
|
|
|
|
volumes: *oncall-volumes
|
2022-11-23 19:31:26 +01:00
|
|
|
extra_hosts: *oncall-extra-hosts
|
2022-11-07 16:34:43 +01:00
|
|
|
depends_on:
|
|
|
|
|
postgres:
|
|
|
|
|
condition: service_healthy
|
|
|
|
|
mysql:
|
|
|
|
|
condition: service_healthy
|
|
|
|
|
rabbitmq:
|
|
|
|
|
condition: service_healthy
|
|
|
|
|
redis:
|
|
|
|
|
condition: service_healthy
|
|
|
|
|
profiles:
|
|
|
|
|
- engine
|
2022-06-03 08:09:47 -06:00
|
|
|
|
|
|
|
|
redis:
|
2022-11-07 16:34:43 +01:00
|
|
|
container_name: redis
|
|
|
|
|
labels: *oncall-labels
|
|
|
|
|
image: redis:7.0.5
|
2022-06-03 08:09:47 -06:00
|
|
|
restart: always
|
|
|
|
|
ports:
|
2022-09-29 12:09:29 +01:00
|
|
|
- "6379:6379"
|
|
|
|
|
deploy:
|
2022-11-07 16:34:43 +01:00
|
|
|
labels: *oncall-labels
|
2022-09-29 12:09:29 +01:00
|
|
|
resources:
|
|
|
|
|
limits:
|
2022-11-07 16:34:43 +01:00
|
|
|
memory: 500m
|
|
|
|
|
cpus: "0.5"
|
|
|
|
|
healthcheck:
|
|
|
|
|
test: ["CMD", "redis-cli", "ping"]
|
|
|
|
|
timeout: 5s
|
|
|
|
|
interval: 5s
|
|
|
|
|
retries: 10
|
|
|
|
|
volumes:
|
|
|
|
|
- redisdata_dev:/data
|
|
|
|
|
profiles:
|
|
|
|
|
- redis
|
2022-06-03 08:09:47 -06:00
|
|
|
|
2022-11-07 16:34:43 +01:00
|
|
|
rabbitmq:
|
|
|
|
|
container_name: rabbitmq
|
|
|
|
|
labels: *oncall-labels
|
2023-06-29 12:49:00 +02:00
|
|
|
image: "rabbitmq:3.12.0-management"
|
2022-11-07 16:34:43 +01:00
|
|
|
restart: always
|
2022-06-03 08:09:47 -06:00
|
|
|
environment:
|
|
|
|
|
RABBITMQ_DEFAULT_USER: "rabbitmq"
|
|
|
|
|
RABBITMQ_DEFAULT_PASS: "rabbitmq"
|
|
|
|
|
RABBITMQ_DEFAULT_VHOST: "/"
|
2022-11-07 16:34:43 +01:00
|
|
|
ports:
|
|
|
|
|
- "15672:15672"
|
|
|
|
|
- "5672:5672"
|
2022-09-29 12:09:29 +01:00
|
|
|
deploy:
|
2022-11-07 16:34:43 +01:00
|
|
|
labels: *oncall-labels
|
2022-09-29 12:09:29 +01:00
|
|
|
resources:
|
|
|
|
|
limits:
|
|
|
|
|
memory: 1000m
|
2022-11-07 16:34:43 +01:00
|
|
|
cpus: "0.5"
|
|
|
|
|
healthcheck:
|
|
|
|
|
test: rabbitmq-diagnostics -q ping
|
|
|
|
|
interval: 30s
|
|
|
|
|
timeout: 30s
|
|
|
|
|
retries: 3
|
|
|
|
|
volumes:
|
|
|
|
|
- rabbitmqdata_dev:/var/lib/rabbitmq
|
|
|
|
|
profiles:
|
|
|
|
|
- rabbitmq
|
|
|
|
|
|
|
|
|
|
mysql:
|
|
|
|
|
container_name: mysql
|
|
|
|
|
labels: *oncall-labels
|
2023-05-10 13:53:27 -04:00
|
|
|
image: mysql:8.0.32
|
Fix duplicate orders for user notification policies (#2278)
# What this PR does
Fixes an issue when multiple user notification policies have duplicated
order values, leading to the following unexpected behaviours:
1. Not possible to rearrange notification policies that have duplicated
orders.
2. The notification system only executes the first policy from each
order group. For example, if there are policies with orders `[0, 0, 0,
0]`, only the first policy will be executed, and all others will be
skipped. So the user will see four policies in the UI, while only one of
them will be actually executed.
This PR fixes the issue by adding a unique index on `(user_id,
important, order)` for `UserNotificationPolicy` model. However, it's not
possible to add that unique index using the ordering library that we use
due to it's implementation details.
I added a new abstract Django model `OrderedModel` that's able to work
with such unique indices + under concurrent load.
Important info on this new `OrderedModel` abstract model:
- Orders are unique on the DB level
- Orders are allowed to be non-consecutive, for example order sequence
`[100, 150, 400]` is valid
- When deleting an instance, orders of other instances don't change.
This is a notable difference from the library we use. I think it's
better to only delete the instance without changing any other orders,
because it reduces the number of dependencies between instances (e.g.
Terraform drift will be much smaller this way if a policy is deleted via
the web UI).
## Which issue(s) this PR fixes
Related to https://github.com/grafana/oncall-private/issues/1680
## Checklist
- [x] Unit, integration, and e2e (if applicable) tests updated
- [x] Documentation added (or `pr:no public docs` PR label added if not
required)
- [x] `CHANGELOG.md` updated (or `pr:no changelog` PR label added if not
required)
2023-06-21 12:13:56 +01:00
|
|
|
command: --default-authentication-plugin=mysql_native_password --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci --max_connections=1024
|
2022-11-07 16:34:43 +01:00
|
|
|
restart: always
|
|
|
|
|
environment:
|
|
|
|
|
MYSQL_ROOT_PASSWORD: empty
|
|
|
|
|
MYSQL_DATABASE: oncall_local_dev
|
2022-06-03 08:09:47 -06:00
|
|
|
ports:
|
2022-11-07 16:34:43 +01:00
|
|
|
- "3306:3306"
|
|
|
|
|
deploy:
|
|
|
|
|
labels: *oncall-labels
|
|
|
|
|
resources:
|
|
|
|
|
limits:
|
2023-05-10 13:53:27 -04:00
|
|
|
memory: 1000m
|
2022-11-07 16:34:43 +01:00
|
|
|
cpus: "0.5"
|
|
|
|
|
healthcheck:
|
2022-11-09 07:21:33 +01:00
|
|
|
test: "mysql -uroot -pempty oncall_local_dev -e 'select 1'"
|
2022-11-07 16:34:43 +01:00
|
|
|
timeout: 20s
|
|
|
|
|
retries: 10
|
|
|
|
|
volumes:
|
|
|
|
|
- mysqldata_dev:/var/lib/mysql
|
|
|
|
|
profiles:
|
|
|
|
|
- mysql
|
2022-06-03 08:09:47 -06:00
|
|
|
|
2022-11-07 16:34:43 +01:00
|
|
|
mysql_to_create_grafana_db:
|
|
|
|
|
container_name: mysql_to_create_grafana_db
|
|
|
|
|
labels: *oncall-labels
|
2023-05-10 13:53:27 -04:00
|
|
|
image: mysql:8.0.32
|
2022-06-10 17:32:58 +03:00
|
|
|
command: bash -c "mysql -h mysql -uroot -pempty -e 'CREATE DATABASE IF NOT EXISTS grafana CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;'"
|
2022-06-03 08:09:47 -06:00
|
|
|
depends_on:
|
|
|
|
|
mysql:
|
|
|
|
|
condition: service_healthy
|
2022-11-07 16:34:43 +01:00
|
|
|
profiles:
|
|
|
|
|
- mysql
|
|
|
|
|
|
|
|
|
|
postgres:
|
|
|
|
|
container_name: postgres
|
|
|
|
|
labels: *oncall-labels
|
|
|
|
|
image: postgres:14.4
|
|
|
|
|
restart: always
|
|
|
|
|
environment:
|
|
|
|
|
POSTGRES_DB: oncall_local_dev
|
|
|
|
|
POSTGRES_PASSWORD: empty
|
|
|
|
|
POSTGRES_INITDB_ARGS: --encoding=UTF-8
|
|
|
|
|
ports:
|
|
|
|
|
- "5432:5432"
|
|
|
|
|
deploy:
|
|
|
|
|
labels: *oncall-labels
|
|
|
|
|
resources:
|
|
|
|
|
limits:
|
|
|
|
|
memory: 500m
|
|
|
|
|
cpus: "0.5"
|
|
|
|
|
healthcheck:
|
|
|
|
|
test: ["CMD", "pg_isready", "-U", "postgres"]
|
|
|
|
|
interval: 10s
|
|
|
|
|
timeout: 5s
|
|
|
|
|
retries: 5
|
|
|
|
|
volumes:
|
|
|
|
|
- postgresdata_dev:/var/lib/postgresql/data
|
|
|
|
|
profiles:
|
|
|
|
|
- postgres
|
|
|
|
|
|
|
|
|
|
postgres_to_create_grafana_db:
|
|
|
|
|
container_name: postgres_to_create_grafana_db
|
|
|
|
|
labels: *oncall-labels
|
|
|
|
|
image: postgres:14.4
|
|
|
|
|
command: bash -c "PGPASSWORD=empty psql -U postgres -h postgres -tc \"SELECT 1 FROM pg_database WHERE datname = 'grafana'\" | grep -q 1 || PGPASSWORD=empty psql -U postgres -h postgres -c \"CREATE DATABASE grafana\""
|
|
|
|
|
depends_on:
|
|
|
|
|
postgres:
|
|
|
|
|
condition: service_healthy
|
|
|
|
|
profiles:
|
|
|
|
|
- postgres
|
2022-06-03 08:09:47 -06:00
|
|
|
|
2023-06-01 09:31:33 -03:00
|
|
|
prometheus:
|
|
|
|
|
container_name: prometheus
|
|
|
|
|
labels: *oncall-labels
|
|
|
|
|
image: prom/prometheus
|
|
|
|
|
volumes:
|
|
|
|
|
- ./dev/prometheus.yml:/etc/prometheus/prometheus.yml
|
|
|
|
|
ports:
|
|
|
|
|
- "9090:9090"
|
|
|
|
|
profiles:
|
|
|
|
|
- prometheus
|
|
|
|
|
|
2022-06-03 08:09:47 -06:00
|
|
|
grafana:
|
2022-11-07 16:34:43 +01:00
|
|
|
container_name: grafana
|
|
|
|
|
labels: *oncall-labels
|
2023-05-02 08:19:34 -04:00
|
|
|
image: "grafana/${GRAFANA_IMAGE:-grafana:latest}"
|
2022-06-03 08:09:47 -06:00
|
|
|
restart: always
|
|
|
|
|
environment:
|
|
|
|
|
GF_SECURITY_ADMIN_USER: oncall
|
|
|
|
|
GF_SECURITY_ADMIN_PASSWORD: oncall
|
|
|
|
|
GF_PLUGINS_ALLOW_LOADING_UNSIGNED_PLUGINS: grafana-oncall-app
|
2022-11-07 16:34:43 +01:00
|
|
|
env_file:
|
|
|
|
|
- ./dev/.env.${DB}.dev
|
|
|
|
|
ports:
|
|
|
|
|
- "3000:3000"
|
2022-09-29 12:09:29 +01:00
|
|
|
deploy:
|
2022-11-07 16:34:43 +01:00
|
|
|
labels: *oncall-labels
|
2022-09-29 12:09:29 +01:00
|
|
|
resources:
|
|
|
|
|
limits:
|
|
|
|
|
memory: 500m
|
2022-11-07 16:34:43 +01:00
|
|
|
cpus: "0.5"
|
|
|
|
|
extra_hosts:
|
|
|
|
|
- "host.docker.internal:host-gateway"
|
2022-06-03 08:09:47 -06:00
|
|
|
volumes:
|
2022-11-07 16:34:43 +01:00
|
|
|
- grafanadata_dev:/var/lib/grafana
|
2022-06-03 08:09:47 -06:00
|
|
|
- ./grafana-plugin:/var/lib/grafana/plugins/grafana-plugin
|
2023-06-01 09:31:33 -03:00
|
|
|
- ./provisioning:/etc/grafana/provisioning
|
2023-01-20 09:19:41 +01:00
|
|
|
- ${GRAFANA_DEV_PROVISIONING:-/dev/null}:/etc/grafana/grafana.ini
|
2022-11-09 07:21:33 +01:00
|
|
|
depends_on:
|
|
|
|
|
postgres:
|
|
|
|
|
condition: service_healthy
|
|
|
|
|
mysql:
|
|
|
|
|
condition: service_healthy
|
2022-11-07 16:34:43 +01:00
|
|
|
profiles:
|
|
|
|
|
- grafana
|
|
|
|
|
volumes:
|
|
|
|
|
redisdata_dev:
|
|
|
|
|
labels: *oncall-labels
|
|
|
|
|
grafanadata_dev:
|
|
|
|
|
labels: *oncall-labels
|
|
|
|
|
rabbitmqdata_dev:
|
|
|
|
|
labels: *oncall-labels
|
|
|
|
|
postgresdata_dev:
|
|
|
|
|
labels: *oncall-labels
|
|
|
|
|
mysqldata_dev:
|
|
|
|
|
labels: *oncall-labels
|
2023-05-17 22:12:51 +02:00
|
|
|
node_modules_dev:
|
|
|
|
|
labels: *oncall-labels
|
2022-11-07 16:34:43 +01:00
|
|
|
|
|
|
|
|
networks:
|
|
|
|
|
default:
|
|
|
|
|
name: oncall_dev
|
|
|
|
|
labels: *oncall-labels
|