Skip to content

Commit 4e10535

Browse files
committed
ranker: server, db data modelling for interests and groups to connect for with API
Signed-off-by: Saif Ul Islam <[email protected]>
1 parent 0e29136 commit 4e10535

File tree

9 files changed

+413
-122
lines changed

9 files changed

+413
-122
lines changed

projects/rank-nsf-linker/Makefile

Lines changed: 80 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,36 @@
11
APP_NAME := go-server
22
DOCKER_COMPOSE := docker compose -f docker-compose.dev.yaml
3+
REGISTRY_CONTAINER := local-registry
4+
REGISTRY_PORT := 5128
5+
REGISTRY := host.docker.internal:$(REGISTRY_PORT)
36
SERVICE := go-server
47

8+
# Helper: pull or cache image in registry if missing
9+
define ensure_image
10+
@IMAGE=$(1); \
11+
if ! docker manifest inspect $(REGISTRY)/$$IMAGE >/dev/null 2>&1; then \
12+
echo "📥 Pulling $$IMAGE from internet..."; \
13+
docker pull $$IMAGE; \
14+
echo "📦 Tagging & pushing to local registry..."; \
15+
docker tag $$IMAGE $(REGISTRY)/$$IMAGE; \
16+
docker push $(REGISTRY)/$$IMAGE; \
17+
else \
18+
echo "✅ Image already cached locally: $(REGISTRY)/$$IMAGE"; \
19+
fi
20+
endef
21+
22+
# Utility function to check container existence
23+
define container_exists
24+
@docker ps -a --format '{{.Names}}' | grep -q "^$(1)$$"
25+
endef
26+
27+
# Utility function to check running status
28+
define container_running
29+
@docker ps --format '{{.Names}}' | grep -q "^$(1)$$"
30+
endef
31+
532
.PHONY: all build run docker-build up down logs restart clean \
6-
exec exec-bash ps top start stop status rebuild
33+
exec exec-bash ps top start stop status rebuild rm-all registry up-infra
734

835
all: build
936

@@ -14,13 +41,52 @@ build:
1441
run:
1542
./$(APP_NAME)
1643

17-
# Compose build only
44+
# Push images to local registry after build
45+
push-images:
46+
@echo "📤 Tagging and pushing images to local registry..."
47+
@docker tag rank-nsf-linker-go-server:latest $(REGISTRY)/go-server:latest
48+
@docker tag rank-nsf-linker-web:latest $(REGISTRY)/web-ui:latest
49+
@docker push $(REGISTRY)/go-server:latest
50+
@docker push $(REGISTRY)/web-ui:latest
51+
@echo "✅ Images pushed to $(REGISTRY)"
52+
53+
# Registry Setup
54+
registry:
55+
@if docker ps --format '{{.Names}}' | grep -q $(REGISTRY_CONTAINER); then \
56+
echo "✅ Local registry already running on :$(REGISTRY_PORT)"; \
57+
else \
58+
echo "🚀 Starting local Docker registry on :$(REGISTRY_PORT)..."; \
59+
docker run -d --restart=always \
60+
-p $(REGISTRY_PORT):5000 \
61+
--name $(REGISTRY_CONTAINER) registry:2; \
62+
fi
63+
64+
# Infrastructure setup (Postgres, ES, Qdrant)
65+
up-infra:
66+
@if ! docker ps --format '{{.Names}}' | grep -q "pg17-local"; then \
67+
echo "📦 Starting PostgreSQL, Elasticsearch, and Qdrant..."; \
68+
$(DOCKER_COMPOSE) up -d postgres elasticsearch qdrant; \
69+
else \
70+
echo "✅ Infrastructure already running."; \
71+
fi
72+
73+
infra-images:
74+
$(call ensure_image,cgr.dev/chainguard/postgres)
75+
$(call ensure_image,docker.elastic.co/elasticsearch/elasticsearch:8.13.0)
76+
$(call ensure_image,qdrant/qdrant:v1.3.0)
77+
78+
# App lifecycle
1879
docker-build:
1980
$(DOCKER_COMPOSE) build
2081

