Skip to content

Add Docker Compose setup for full-stack local development#15

Open
anshjaiswal12 wants to merge 22 commits into
Climate-Vision:mainfrom
anshjaiswal12:feature/docker-compose-setup
Open

Add Docker Compose setup for full-stack local development#15
anshjaiswal12 wants to merge 22 commits into
Climate-Vision:mainfrom
anshjaiswal12:feature/docker-compose-setup

Conversation

@anshjaiswal12
Copy link
Copy Markdown

Resolves #13.

What was added

  • Full docker-compose.yml configuration linking the FastAPI backend and React Vite frontend.
  • CPU optimization layer in the backend Dockerfile using the --extra-index-url pip parameter preventing multi-gigabyte NVIDIA GPU metadata from downloading recursively for local API contexts.
  • Advanced Volume caching preventing local container node cache collisions.
  • Clear onboarding instructions directly integrated within README.md.

How to test

  1. cp .env.example .env && cp frontend/.env.example frontend/.env
  2. Run docker-compose up -d --build
  3. See API running at http://localhost:8000/docs and frontend at http://localhost:5173

Why it improves DX

Local environment onboarding is extremely unified, ensuring engineers bypass OS-dependency nuances directly through Docker mappings orchestrating both ends simultaneously while maintaining HMR.

Goldokpa and others added 22 commits March 28, 2026 21:22
…iddleware-audit

Merging Olufemi's API middleware and auth modules
…tics-statistics

Merging Francis's analytics statistics and reporting modules
Defines responsibilities, deliverables, and collaboration guidelines for the Carbon Analytics & Validation role.

Co-Authored-By: Francis Umo <francis.umo@climatevision.org>
Defines responsibilities, deliverables, and collaboration guidelines for the API Development & Integration role.

Co-Authored-By: Olufemi Taiwo <olufemi.taiwo@climatevision.org>
…mate-Vision#7)

* feat(data): add GEE tile downloader with analysis-aware band selection

- Downloads real Sentinel-2 composites via Google Earth Engine
- Reads required bands from config.yaml per analysis_type
- Includes SCL band for downstream cloud masking
- Synthetic fallback with explicit is_synthetic flag when GEE unavailable
- Fix .gitignore so src/climatevision/data/ is no longer ignored

* feat(data): add analysis-specific Sentinel-2 band mapping utilities

- get_bands_for_analysis() reads correct bands from config.yaml
- get_band_indices() maps band names to canonical 13-band stack positions
- is_analysis_enabled() and list_enabled_analysis_types() for config validation
- Includes SCL band helpers for downstream cloud masking

* feat(data): integrate SCL cloud masking and export new pipeline modules

- apply_scl_cloud_mask() masks cloudy pixels using Sentinel-2 SCL band
- Default clear labels: vegetation, bare soils, water, snow
- Update __init__.py to expose gee_downloader and band_mapping utilities

* refactor(data): address PR review feedback

- Remove duplicated config logic in gee_downloader.py; import from band_mapping
- Cache config.yaml load in band_mapping.py via lru_cache
- Read synthetic tile size from config.yaml instead of hardcoding 256
- Remove unused json import in gee_downloader.py
- Add shape validation in apply_scl_cloud_mask

---------

Co-authored-by: Adeolu Mary Oshadare <adeolu@placeholder.com>
…ing (Climate-Vision#8)

* feat(inference): make pipeline analysis-aware with dynamic model loading

- _load_model() now accepts analysis_type and reads in_channels/num_classes from config.yaml
- Per-analysis-type model cache prevents cross-contamination between deforestation/ice/flood models
- _find_best_checkpoint() prefers config.yaml weight path per analysis type
- run_inference() accepts analysis_type, pads/crops to correct n_channels, and returns dynamic class counts
- run_inference_from_file() and run_inference_from_gee() propagate analysis_type parameter

* feat(api): wire analysis_type into prediction endpoints

- Pass body.analysis_type to run_inference_from_gee() in /api/predict
- Pass analysis_type to run_inference_from_file() in /api/predict/upload
- Enables the API to load the correct model and return correct class counts per analysis type

---------

Co-authored-by: Olufemi Taiwo <Olufemitaiwo23@gmail.com>
… flag, add config health validation

- Add cv_dev development key bypass for local testing
- Require X-API-Key on all mutation endpoints (POST predict, orgs, alerts, subscriptions)
- Surface is_synthetic at root of inference response for frontend demo banners
- Expand /api/health to validate config alignment (bands vs in_channels, classes vs num_classes)
- Add FastAPI test client fixture
- Create CI workflow for Python (flake8, pytest) and frontend (npm build)
- Bootstrap tests/ directory structure
- Parametrize UNet init for all 3 analysis types (4ch/2cl, 4ch/3cl, 3ch/3cl)
- Validate forward pass output shapes
- Add Siamese change detection forward shape test
- Link to 6 active good-first-issue and help-wanted issues
- Add claim workflow for new contributors
- Include time estimates and skill-building map
- ../components/map/ -> ../components/Map/
- Fixes vite build failure on Linux (case-sensitive filesystem)
- Fixes pip install failure for gdal and rasterio on Ubuntu runners
- Adds libgdal-dev, gdal-bin, libgl1-mesa-glx
- gdal Python package requires exact system GDAL version matching
- rasterio covers all GDAL functionality we actually use
- Simplify CI system deps to libgl1 only (for opencv runtime)
- Fixes ModuleNotFoundError: No module named 'climatevision'
- pip install -e . registers src/ as an importable package
- ForestDataset with DataLoader support
- Training/validation augmentation pipelines
- Synthetic tile generation for demo/fallback mode
- Add DONE/PENDING task list for April 2026 sprint
- Include actual .github/workflows/ci.yml code in role doc
- Update local CI check commands to match current workflow
@Goldokpa Goldokpa requested a review from Oshgig April 22, 2026 15:47
Copy link
Copy Markdown
Member

@Goldokpa Goldokpa left a comment

Choose a reason for hiding this comment

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

Great contribution @anshjaiswal12 — Docker Compose support is exactly what was needed for issue #13. The overall approach is solid: the node_modules volume trick, BACKEND_URL proxy in vite.config.ts, and restart policies are all correct. However there are blocking issues before this can merge.

MUST FIX:

  1. PR targets main instead of develop — Per CONTRIBUTING.md all PRs must target develop. Please change the base branch using the Edit button at the top of this PR.
  2. Backend Dockerfile missing CPU-only pip flag — The PR description mentions preventing multi-GB NVIDIA downloads, but the Dockerfile does not include --extra-index-url https://download.pytorch.org/whl/cpu. Without this, PyTorch will pull CUDA wheels and the image will exceed several GB. Add this flag to the pip install line or provide a requirements-docker.txt pinning CPU wheels.
  3. No healthcheck — frontend starts before backend is readydepends_on: backend only waits for container start, not for FastAPI to be ready. Add a healthcheck on the backend service and use condition: service_healthy in the frontend depends_on. The /health endpoint already exists in the app.
  4. Backend volume .:/app mounts everything — This is intentional for hot-reload but should be documented with a comment, and it means the Dockerfile COPY is ignored at runtime.
    SUGGESTIONS (non-blocking):
  • Remove the 3000:3000 port — "in case it's overridden" is not a good pattern; document the env var override instead.
    • Note in README that the frontend .env copy step is not required for Docker Compose (BACKEND_URL is set via compose env, not .env).
      • Add a note that this is a dev-only setup and a production Dockerfile (nginx + built assets) is a separate follow-up.
        What's done well: .dockerignore files are correct, vite.config.ts proxy change is non-breaking for manual setup, README section is clear and well-structured.

Please retarget to develop and address items 1-3 — happy to approve once those are done!

@spandanaerukull
Copy link
Copy Markdown

Hi, I noticed this PR has requested changes and one required CI check still pending.

If the original contributor is unavailable, I would be happy to help address the remaining requested changes or update the Docker Compose setup/documentation.

Please let me know if I can take this up.

@spandanaerukull
Copy link
Copy Markdown

Hi, I noticed there is already an open PR for this issue. I’ll avoid duplicating the work.

If help is needed with the requested changes or Docker Compose documentation, I’d be happy to contribute.

@Goldokpa
Copy link
Copy Markdown
Member

Thanks for the patience here, everyone.

@anshjaiswal12 — the PR has been waiting on the changes I requested for a while now, so I want to make sure it doesn't stall. If you're still planning to push the fixes (the multi-stage Dockerfile + the README/QUICKSTART updates noted above), please drop a comment and we'll hold the slot for you.\n\n@spandanaerukull — thanks for offering to pick this up. If we don't hear back from @anshjaiswal12 in the next 5–7 days, please feel free to open a follow-up PR addressing the requested changes (multi-stage Dockerfile, frontend/Dockerfile slim build, BACKEND_URL documented in .env.example, and a Docker section in QUICKSTART.md). Either way the work won't go to waste.\n\nLet's keep the momentum going.

@Goldokpa
Copy link
Copy Markdown
Member

📢 Heads-up: repo history was rewritten today (2026-05-18)

We force-pushed a cleaned history across all branches to remove an internal directory from past commits. Your code and this PR are unaffected — only the commit SHAs underneath have shifted. GitHub will re-render the diff against the new base automatically.

If you have a local clone, please bring it back in sync before pushing anything else:

# Option A (simplest): fresh start
git clone https://github.com/Climate-Vision/ClimateVision.git

# Option B: rebase the existing PR branch in your fork
git fetch origin
git checkout <your-branch>
git rebase origin/main          # likely no conflicts
git push --force-with-lease

Do not git pull on an existing clone — it will produce a messy non-fast-forward state. Either re-clone, or rebase explicitly as above.

Apologies for the interruption — really appreciate your patience here. If anything looks off after rebasing, leave a comment and I'll help unblock right away. Thanks for contributing 🙏

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Good First Issue] Add Docker Compose for full-stack local development

6 participants