Skip to content

Commit a121a34

Browse files
committed
docker
1 parent bc22d58 commit a121a34

13 files changed

Lines changed: 1510 additions & 0 deletions

File tree

.env.docker

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Docker Compose Environment
2+
COMPOSE_PROJECT_NAME=bl1nk-agent-builder
3+
ENVIRONMENT=development
4+
5+
# Database
6+
POSTGRES_DB=bl1nk
7+
POSTGRES_USER=bl1nk_user
8+
POSTGRES_PASSWORD=bl1nk_password
9+
10+
# Redis
11+
REDIS_PASSWORD=bl1nk_redis_password
12+
13+
# Services
14+
FASTAPI_PORT=8000
15+
WORKER_PORT=8001
16+
UI_PORT=3000
17+
BRIDGE_PORT=8787

Dockerfile.worker

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
FROM python:3.11-slim
2+
3+
# Set working directory
4+
WORKDIR /app
5+
6+
# ให้ Python เห็น apps/worker เป็น root เพื่อให้ import "app...." ได้
7+
ENV PYTHONPATH="/app/apps/worker"
8+
9+
# Install system dependencies (updated for slimmer image, includes git for possible dependencies)
10+
RUN apt-get update && apt-get install -y \
11+
gcc \
12+
g++ \
13+
curl \
14+
git \
15+
libpq-dev \
16+
&& rm -rf /var/lib/apt/lists/*
17+
18+
# Copy requirements first for better caching
19+
COPY apps/worker/requirements.txt .
20+
RUN pip install --no-cache-dir -r requirements.txt
21+
22+
# Copy application code
23+
COPY . /app/
24+
25+
# Create non-root user
26+
RUN useradd --create-home --shell /bin/bash app \
27+
&& chown -R app:app /app
28+
USER app
29+
30+
# Expose port
31+
EXPOSE 8000
32+
33+
# Health check
34+
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
35+
CMD curl -f http://localhost:8000/health || exit 1
36+
37+
# Run application
38+
CMD ["uvicorn", "apps.worker.app.main:app", "--host", "0.0.0.0", "--port", "8000", "--workers", "1"]

apps/bridge/Dockerfile

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
FROM node:18-alpine
2+
3+
WORKDIR /app
4+
5+
# Copy package files (จาก context ./apps/bridge)
6+
COPY package*.json ./
7+
8+
# ติดตั้ง dependencies แบบ production โดยไม่ใช้ npm ci (เพราะไม่มี package-lock)
9+
RUN npm install --only=production
10+
11+
# Copy source code
12+
COPY src/ ./src/
13+
14+
# Expose port
15+
EXPOSE 8787
16+
17+
# ให้มี curl สำหรับ healthcheck
18+
RUN apk add --no-cache curl
19+
20+
# Health check
21+
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
22+
CMD curl -f http://localhost:8787/health || exit 1
23+
24+
# Run worker
25+
CMD ["npm", "start"]
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
from bedrock_agentcore.memory import MemorySessionManager
2+
from bedrock_agentcore.memory.constants import ConversationalMessage, MessageRole
3+
4+
# Initialize the session manager
5+
manager = MemorySessionManager(
6+
memory_id="your-memory-id", # Use existing memory id
7+
region_name="us-east-1"
8+
)
9+
10+
# Create a session for a specific actor
11+
session = manager.create_memory_session(
12+
actor_id="user-123",
13+
session_id="session-456" # Optional - will generate UUID if not provided
14+
)
15+
16+
# Add conversation turns
17+
session.add_turns([
18+
ConversationalMessage("I love eating apples and cherries", MessageRole.USER),
19+
ConversationalMessage("Apples are very good for you!", MessageRole.ASSISTANT),
20+
ConversationalMessage("What's your favorite thing about apples?", MessageRole.USER),
21+
ConversationalMessage("I enjoy their flavor and nutritional benefits", MessageRole.ASSISTANT)
22+
])
23+
24+
# Search long-term memories (after memory extraction has occurred)
25+
memories = session.search_long_term_memories(
26+
query="what food does the user like",
27+
namespace_prefix="/food/user-123",
28+
top_k=5
29+
)
30+
31+
# Or search across multiple users
32+
memories = manager.search_long_term_memories(
33+
query="Food preferences",
34+
namespace_prefix="/food/", # Search all food-related memories
35+
top_k=10
36+
)

infra/prometheus/prometheus.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
global:
2+
scrape_interval: 15s
3+
evaluation_interval: 15s
4+
5+
scrape_configs:
6+
# Prometheus เอง
7+
- job_name: 'prometheus'
8+
static_configs:
9+
- targets: ['prometheus:9090']
10+
11+
# FastAPI worker (ถ้ามี /metrics)
12+
- job_name: 'worker'
13+
metrics_path: /metrics
14+
static_configs:
15+
- targets: ['worker:8000']

0 commit comments

Comments
 (0)