Add multi-stage Dockerfiles for Python services (Dockerfile.service) and React dashboard (Dockerfile.dashboard + nginx.conf). Update docker-compose.yml with all seven application services: news-fetcher, sentiment-analyzer, signal-generator, trade-executor, learning-engine, api-gateway, and dashboard.
45 lines
1.5 KiB
Desktop File
45 lines
1.5 KiB
Desktop File
# Multi-stage Dockerfile for all Python microservices.
|
|
# Build args:
|
|
# EXTRAS — pip optional-dependency groups (e.g. "news", "sentiment,trading")
|
|
# SERVICE_MODULE — Python module name under services/ (e.g. "news_fetcher")
|
|
|
|
# ---------------------------------------------------------------------------
|
|
# Stage 1: builder — install Python dependencies
|
|
# ---------------------------------------------------------------------------
|
|
FROM python:3.12-slim AS builder
|
|
|
|
WORKDIR /app
|
|
|
|
# Copy project metadata and source so pip can resolve the local package
|
|
COPY pyproject.toml .
|
|
COPY shared/ shared/
|
|
COPY services/ services/
|
|
COPY backtester/ backtester/
|
|
COPY alembic/ alembic/
|
|
COPY alembic.ini .
|
|
|
|
ARG EXTRAS="dev"
|
|
RUN pip install --no-cache-dir ".[$EXTRAS]"
|
|
|
|
# ---------------------------------------------------------------------------
|
|
# Stage 2: slim runtime image
|
|
# ---------------------------------------------------------------------------
|
|
FROM python:3.12-slim
|
|
|
|
WORKDIR /app
|
|
|
|
# Copy installed packages and CLI entry-points from the builder
|
|
COPY --from=builder /usr/local/lib/python3.12/site-packages /usr/local/lib/python3.12/site-packages
|
|
COPY --from=builder /usr/local/bin /usr/local/bin
|
|
|
|
# Copy application source code
|
|
COPY --from=builder /app .
|
|
|
|
ARG SERVICE_MODULE="api_gateway"
|
|
ENV SERVICE_MODULE=${SERVICE_MODULE}
|
|
|
|
# Simple health check — verify the Python process is running
|
|
HEALTHCHECK --interval=30s --timeout=10s --start-period=15s --retries=3 \
|
|
CMD python -c "import sys; sys.exit(0)" || exit 1
|
|
|
|
CMD python -m services.${SERVICE_MODULE}.main
|