Skip to content

Conversation

avirajsingh7
Copy link
Collaborator

@avirajsingh7 avirajsingh7 commented Oct 1, 2025

Summary

Target issue is #386
This PR significantly enhances the Docker Compose configuration to provide a complete containerized development environment with improved service orchestration, dependency management.

New Services Added

  • Redis: Added Redis service for caching and Celery result backend
  • RabbitMQ: Added RabbitMQ service with management UI for Celery message broker
  • Celery Worker: Added dedicated Celery worker service for background task processing
  • Celery Beat: Added Celery beat scheduler for periodic tasks

Infrastructure Improvements

  • Health Checks: Implemented comprehensive health checks for all services (PostgreSQL, Redis, RabbitMQ)
  • Service Dependencies: Proper dependency management with condition: service_healthy
  • Volume Management: Updated volume naming convention (kaapi-* prefix) and added Redis/RabbitMQ volumes
  • Port Mapping: Exposed all service ports for local development access

Configuration Cleanup

  • Removed Traefik: Eliminated Traefik-related configurations and files for simplified local development
  • Environment Variables: Streamlined environment variable management while maintaining security
  • Version Update: Updated Docker Compose version from "3.9" to "0.1"

Summary by CodeRabbit

  • New Features

    • Unified local Docker stack with DB, Redis, RabbitMQ, backend, Adminer, Celery (worker & Flower) and health checks; added OPENAI_API_KEY env var.
  • Refactor

    • Consolidated environment references, standardized container names, health-driven startup, and development live-reload workflow; environment values updated and project renamed to Kaapi.
  • Chores

    • Removed legacy local override and Traefik public routing configurations.
  • Documentation

    • Updated env guidance, startup options, secret-key generation, and rebuild notes.

…d simplify service definitions by removing Traefik-related settings.
…, update PostgreSQL settings, and improve health checks and environment variable management for backend services in docker compose
…y_worker and celery_beat services, and streamline environment variable management for backend services.
Copy link

coderabbitai bot commented Oct 1, 2025

Walkthrough

Consolidated local deployment: updated .env template, removed multiple compose override files (dev/override/traefik), and expanded docker-compose.yml to declare Postgres, Redis, RabbitMQ, Adminer, prestart, backend, Celery worker/Flower with volumes/healthchecks; README and backend Dockerfile adjusted.

Changes

Cohort / File(s) Summary
Env template
\.env\.example
Replaced ENVIRONMENT options (now includes development,testing,staging,production), renamed PROJECT_NAME/STACK_NAME to Kaapi, changed POSTGRES_DB to kaapi, added OPENAI_API_KEY (empty) and notes, minor formatting tweaks.
Removed compose overrides
docker-compose.dev.yml, docker-compose.override.yml, docker-compose.traefik.yml
Deleted local/dev/Traefik override configs and all services/networks/volumes they declared (proxy/Traefik, mailcatcher, previous db/backend/adminer overrides, traefik-public network, etc.).
Consolidated main compose
docker-compose.yml
Reworked main compose to declare services: db (container_name, env_file, POSTGRES_*, PGDATA, kaapi-postgres volume, ports, healthcheck), redis (container_name, env_file, optional password, kaapi-redis volume, port, healthcheck), rabbitmq (management image, env_file, kaapi-rabbitmq volume, ports, healthcheck), adminer, prestart (profile), backend (build context, env refs, ports, healthcheck, dev command), celery_worker, celery_flower; added volumes kaapi-postgres, kaapi-redis, kaapi-rabbitmq; removed Traefik labels/networks.
Docs
README.md
Reworked startup guidance: replaced deployment pre-checks with a generic env-warning, added Python one-liner to generate secret keys, split bootstrap into two options (prestart migrations/seeding vs normal start/watch), added “Rebuilding Images” guidance and rebuild triggers, updated health-check references and wording.
Backend build files
backend/Dockerfile, deleted backend/Dockerfile.celery
backend/Dockerfile: added top-level comment noting shared Dockerfile for backend/Celery and commented CMD examples for Celery worker/Flower. backend/Dockerfile.celery removed (Celery image now handled via compose/build context).

Sequence Diagram(s)

