Metrics collector (wiregui/collector.py): - Standalone process spawned by web app when WG_METRICS_ENABLED=true - Polls wg show dump every WG_METRICS_POLL_INTERVAL seconds (default 5) - Updates device stats in PostgreSQL - Pushes Prometheus-format metrics to VictoriaMetrics (if configured) - Graceful shutdown on SIGTERM Integration test stack (compose.yml): - Unified compose file for dev, test, and integration modes - VictoriaMetrics single-node TSDB for metrics storage - 3 mock WireGuard client containers generating ping traffic - Automated setup script seeds server keypair, admin user, client devices - make test-stack-up: one command to start everything - make test-stack-verify: validates metrics flowing end-to-end Infrastructure: - Makefile with targets for dev, test, integration, and production - Integration tests verify VictoriaMetrics has data for all 3 clients - Fix Dockerfile to include img/ directory - Separate TESTS.md for test tracking, clean TODO.md for features only
57 lines
1.6 KiB
Docker
57 lines
1.6 KiB
Docker
FROM python:3.13-slim AS builder
|
|
|
|
WORKDIR /app
|
|
|
|
# Install uv for fast dependency resolution
|
|
COPY --from=ghcr.io/astral-sh/uv:latest /uv /usr/local/bin/uv
|
|
|
|
# Install system deps needed for building (wireguard-tools for wg CLI)
|
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
|
gcc libpq-dev wireguard-tools nftables iproute2 \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
# Copy dependency files first for layer caching
|
|
COPY pyproject.toml uv.lock* ./
|
|
|
|
# Install dependencies (production only, no dev group)
|
|
RUN uv sync --no-dev --frozen 2>/dev/null || uv sync --no-dev
|
|
|
|
# Copy application code
|
|
COPY wiregui/ wiregui/
|
|
COPY alembic/ alembic/
|
|
COPY alembic.ini ./
|
|
COPY img/ img/
|
|
|
|
FROM python:3.13-slim AS runner
|
|
|
|
WORKDIR /app
|
|
|
|
# Runtime dependencies
|
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
|
wireguard-tools nftables iproute2 libpq5 \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
# Copy uv and virtualenv from builder
|
|
COPY --from=builder /usr/local/bin/uv /usr/local/bin/uv
|
|
COPY --from=builder /app/.venv /app/.venv
|
|
COPY --from=builder /app/wiregui /app/wiregui
|
|
COPY --from=builder /app/img /app/img
|
|
COPY --from=builder /app/alembic /app/alembic
|
|
COPY --from=builder /app/alembic.ini /app/alembic.ini
|
|
COPY --from=builder /app/pyproject.toml /app/pyproject.toml
|
|
|
|
# Ensure the venv is on PATH
|
|
ENV PATH="/app/.venv/bin:$PATH"
|
|
ENV PYTHONUNBUFFERED=1
|
|
|
|
# Create logs directory
|
|
RUN mkdir -p /app/logs
|
|
|
|
ARG VERSION=0.0.0-dev
|
|
ENV WG_VERSION=$VERSION
|
|
|
|
EXPOSE 13000
|
|
EXPOSE 51820/udp
|
|
|
|
# Run migrations then start the app
|
|
CMD ["sh", "-c", "alembic upgrade head && python -m wiregui.main"]
|