first claude draft

This commit is contained in:
buenosairesam
2025-12-29 14:40:06 -03:00
commit 116d4032e2
69 changed files with 5020 additions and 0 deletions

View File

@@ -0,0 +1,47 @@
# Multi-stage Dockerfile for Aggregator service
FROM python:3.11-slim as base
WORKDIR /app
# Install system dependencies including grpc_health_probe
RUN apt-get update && apt-get install -y --no-install-recommends \
curl \
&& curl -fsSL https://github.com/grpc-ecosystem/grpc-health-probe/releases/download/v0.4.24/grpc_health_probe-linux-amd64 \
-o /bin/grpc_health_probe \
&& chmod +x /bin/grpc_health_probe \
&& rm -rf /var/lib/apt/lists/*
COPY services/aggregator/requirements.txt /app/requirements.txt
RUN pip install --no-cache-dir -r requirements.txt
COPY shared /app/shared
COPY proto /app/proto
RUN python -m grpc_tools.protoc \
-I/app/proto \
--python_out=/app/shared \
--grpc_python_out=/app/shared \
/app/proto/metrics.proto
COPY services/aggregator /app/services/aggregator
ENV PYTHONPATH=/app
ENV PYTHONUNBUFFERED=1
# =============================================================================
FROM base as development
RUN pip install --no-cache-dir watchfiles
CMD ["python", "-m", "watchfiles", "python services/aggregator/main.py", "/app/services/aggregator"]
# =============================================================================
FROM base as production
RUN useradd --create-home --shell /bin/bash appuser
USER appuser
EXPOSE 50051
CMD ["python", "services/aggregator/main.py"]

View File

@@ -0,0 +1,9 @@
grpcio>=1.60.0
grpcio-tools>=1.60.0
grpcio-health-checking>=1.60.0
redis>=5.0.0
asyncpg>=0.29.0
structlog>=23.2.0
python-json-logger>=2.0.7
pydantic>=2.5.0
pydantic-settings>=2.1.0

View File

@@ -0,0 +1,35 @@
# Multi-stage Dockerfile for Alerts service
FROM python:3.11-slim as base
WORKDIR /app
RUN apt-get update && apt-get install -y --no-install-recommends \
curl \
&& rm -rf /var/lib/apt/lists/*
COPY services/alerts/requirements.txt /app/requirements.txt
RUN pip install --no-cache-dir -r requirements.txt
COPY shared /app/shared
COPY proto /app/proto
COPY services/alerts /app/services/alerts
ENV PYTHONPATH=/app
ENV PYTHONUNBUFFERED=1
# =============================================================================
FROM base as development
RUN pip install --no-cache-dir watchfiles
CMD ["python", "-m", "watchfiles", "python services/alerts/main.py", "/app/services/alerts"]
# =============================================================================
FROM base as production
RUN useradd --create-home --shell /bin/bash appuser
USER appuser
CMD ["python", "services/alerts/main.py"]

View File

@@ -0,0 +1,6 @@
redis>=5.0.0
asyncpg>=0.29.0
structlog>=23.2.0
python-json-logger>=2.0.7
pydantic>=2.5.0
pydantic-settings>=2.1.0

View File

@@ -0,0 +1,55 @@
# Multi-stage Dockerfile for Collector service
# Stages: base -> development, base -> production
# =============================================================================
# Base stage - common dependencies
# =============================================================================
FROM python:3.11-slim as base
WORKDIR /app
# Install system dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
curl \
&& rm -rf /var/lib/apt/lists/*
# Install Python dependencies
COPY services/collector/requirements.txt /app/requirements.txt
RUN pip install --no-cache-dir -r requirements.txt
# Copy shared code and proto
COPY shared /app/shared
COPY proto /app/proto
# Generate gRPC code from proto
RUN python -m grpc_tools.protoc \
-I/app/proto \
--python_out=/app/shared \
--grpc_python_out=/app/shared \
/app/proto/metrics.proto
# Copy service code
COPY services/collector /app/services/collector
ENV PYTHONPATH=/app
ENV PYTHONUNBUFFERED=1
# =============================================================================
# Development stage - with hot reload
# =============================================================================
FROM base as development
RUN pip install --no-cache-dir watchfiles
CMD ["python", "-m", "watchfiles", "python services/collector/main.py", "/app/services/collector"]
# =============================================================================
# Production stage - optimized
# =============================================================================
FROM base as production
# Run as non-root user
RUN useradd --create-home --shell /bin/bash appuser
USER appuser
CMD ["python", "services/collector/main.py"]

View File

@@ -0,0 +1,7 @@
grpcio>=1.60.0
grpcio-tools>=1.60.0
psutil>=5.9.0
structlog>=23.2.0
python-json-logger>=2.0.7
pydantic>=2.5.0
pydantic-settings>=2.1.0

View File

@@ -0,0 +1,44 @@
# Multi-stage Dockerfile for Gateway service (FastAPI)
FROM python:3.11-slim as base
WORKDIR /app
RUN apt-get update && apt-get install -y --no-install-recommends \
curl \
&& rm -rf /var/lib/apt/lists/*
COPY services/gateway/requirements.txt /app/requirements.txt
RUN pip install --no-cache-dir -r requirements.txt
COPY shared /app/shared
COPY proto /app/proto
RUN python -m grpc_tools.protoc \
-I/app/proto \
--python_out=/app/shared \
--grpc_python_out=/app/shared \
/app/proto/metrics.proto
COPY services/gateway /app/services/gateway
COPY web /app/web
ENV PYTHONPATH=/app
ENV PYTHONUNBUFFERED=1
# =============================================================================
FROM base as development
RUN pip install --no-cache-dir watchfiles
CMD ["uvicorn", "services.gateway.main:app", "--host", "0.0.0.0", "--port", "8000", "--reload"]
# =============================================================================
FROM base as production
RUN useradd --create-home --shell /bin/bash appuser
USER appuser
EXPOSE 8000
CMD ["uvicorn", "services.gateway.main:app", "--host", "0.0.0.0", "--port", "8000", "--workers", "2"]

View File

@@ -0,0 +1,13 @@
fastapi>=0.109.0
uvicorn[standard]>=0.27.0
grpcio>=1.60.0
grpcio-tools>=1.60.0
redis>=5.0.0
asyncpg>=0.29.0
websockets>=12.0
jinja2>=3.1.2
structlog>=23.2.0
python-json-logger>=2.0.7
pydantic>=2.5.0
pydantic-settings>=2.1.0
httpx>=0.26.0