Skip to content

Conversation

@saurabhraghuvanshii
Copy link

@saurabhraghuvanshii saurabhraghuvanshii commented Dec 28, 2025

fixes: #75

[Backend] Containerize the Full Stack (Docker Compose)

Summary

This PR introduces full-stack containerization using Docker Compose, enabling a consistent, reproducible, and production-aligned local and deployment setup. The backend, supporting services, and reverse proxy are containerized with clear separation of concerns, persistent storage, and secure defaults.


Changes

New Files

  • docker-compose.yml — Orchestrates all services
  • backend/Dockerfile — Backend service container
  • nginx/Dockerfile — Nginx reverse proxy container
  • nginx/nginx.conf — API proxying and routing configuration
  • .dockerignore — Optimized Docker build context

Key Features

  • Model loading handled at container startup
  • FAISS integration for efficient vector search
  • API proxying via Nginx (single entry point)
  • Security:
    • Non-root containers
    • Environment-based secrets
    • Isolated internal network

Build Dependencies

Resolved common Docker build issues:

  • lxml — Fixed by installing system-level XML dependencies
  • scipy — Resolved via compatible base image and build tools
  • faiss-cpu — Installed with matching Python and OS versions

These changes ensure deterministic and reliable builds across environments.


Usage

Quick Start

docker compose up --build

Submitter checklist

  • Make sure you are opening from a topic/feature/bugfix branch (right side) and not your main branch!
  • Ensure that the pull request title represents the desired changelog entry

@saurabhraghuvanshii saurabhraghuvanshii requested a review from a team as a code owner December 28, 2025 12:00
Copy link
Contributor

@berviantoleo berviantoleo left a comment

Choose a reason for hiding this comment

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

Look at some comments above.

@berviantoleo berviantoleo added developer Changes which impact plugin developers maintenance Targets chores, refactors and cleanups labels Dec 29, 2025
@cnu1812 cnu1812 requested a review from berviantoleo December 29, 2025 18:31
@berviantoleo
Copy link
Contributor

berviantoleo commented Dec 29, 2025

Sorry. One more request. Please update the docs, so the next developer know/understand how to use it. In addition, please have a look at failed CIs.

@berviantoleo berviantoleo added the documentation Improvements or additions to documentation label Dec 29, 2025
Copy link
Contributor

@berviantoleo berviantoleo left a comment

Choose a reason for hiding this comment

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

I don't see the docs file as described in the PR descriptions.

@saurabhraghuvanshii
Copy link
Author

I don't see the docs file as described in the PR descriptions.

Sorry, I forgot to mention that I’ll update tomorrow because my end-semester exams are going on.

@cnu1812
Copy link
Member

cnu1812 commented Dec 30, 2025

I don't see the docs file as described in the PR descriptions.

Sorry, I forgot to mention that I’ll update tomorrow because my end-semester exams are going on.

No hurry, take your time to understand, and provide with the quality pr

@berviantoleo berviantoleo self-requested a review January 3, 2026 12:42
berviantoleo
berviantoleo previously approved these changes Jan 3, 2026
@berviantoleo
Copy link
Contributor

Could you please have a look at the failed CIs?

@saurabhraghuvanshii
Copy link
Author

saurabhraghuvanshii commented Jan 6, 2026

Hi @berviantoleo, I think the tests aren’t failing because of my PR. Only ESLint is failing due to my changes; the other failures are coming from recent changes in the main branch.

@berviantoleo
Copy link
Contributor

These error from your changes of the config.

src/config.ts:2:18 - error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node16', 'node18', or 'nodenext'.

