From 45fc87877f83ab3e98486225a91b2ae22a98ceaa Mon Sep 17 00:00:00 2001 From: thenav56 Date: Fri, 13 Sep 2024 14:25:02 +0545 Subject: [PATCH] Use profile in docker-compose.yml - docker compose up will only run essential services - docker compose up run --rm can be used to run cli helpers - docker compose --profile elasticsearch up is required to run kibana --- Dockerfile | 2 +- docker-compose.yml | 34 +++++++++++++++++++++++++++++----- 2 files changed, 30 insertions(+), 6 deletions(-) diff --git a/Dockerfile b/Dockerfile index 9a7f69b53..82a93a5c1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,6 @@ FROM python:3.9-bullseye -ENV PYTHONUNBUFFERED 1 +ENV PYTHONUNBUFFERED=1 EXPOSE 80 EXPOSE 443 diff --git a/docker-compose.yml b/docker-compose.yml index 399644376..7b904b299 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,5 +1,3 @@ -version: '3.5' - x-server: &base_server_setup image: ifrcgo/go-api:latest build: . @@ -29,8 +27,8 @@ x-server: &base_server_setup CACHE_MIDDLEWARE_SECONDS: ${CACHE_MIDDLEWARE_SECONDS:-600} ELASTIC_SEARCH_HOST: ${ELASTIC_SEARCH_HOST:-elasticsearch://elasticsearch:9200} # Appeal API - APPEALS_USER: ${APPEALS_USER} - APPEALS_PASS: ${APPEALS_PASS} + APPEALS_USER: ${APPEALS_USER:-} + APPEALS_PASS: ${APPEALS_PASS:-} # Sentry SENTRY_DSN: ${SENTRY_DSN:-} SENTRY_SAMPLE_RATE: ${SENTRY_SAMPLE_RATE:-0.2} @@ -56,7 +54,6 @@ x-server: &base_server_setup - db - redis - elasticsearch - - kibana services: @@ -107,6 +104,7 @@ services: - '5601:5601' depends_on: - elasticsearch + profiles: [elasticsearch] serve: <<: *base_server_setup @@ -119,93 +117,119 @@ services: <<: *base_server_setup command: python manage.py run_celery_dev + # ------------------ Helper CLI Commands + # Usage: `docker compose run --rm ` + # Example: `docker compose run --rm bash` bash: <<: *base_server_setup entrypoint: /bin/bash + profiles: [cli] shell: <<: *base_server_setup command: python manage.py shell + profiles: [cli] loaddata: <<: *base_server_setup command: python manage.py loaddata Regions Countries Districts DisasterTypes Actions Groups + profiles: [cli] ingest_databank: <<: *base_server_setup command: python manage.py ingest_databank + profiles: [cli] collectstatic: <<: *base_server_setup command: python manage.py collectstatic --noinput -l + profiles: [cli] createsuperuser: <<: *base_server_setup command: python manage.py createsuperuser + profiles: [cli] ingest_appeals: <<: *base_server_setup command: python manage.py ingest_appeals + profiles: [cli] ingest_appeal_docs: <<: *base_server_setup command: python manage.py ingest_appeal_docs + profiles: [cli] user_registration_reminder: <<: *base_server_setup command: python manage.py user_registration_reminder + profiles: [cli] ingest_appeal_docs_fullscan: <<: *base_server_setup command: python manage.py ingest_appeal_docs --fullscan + profiles: [cli] ingest_mdb: <<: *base_server_setup command: python manage.py ingest_mdb + profiles: [cli] migrate: <<: *base_server_setup command: python manage.py migrate + profiles: [cli] makemigrations: <<: *base_server_setup command: python manage.py makemigrations + profiles: [cli] makemigrations_merge: <<: *base_server_setup command: python manage.py makemigrations --merge + profiles: [cli] make_permissions: <<: *base_server_setup command: python manage.py make_permissions + profiles: [cli] test: <<: *base_server_setup command: pytest --durations=10 + profiles: [cli] test_snapshot_update: <<: *base_server_setup command: python manage.py test -k --snapshot-update + profiles: [cli] testr: <<: *base_server_setup command: pytest --reuse-db --durations=10 -s + profiles: [cli] coverage: <<: *base_server_setup command: coverage run --source='.' manage.py test -k + profiles: [cli] coverage_report: <<: *base_server_setup command: coverage report + profiles: [cli] coverage_html: <<: *base_server_setup command: coverage html + profiles: [cli] triggers_to_db: <<: *base_server_setup command: python manage.py triggers_to_db + profiles: [cli] + volumes: redis-data: