Skip to content

feat: add Docker support for one-command local setup #47

Open
adarsh-7-satyam wants to merge 2 commits into
chaoss:mainfrom
adarsh-7-satyam:feat/docker-support
Open

feat: add Docker support for one-command local setup #47
adarsh-7-satyam wants to merge 2 commits into
chaoss:mainfrom
adarsh-7-satyam:feat/docker-support

Conversation

@adarsh-7-satyam
Copy link
Copy Markdown

@adarsh-7-satyam adarsh-7-satyam commented May 9, 2026

Closes #45

Problem

Setting up this project locally requires contributors to manually install Python 3.8+, Node.js 18+, create a virtual environment, and run bash.sh — which doesn't work on Windows without WSL. Version mismatches cause hard-to-reproduce environment-specific bugs, creating friction especially during high-volume programs like DMP 2026.

Solution

This PR adds full Docker Compose support so any contributor can get the
entire stack running with:

cp backend/.env.example backend/.env
# fill in GITHUB_TOKEN and OSDG_TOKEN
docker compose up --build

Frontend → http://localhost:3000
Backend → http://localhost:5000


Files Added

File Purpose
docker-compose.yml Orchestrates backend + frontend services
backend/Dockerfile Python 3.11-slim image, installs requirements.txt
frontend/Dockerfile Node 18 Alpine image, npm ci
backend/.env.example Documents GITHUB_TOKEN and OSDG_TOKEN for contributors
.dockerignore Excludes venv, node_modules, .env, .next from images

Code Changes

File Change
backend/app.py Added GET /health route required by Docker healthcheck
frontend/services/api.ts Backend URL now reads NEXT_PUBLIC_API_URL env var with fallback to 127.0.0.1:5000 so bare-metal workflow is unchanged

Design Decisions

HuggingFace model cachefacebook/bart-large-mnli and sentence-transformers/all-MiniLM-L6-v2 are large models that download at runtime. A named volume hf-model-cache persists them across container restarts so they download only once.

Flask bound to 0.0.0.0 — Flask defaults to 127.0.0.1 which is unreachable from outside the container. The backend Dockerfile uses flask run --host=0.0.0.0 to make it accessible on the Docker network.

Volume mounts for live reload — Source directories are mounted so code edits reflect immediately without rebuilding the image. Anonymous volumes guard node_modules and __pycache__ from being shadowed by the host.

depends_on with healthcheck — The frontend waits for the backend /health route to return 200 before starting, preventing cold-start race conditions.

Non-breaking fallback in api.ts — The ?? operator means contributors not using Docker get the same 127.0.0.1:5000 behaviour as before. Zero regression for existing workflow.


Testing Done

Tested locally on Windows 11 with Docker Desktop 27.4.0:

Level 1 — file verification

  • All 5 new files confirmed present on disk
  • /health route confirmed in backend/app.py line 17
  • NEXT_PUBLIC_API_URL confirmed in frontend/services/api.ts line 8

Level 2 — image builds

  • docker build -t unsdg-backend ./backend — 6/6 steps FINISHED
  • docker build -t unsdg-frontend ./frontend — 12/12 steps FINISHED

Level 3 — full stack smoke test

  • curl http://localhost:5000/health{"status": "ok"} 200
  • curl http://localhost:5000/api/hello{"message": "Hello, World!"} 200
  • Frontend verified loading correctly at http://localhost:3000

Level 4 — volume persistence

  • docker volume ls confirms unsdg-classifier-tool_hf-model-cache present
  • After docker compose down && docker compose up, backend reached healthy state instantly with no model re-download

Notes

Signed-off-by: Adarsh Satyam <adarsh5.satyam@gmail.com>
Signed-off-by: Adarsh Satyam <adarsh5.satyam@gmail.com>
@adarsh-7-satyam adarsh-7-satyam changed the title feat: add Docker support for one-command local setup (closes #45) feat: add Docker support for one-command local setup May 13, 2026
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.

Add Docker support for one-command local setup

1 participant