�[7m2   const envUrl = import.meta.env.VITE_API_BASE_URL;
�[7m                   ~~~~~~~~~~~
src/config.ts:2:30 - error TS2339: Property 'env' does not exist on type 'ImportMeta'.

�[7m2   const envUrl = import.meta.env.VITE_API_BASE_URL;
�[7m                               ~~~
src/config.ts:7:10 - error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node16', 'node18', or 'nodenext'.

�[7m7   return import.meta.env.PROD ? '' : 'http://localhost:8000';
�[7m           ~~~~~~~~~~~
src/config.ts:7:22 - error TS2339: Property 'env' does not exist on type 'ImportMeta'.

�[7m7   return import.meta.env.PROD ? '' : 'http://localhost:8000';

@berviantoleo
Copy link
Contributor

Backend test error due to removing pytest from requirements. Hence, should adjust the CI.

@saurabhraghuvanshii
Copy link
Author

@berviantoleo I'll update it by tomorrow

@saurabhraghuvanshii
Copy link
Author

saurabhraghuvanshii commented Jan 9, 2026

@berviantoleo @cnu1812 Sorry for the delayed response due to my end-semester exams. I’ll be free by the 12th.

Kindly approve the workflow to run. I expect the frontend checks to pass now.

@berviantoleo
Copy link
Contributor

@berviantoleo @cnu1812 Sorry for the delayed response due to my end-semester exams. I’ll be free by the 12th.

Kindly approve the workflow to run. I expect the frontend checks to pass now.

We still have two issues now.

  1. module shouldn't be node, but either 'es2020', 'es2022', 'esnext', 'system', 'node16', 'node18', or 'nodenext'
  2. Implement as suggested by jest > Cannot find module './chatbotTexts.json'. Consider using '--resolveJsonModule' to import module with '.json' extension.

@saurabhraghuvanshii
Copy link
Author

@berviantoleo Just a thought Would it help if some CI checks (backend, frontend, ESLint) ran automatically without approval, like in other orgs? It might make things easier for contributors.

@krisstern
Copy link
Member

@saurabhraghuvanshii that may be too big of an ask

@berviantoleo
Copy link
Contributor

@berviantoleo Just a thought Would it help if some CI checks (backend, frontend, ESLint) ran automatically without approval, like in other orgs? It might make things easier for contributors.

Hi, @saurabhraghuvanshii,
I encourage you to understand what tests have been done in CIs. Those tests can easily be run in your local environment without any special resources. If you ask to run the CIs multiple times, I assume you haven't run the test in your local environment.

@GunaPalanivel
Copy link
Contributor

Hey @saurabhraghuvanshii, thanks for pushing through 22 commits on this. The Docker setup works locally and the architecture is solid—just need to fix a few blockers before we can merge.


Blocking Issues

1. Python version mismatch - chatbot-core/Dockerfile L37, Dockerfile.gpu L73
You're copying from python3.14/site-packages but the base image is python:3.12-slim. This will crash on first import.
→ Change both to python3.12

2. Missing .env.example
Nobody can run this without guessing env vars. Create .env.example with MODEL_PATH, FAISS_INDEX_PATH, LOG_LEVEL, VITE_API_BASE_URL and add a table to README.

3. Health checks hit /docs instead of actual API - Both Dockerfiles L49/L83
/docs returns 200 even if the model isn't loaded. Orchestrators will route traffic to broken containers.
→ Add /health endpoint in api/main.py that checks model state, update healthchecks to use it

4. No model validation on startup
Container starts fine without the model, then fails silently on first query.
→ Add startup script that checks model exists before uvicorn starts

5. Race condition on startup - Both compose files
depends_on only waits for container start, not health.
→ Use condition: service_healthy


Recommended Before Merge

6. No production compose file
Current setup has no resource limits, basic logging, relaxed health intervals. Create docker-compose.prod.yml with memory/CPU limits, proper logging config, faster health checks.

7. Volume strategy breaks in cloud
Relative paths don't work in K8s/ECS/Fargate. Add "Production Deployment" section to README showing how to handle storage for different platforms (S3+init containers for K8s, EFS for ECS, etc.)

8. Missing security headers - nginx.conf
Add CSP, Referrer-Policy, Permissions-Policy after the existing headers

9. TypeScript any types - config.ts L9-10
ESLint is failing on this. Create proper interface extending ImportMeta instead of using any

10. GPU Dockerfile untested
Add CI job to build Dockerfile.gpu so we know it actually works


Can Be Follow-up PR

  • Image scanning (Trivy)
  • Log persistence volume
  • Multi-arch builds
  • Metrics endpoint

Next Steps

Fix items 1-5 first (about 1 hour), then we can discuss whether to include 6-10 or do them as follow-up. Items 1-3 will cause production failures, so those are hard blockers.

Let me know if you want to pair on the health check endpoint or have questions about the production setup.

cc: @berviantoleo

@saurabhraghuvanshii
Copy link
Author

@berviantoleo @GunaPalanivel thanks, I'll update pr with all the on 16/01/26 I'm not feeling well. Thanks

@saurabhraghuvanshii
Copy link
Author

@berviantoleo @cnu1812 All tests are passing I double checked

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

developer Changes which impact plugin developers documentation Improvements or additions to documentation maintenance Targets chores, refactors and cleanups

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Backend] Containerize the Full Stack (Docker Compose)

5 participants