sequenceDiagram
    autonumber
    actor Dev as Developer
    participant DC as Docker Compose
    participant DB as postgres-db
    participant RD as redis
    participant MQ as rabbitmq
    participant AD as adminer
    participant PS as prestart
    participant BE as backend
    participant CW as celery_worker
    participant CF as celery_flower

    Dev->>DC: docker compose up (--profile prestart?)
    DC->>DB: start postgres-db (env_file, volume, healthcheck)
    DC->>RD: start redis (env_file, optional password, healthcheck)
    DC->>MQ: start rabbitmq (env_file, management port, healthcheck)
    DC->>AD: start adminer
    alt prestart profile used
        DC->>PS: run prestart (migrations & seed)
        PS->>DB: apply migrations / seed
    end
    note right of DB: healthchecks ensure readiness
    DC->>BE: start backend when DB/RD/MQ healthy
    DC->>CW: start celery_worker when DB/RD/MQ healthy
    DC->>CF: start celery_flower when backend ready
    BE->>DB: connect via POSTGRES_SERVER
    BE->>RD: connect via REDIS_HOST
    BE->>MQ: connect via RABBITMQ_HOST
    CW->>DB: connect
    CW->>RD: connect
    CW->>MQ: connect
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

Suggested reviewers

  • AkhileshNegi
  • nishika26

Poem

I hop through configs, nose in the log,
ENV set to dev — I danced on a bog.
Traefik waved off, containers align,
Postgres, Redis, Rabbit, Celery — all mine.
I nibble a carrot and stamp little paws. 🥕🐇

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title “Docker Compose Configuration Enhancements” succinctly captures the primary focus of this changeset, which is the overhaul and improvement of Docker Compose service definitions and orchestration; it is specific to the core update without extraneous detail.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/docker_compose

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@avirajsingh7 avirajsingh7 self-assigned this Oct 1, 2025
@avirajsingh7 avirajsingh7 linked an issue Oct 1, 2025 that may be closed by this pull request
@avirajsingh7 avirajsingh7 added enhancement New feature or request and removed ready-for-review labels Oct 1, 2025
Copy link

codecov bot commented Oct 1, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
docker-compose.yml (1)

88-91: depends_on schema violation stops Compose from parsing.
The restart: true entry isn’t part of the Compose spec for depends_on, so the CLI rejects the file before deployment. Drop that key so the service graph can be evaluated.

     depends_on:
       db:
         condition: service_healthy
-        restart: true
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 569fa27 and 7bd7a16.

📒 Files selected for processing (5)
  • .env.example (2 hunks)
  • docker-compose.dev.yml (0 hunks)
  • docker-compose.override.yml (0 hunks)
  • docker-compose.traefik.yml (0 hunks)
  • docker-compose.yml (2 hunks)
💤 Files with no reviewable changes (3)
  • docker-compose.override.yml
  • docker-compose.traefik.yml
  • docker-compose.dev.yml
🧰 Additional context used
🪛 dotenv-linter (3.3.0)
.env.example

[warning] 53-53: [UnorderedKey] The RABBITMQ_PASSWORD key should go before the RABBITMQ_PORT key

(UnorderedKey)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: checks (3.11.7, 6)

…name, and database settings in .env.example; enhance README with service dependency warnings and startup options.
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3b7ba7b and 3504a68.

📒 Files selected for processing (3)
  • .env.example (3 hunks)
  • README.md (1 hunks)
  • docker-compose.yml (2 hunks)
✅ Files skipped from review due to trivial changes (1)
  • README.md
🧰 Additional context used
🪛 dotenv-linter (3.3.0)
.env.example

