Skip to content

Commit f65e91f

Browse files
committed
deploy with help + added instruction
1 parent 917bcdd commit f65e91f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+3089
-73
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,3 +90,7 @@ yarn-error.log*
9090

9191
# Build outputs
9292
frontend/public/build/
93+
94+
# Helm
95+
helm/*/charts/*.tgz
96+
helm/*/Chart.lock

backend/Dockerfile.base

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ RUN apt-get update && apt-get install -y \
1212
liblzma-dev \
1313
&& rm -rf /var/lib/apt/lists/*
1414

15-
# Install uv
16-
COPY --from=ghcr.io/astral-sh/uv:0.9.17 /uv /uvx /bin/
15+
# Install uv (using Docker Hub mirror - ghcr.io has rate limiting issues)
16+
COPY --from=astral/uv:latest /uv /uvx /bin/
1717

1818
# Copy dependency files
1919
COPY pyproject.toml uv.lock ./

backend/app/services/coordinator/coordinator.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,9 +124,10 @@ async def start(self) -> None:
124124

125125
await self.idempotency_manager.initialize()
126126

127+
settings = get_settings()
127128
consumer_config = ConsumerConfig(
128129
bootstrap_servers=self.kafka_servers,
129-
group_id= f"{self.consumer_group}.{settings.KAFKA_GROUP_SUFFIX}",
130+
group_id=f"{self.consumer_group}.{settings.KAFKA_GROUP_SUFFIX}",
130131
enable_auto_commit=False,
131132
session_timeout_ms=30000, # 30 seconds
132133
heartbeat_interval_ms=10000, # 10 seconds (must be < session_timeout / 3)

backend/scripts/create_admin_user.py

Lines changed: 0 additions & 68 deletions
This file was deleted.

backend/scripts/create_topics.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,15 @@ async def create_topics() -> None:
3535
# Get all required topics and their configs
3636
all_topics = get_all_topics()
3737
topic_configs = get_topic_configs()
38-
logger.info(f"Total required topics: {len(all_topics)}")
38+
topic_prefix = settings.KAFKA_TOPIC_PREFIX
39+
logger.info(f"Total required topics: {len(all_topics)} (prefix: '{topic_prefix}')")
3940

4041
# Create topics
4142
topics_to_create: List[NewTopic] = []
4243

4344
for topic in all_topics:
44-
topic_name = topic.value
45+
# Apply topic prefix for consistency with consumers/producers
46+
topic_name = f"{topic_prefix}{topic.value}"
4547
if topic_name not in existing_topics:
4648
# Get config from topic_configs
4749
config = topic_configs.get(topic, {

backend/scripts/seed_users.py

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
#!/usr/bin/env python3
2+
"""
3+
Seed default users in MongoDB (idempotent - safe to run multiple times).
4+
5+
Creates:
6+
1. Default user (role=user) for testing/demo
7+
2. Admin user (role=admin, is_superuser=True) for administration
8+
9+
Environment Variables:
10+
MONGODB_URL: Connection string (default: mongodb://mongo:27017/integr8scode)
11+
DEFAULT_USER_PASSWORD: Default user password (default: user123)
12+
ADMIN_USER_PASSWORD: Admin user password (default: admin123)
13+
"""
14+
15+
import asyncio
16+
import os
17+
from datetime import datetime, timezone
18+
19+
from bson import ObjectId
20+
from motor.motor_asyncio import AsyncIOMotorClient
21+
from passlib.context import CryptContext
22+
23+
pwd_context = CryptContext(schemes=["bcrypt"], deprecated="auto")
24+
25+
26+
async def upsert_user(db, username: str, email: str, password: str, role: str, is_superuser: bool) -> None:
27+
"""Create user or update if exists."""
28+
existing = await db.users.find_one({"username": username})
29+
30+
if existing:
31+
print(f"User '{username}' exists - updating role={role}, is_superuser={is_superuser}")
32+
await db.users.update_one(
33+
{"username": username},
34+
{"$set": {
35+
"role": role,
36+
"is_superuser": is_superuser,
37+
"is_active": True,
38+
"updated_at": datetime.now(timezone.utc)
39+
}}
40+
)
41+
else:
42+
print(f"Creating user '{username}' (role={role}, is_superuser={is_superuser})")
43+
await db.users.insert_one({
44+
"_id": ObjectId(),
45+
"user_id": str(ObjectId()),
46+
"username": username,
47+
"email": email,
48+
"hashed_password": pwd_context.hash(password),
49+
"role": role,
50+
"is_active": True,
51+
"is_superuser": is_superuser,
52+
"created_at": datetime.now(timezone.utc),
53+
"updated_at": datetime.now(timezone.utc)
54+
})
55+
56+
57+
async def seed_users() -> None:
58+
mongodb_url = os.getenv("MONGODB_URL", "mongodb://mongo:27017/integr8scode")
59+
print(f"Connecting to MongoDB...")
60+
61+
client: AsyncIOMotorClient = AsyncIOMotorClient(mongodb_url)
62+
db_name = mongodb_url.rstrip("/").split("/")[-1].split("?")[0] or "integr8scode"
63+
db = client[db_name]
64+
65+
# Default user
66+
await upsert_user(
67+
db,
68+
username="user",
69+
70+
password=os.getenv("DEFAULT_USER_PASSWORD", "user123"),
71+
role="user",
72+
is_superuser=False
73+
)
74+
75+
# Admin user
76+
await upsert_user(
77+
db,
78+
username="admin",
79+
80+
password=os.getenv("ADMIN_USER_PASSWORD", "admin123"),
81+
role="admin",
82+
is_superuser=True
83+
)
84+
85+
print("\n" + "=" * 50)
86+
print("SEEDED USERS:")
87+
print("=" * 50)
88+
print("Default: user / user123 (or DEFAULT_USER_PASSWORD)")
89+
print("Admin: admin / admin123 (or ADMIN_USER_PASSWORD)")
90+
print("=" * 50)
91+
92+
client.close()
93+
94+
95+
if __name__ == "__main__":
96+
asyncio.run(seed_users())

0 commit comments

Comments
 (0)