2182
# Spin up services in background
22-
up:
23-
$(DOCKER_COMPOSE) up -d
83+
up: registry up-infra
84+
@if ! docker ps --format '{{.Names}}' | grep -q "$(SERVICE)"; then \
85+
echo "🚀 Launching main services (web + go-server)..."; \
86+
$(DOCKER_COMPOSE) up -d go-server web; \
87+
else \
88+
echo "✅ Main services already running."; \
89+
fi
2490

2591
# Bring down all containers, networks
2692
down:
@@ -78,11 +144,17 @@ status:
78144

79145
# Full rebuild with clean
80146
rebuild:
81-
$(DOCKER_COMPOSE) down -v --remove-orphans
82-
$(DOCKER_COMPOSE) build --no-cache
83-
$(DOCKER_COMPOSE) up -d
84-
make rm-all && make docker-build && make up && make logs-go-server
147+
make rm-all
148+
make registry
149+
make infra-images
150+
make docker-build
151+
make push-images
152+
make up
153+
make logs-go-server
85154

86155
# Remove all
87156
rm-all:
157+
$(DOCKER_COMPOSE) down -v --remove-orphans
158+
159+
rm-all-hard:
88160
$(DOCKER_COMPOSE) down --rmi all -v --remove-orphans

projects/rank-nsf-linker/README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ This system helps prospective students, collaborators, or researchers **identify
99
- [🔗 Algorithm: Mapping CS Faculty to NSF Awards \& Google Scholar Publications](#-algorithm-mapping-cs-faculty-to-nsf-awards--google-scholar-publications)
1010
- [🧠 Step-by-Step Algorithm](#-step-by-step-algorithm)
1111
- [🛠️ Expand Features to Support Further Use Cases](#️-expand-features-to-support-further-use-cases)
12+
- [Debugging](#debugging)
13+
- [http: server gave HTTP response to HTTPS client](#http-server-gave-http-response-to-https-client)
1214

1315
## 🧭 Use Cases
1416

@@ -127,3 +129,15 @@ This algorithm enhances the core faculty selection tool by connecting researcher
127129
| 📤 **Export Options** (CSV, JSON) | Helps bloggers, journalists, students do deeper dives |
128130
| 🔄 **Daily/Weekly Sync with NSF API** | Keep data fresh |
129131
| 💡 **“Suggested Researchers” Engine** | “If you liked this grant/lab, here are similar ones” |
132+
133+
# Debugging
134+
135+
## http: server gave HTTP response to HTTPS client
136+
137+
If "HTTP/HTTPS" error occurs while pushing the docker images, add the following to the Docker Engine configuration,
138+
139+
```json
140+
"insecure-registries": [
141+
"host.docker.internal:5128"
142+
]
143+
```

projects/rank-nsf-linker/docker-compose.dev.yaml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
services:
22
postgres:
3-
image: cgr.dev/chainguard/postgres
3+
image: host.docker.internal:5128/cgr.dev/chainguard/postgres
44
container_name: pg17-local
55
restart: unless-stopped
66
ports:
@@ -40,7 +40,7 @@ services:
4040
- default
4141

4242
elasticsearch:
43-
image: docker.elastic.co/elasticsearch/elasticsearch:8.13.0
43+
image: host.docker.internal:5128/docker.elastic.co/elasticsearch/elasticsearch:8.13.0
4444
container_name: es-local
4545
environment:
4646
- discovery.type=single-node
@@ -56,7 +56,7 @@ services:
5656
- default
5757

5858
qdrant:
59-
image: qdrant/qdrant:v1.3.0
59+
image: host.docker.internal:5128/qdrant/qdrant:v1.3.0
6060
container_name: qdrant-local
6161
ports:
6262
- "6333:6333"
@@ -67,6 +67,7 @@ services:
6767
- default
6868

6969
go-server:
70+
image: host.docker.internal:5128/go-server:latest
7071
container_name: go-server
7172
build:
7273
context: ./server
@@ -101,6 +102,7 @@ services:
101102
- default
102103

103104
web:
105+
image: host.docker.internal:5128/web-ui:latest
104106
container_name: web-ui
105107
build:
106108
context: ./web

0 commit comments

Comments
 (0)