49 lines
1.4 KiB
Docker
49 lines
1.4 KiB
Docker
# 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 \
|
|
&& sed -i 's/^import metrics_pb2/from shared import metrics_pb2/' /app/shared/metrics_pb2_grpc.py
|
|
|
|
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"]
|