[warning] 17-17: [QuoteCharacter] The value has quote characters (', ")

(QuoteCharacter)


[warning] 29-29: [UnorderedKey] The POSTGRES_DB key should go before the POSTGRES_PORT key

(UnorderedKey)


[warning] 82-82: [QuoteCharacter] The value has quote characters (', ")

(QuoteCharacter)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: checks (3.11.7, 6)

- EMAIL_TEST_USER=${EMAIL_TEST_USER}
- AWS_S3_BUCKET_PREFIX=${AWS_S3_BUCKET_PREFIX}
POSTGRES_SERVER: db
profiles: ["prestart"]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just clarifying question why we need this

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Screenshot 2025-10-13 at 1 02 59 PM

build:
context: ./backend
ports:
- "8000:80"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why 8000:80 and not 8000

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Map port 8000 on my local machine (host) to port 80 inside the container. ( container start app at port 80)



celery_worker:
image: "${DOCKER_IMAGE_BACKEND?Variable not set}:${TAG:-latest}"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should also be built like backend from source, not from image

one other simplification can be done; realised this while deploying to ECS - we probably don't need two Dockerfiles like there are right now; the same Dockerfile can be used to build both backend and celery-worker containers, jus the RUN/CMD needs to change

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
docker-compose.yml (1)

84-91: Remove unsupported restart key from depends_on.

restart: true isn’t a valid property inside the depends_on block, so docker compose config fails with “Additional property restart is not allowed.” Drop that line to keep the config schema‑compliant.

     depends_on:
       db:
         condition: service_healthy
-        restart: true
🧹 Nitpick comments (1)
README.md (1)

47-50: Fix the “Boostrap” typo.

Rename the section header to “Bootstrap & development mode” to avoid the misspelling.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 93546d8 and ad67131.

📒 Files selected for processing (4)
  • README.md (1 hunks)
  • backend/Dockerfile (2 hunks)
  • backend/Dockerfile.celery (0 hunks)
  • docker-compose.yml (2 hunks)
💤 Files with no reviewable changes (1)
  • backend/Dockerfile.celery
✅ Files skipped from review due to trivial changes (1)
  • backend/Dockerfile

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
docker-compose.yml (1)

88-91: Invalid key under depends_on; compose will fail to parse.

restart: true is not allowed inside depends_on. Remove it (and optionally set a service-level restart policy if desired).

   depends_on:
     db:
       condition: service_healthy
-      restart: true
🧹 Nitpick comments (5)
backend/Dockerfile (1)

52-56: Remove commented-out CMD examples to avoid drift/confusion.

Compose overrides the command per service; keeping example CMDs here can mislead. Prefer documenting in README or compose.

-# command for Celery worker
-# CMD ["uv", "run", "celery", "-A", "app.celery.celery_app", "worker", "--loglevel=info"]
-
-# command for Celery Flower
-# CMD ["uv", "run", "celery", "-A", "app.celery.celery_app", "flower", "--port=5555"]
docker-compose.yml (4)

144-147: Avoid unnecessary coupling on backend health; depend on actual infra.

Celery services only need DB/Redis/RabbitMQ. Depending on backend health can block workers unnecessarily.

-celery_worker:
-  depends_on:
-    backend:
-      condition: service_healthy
+celery_worker:
+  depends_on:
+    db:
+      condition: service_healthy
+    redis:
+      condition: service_healthy
+    rabbitmq:
+      condition: service_healthy
@@
-celery_flower:
-  depends_on:
-    backend:
-      condition: service_healthy
+celery_flower:
+  depends_on:
+    db:
+      condition: service_healthy
+    redis:
+      condition: service_healthy
+    rabbitmq:
+      condition: service_healthy

Also applies to: 161-164


23-24: Bind dev ports to localhost to avoid exposing services on all interfaces.

Reduces accidental exposure on shared networks.

-      - "5432:5432"
+      - "127.0.0.1:5432:5432"
@@
-      - "6379:6379"
+      - "127.0.0.1:6379:6379"
@@
-      - "5672:5672"
-      - "15672:15672"
+      - "127.0.0.1:5672:5672"
+      - "127.0.0.1:15672:15672"
@@
-      - "8080:8080"
+      - "127.0.0.1:8080:8080"
@@
-      - "8000:80"
+      - "127.0.0.1:8000:80"
@@
-      - "5555:5555"
+      - "127.0.0.1:5555:5555"

Also applies to: 41-41, 62-63, 80-80, 117-118, 167-167


83-85: Normalize TAG default expansion for consistency.

Use the same ${TAG:-latest} form everywhere (treats empty as unset too).

-  image: "${DOCKER_IMAGE_BACKEND?Variable not set}:${TAG-latest}"
+  image: "${DOCKER_IMAGE_BACKEND?Variable not set}:${TAG:-latest}"

75-80: Consider waiting for DB health before starting Adminer.

Not strictly required, but avoids transient errors on first load.

   depends_on:
-    - db
+    db:
+      condition: service_healthy
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 93546d8 and ad67131.

📒 Files selected for processing (4)
  • README.md (1 hunks)
  • backend/Dockerfile (2 hunks)
  • backend/Dockerfile.celery (0 hunks)
  • docker-compose.yml (2 hunks)
💤 Files with no reviewable changes (1)
  • backend/Dockerfile.celery
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: checks (3.11.7, 6)
🔇 Additional comments (2)
backend/Dockerfile (1)

1-1: Good clarification.

Single Dockerfile approach is clear and aligns with compose usage.

README.md (1)

66-78: Confirm Compose Watch availability across dev environments.

“docker compose watch” requires a recent Docker Desktop/Compose version. Please confirm team machines meet this requirement or add a brief note with minimum versions.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ad67131 and 595df33.

📒 Files selected for processing (1)
  • README.md (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: checks (3.11.7, 6)

@avirajsingh7 avirajsingh7 merged commit 8013fa3 into main Oct 13, 2025
3 checks passed
@avirajsingh7 avirajsingh7 deleted the fix/docker_compose branch October 13, 2025 09:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request ready-for-review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Docker setup not working with provided compose files

4 participants