diff --git a/.gitignore b/.gitignore index 320b022a..0e47d8af 100644 --- a/.gitignore +++ b/.gitignore @@ -1,43 +1,8 @@ -# Backend -*/db.sqlite3 -engine/*.db *.pyc venv .python-version + .vscode -dump.rdb .idea -jupiter_playbooks/* -engine/reports/*.csv -engine/jupiter_playbooks/* - -# Frontend dependencies -node_modules -/.pnp -.pnp.js - -# testing -/coverage - -# production -/build - -# misc .DS_Store -.swp .env - -npm-debug.log* -yarn-debug.log* -yarn-error.log* - -scripts/gcom.token -scripts/gcom_grafana.token -scripts/gcom_raintank.token - -engine/extensions/ - -grafana-plugin/frontend_enterprise - -uwsgi-local.ini -celerybeat-schedule diff --git a/Makefile b/Makefile index c2746ea5..fb08b79a 100644 --- a/Makefile +++ b/Makefile @@ -61,6 +61,9 @@ ifeq ($(DB),$(SQLITE_PROFILE)) fi endif + $(call run_docker_compose_command,up --remove-orphans -d) + +init: # if the oncall UI is to be run in docker we should do an initial build of the frontend code # this makes sure that it will be available when the grafana container starts up without the need to # restart the grafana container initially @@ -68,8 +71,6 @@ ifeq ($(findstring $(UI_PROFILE),$(COMPOSE_PROFILES)),$(UI_PROFILE)) cd grafana-plugin && yarn install && yarn build:dev endif - $(call run_docker_compose_command,up --remove-orphans -d) - stop: $(call run_docker_compose_command,down) diff --git a/dev/README.md b/dev/README.md index 512f3cf1..eb7aed70 100644 --- a/dev/README.md +++ b/dev/README.md @@ -22,7 +22,7 @@ Related: [How to develop integrations](/engine/config_integrations/README.md) By default everything runs inside Docker. These options can be modified via the [`COMPOSE_PROFILES`](#compose_profiles) environment variable. 1. Firstly, ensure that you have `docker` [installed](https://docs.docker.com/get-docker/) and running on your machine. **NOTE**: the `docker-compose-developer.yml` file uses some syntax/features that are only supported by Docker Compose v2. For insturctions on how to enable this (if you haven't already done so), see [here](https://www.docker.com/blog/announcing-compose-v2-general-availability/). -2. Run `make start`. By default this will run everything in Docker, using SQLite as the database and Redis as the message broker/cache. See [Running in Docker](#running-in-docker) below for more details on how to swap out/disable which components are run in Docker. +2. Run `make init start`. By default this will run everything in Docker, using SQLite as the database and Redis as the message broker/cache. See [Running in Docker](#running-in-docker) below for more details on how to swap out/disable which components are run in Docker. 3. Open Grafana in a browser [here](http://localhost:3000/plugins/grafana-oncall-app) (login: `oncall`, password: `oncall`). 4. You should now see the OnCall plugin configuration page. Fill out the configuration options as follows: @@ -33,6 +33,8 @@ By default everything runs inside Docker. These options can be modified via the 5. Enjoy! Check our [OSS docs](https://grafana.com/docs/grafana-cloud/oncall/open-source/) if you want to set up Slack, Telegram, Twilio or SMS/calls through Grafana Cloud. 6. (Optional) Install `pre-commit` hooks by running `make install-precommit-hook` +**Note**: on subsequent startups you can simply run `make start`, this is a bit faster because it skips the frontend build step. + ### `COMPOSE_PROFILES` This configuration option represents a comma-separated list of [`docker-compose` profiles](https://docs.docker.com/compose/profiles/). It allows you to swap-out, or disable, certain components in Docker. @@ -85,6 +87,8 @@ By default everything runs inside Docker. If you would like to run the backend s See [`COMPOSE_PROFILES`](#compose_profiles) for more information on what this option is and how to configure it. ```bash +make init # build the frontend plugin code then run make start +make start # start all of the docker containers make stop # stop all of the docker containers make restart # restart all docker containers diff --git a/docker-compose-developer.yml b/docker-compose-developer.yml index 6b0d2ab3..0cc79491 100644 --- a/docker-compose-developer.yml +++ b/docker-compose-developer.yml @@ -1,15 +1,17 @@ -version: "3.8" +version: "3.9" x-labels: &oncall-labels - "com.grafana.oncall.env=dev" x-oncall-build: &oncall-build-args context: ./engine - target: dev + target: ${ONCALL_IMAGE_TARGET:-dev} labels: *oncall-labels 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 x-env-files: &oncall-env-files @@ -30,6 +32,8 @@ services: volumes: - ./grafana-plugin:/etc/app - /etc/app/node_modules + # https://stackoverflow.com/a/60456034 + - ${ENTERPRISE_FRONTEND:-/dev/null}:/etc/app/frontend_enterprise profiles: - oncall_ui @@ -170,7 +174,7 @@ services: memory: 500m cpus: "0.5" healthcheck: - test: ["CMD", "mysqladmin", "ping", "-h", "localhost"] + test: "mysql -uroot -pempty oncall_local_dev -e 'select 1'" timeout: 20s retries: 10 volumes: @@ -252,6 +256,11 @@ services: volumes: - grafanadata_dev:/var/lib/grafana - ./grafana-plugin:/var/lib/grafana/plugins/grafana-plugin + depends_on: + postgres: + condition: service_healthy + mysql: + condition: service_healthy profiles: - grafana diff --git a/docker-compose-mysql-rabbitmq.yml b/docker-compose-mysql-rabbitmq.yml index fdcd213c..9537c2f2 100644 --- a/docker-compose-mysql-rabbitmq.yml +++ b/docker-compose-mysql-rabbitmq.yml @@ -1,4 +1,4 @@ -version: "3.8" +version: "3.9" x-environment: &oncall-environment BASE_URL: $DOMAIN diff --git a/docker-compose.yml b/docker-compose.yml index e7134998..1557dafc 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,4 +1,4 @@ -version: "3.8" +version: "3.9" x-environment: &oncall-environment DATABASE_TYPE: sqlite3 diff --git a/engine/.gitignore b/engine/.gitignore new file mode 100644 index 00000000..1193cff7 --- /dev/null +++ b/engine/.gitignore @@ -0,0 +1,5 @@ +requirements-enterprise.txt +extensions/ +uwsgi-local.ini +celerybeat-schedule +*.db diff --git a/engine/Dockerfile b/engine/Dockerfile index 6c753114..0367b53a 100644 --- a/engine/Dockerfile +++ b/engine/Dockerfile @@ -16,10 +16,11 @@ RUN DJANGO_SETTINGS_MODULE=settings.prod_without_db DATABASE_TYPE=sqlite3 DATABA RUN chown -R 1000:2000 /var/lib/oncall FROM base AS dev - -# these are needed for the django dbshell command RUN apk add sqlite mysql-client postgresql-client +FROM dev AS dev-enterprise +RUN pip install -r requirements-enterprise.txt + FROM base AS prod # This is required for prometheus_client to sync between uwsgi workers diff --git a/grafana-plugin/.gitignore b/grafana-plugin/.gitignore index cc1a03f4..5a371043 100644 --- a/grafana-plugin/.gitignore +++ b/grafana-plugin/.gitignore @@ -1,33 +1,16 @@ -# See https://help.github.com/articles/ignoring-files/ for more about ignoring files. - -# dependencies /node_modules -/.pnp -.pnp.js +.eslintcache # testing /coverage # production /dist -/ci - -# misc -.idea -.DS_Store -.env.local -.env.development.local -.env.test.local -.env.production.local - -grafana-plugin.yml - -# cache -.eslintcache npm-debug.log* yarn-debug.log* yarn-error.log* # This file is generated -grafana-plugin.yml \ No newline at end of file +grafana-plugin.yml +frontend_enterprise