Initial commit
Some checks failed
CI/CD Pipeline / Code Quality & Linting (push) Has been cancelled
CI/CD Pipeline / Policy Validation (push) Has been cancelled
CI/CD Pipeline / Test Suite (push) Has been cancelled
CI/CD Pipeline / Build Docker Images (svc-coverage) (push) Has been cancelled
CI/CD Pipeline / Build Docker Images (svc-extract) (push) Has been cancelled
CI/CD Pipeline / Build Docker Images (svc-firm-connectors) (push) Has been cancelled
CI/CD Pipeline / Build Docker Images (svc-forms) (push) Has been cancelled
CI/CD Pipeline / Build Docker Images (svc-hmrc) (push) Has been cancelled
CI/CD Pipeline / Build Docker Images (svc-ingestion) (push) Has been cancelled
CI/CD Pipeline / Build Docker Images (svc-kg) (push) Has been cancelled
CI/CD Pipeline / Build Docker Images (svc-normalize-map) (push) Has been cancelled
CI/CD Pipeline / Build Docker Images (svc-ocr) (push) Has been cancelled
CI/CD Pipeline / Build Docker Images (svc-rag-indexer) (push) Has been cancelled
CI/CD Pipeline / Build Docker Images (svc-rag-retriever) (push) Has been cancelled
CI/CD Pipeline / Build Docker Images (svc-reason) (push) Has been cancelled
CI/CD Pipeline / Build Docker Images (svc-rpa) (push) Has been cancelled
CI/CD Pipeline / Build Docker Images (ui-review) (push) Has been cancelled
CI/CD Pipeline / Security Scanning (svc-coverage) (push) Has been cancelled
CI/CD Pipeline / Security Scanning (svc-extract) (push) Has been cancelled
CI/CD Pipeline / Security Scanning (svc-kg) (push) Has been cancelled
CI/CD Pipeline / Security Scanning (svc-rag-retriever) (push) Has been cancelled
CI/CD Pipeline / Security Scanning (ui-review) (push) Has been cancelled
CI/CD Pipeline / Generate SBOM (push) Has been cancelled
CI/CD Pipeline / Deploy to Staging (push) Has been cancelled
CI/CD Pipeline / Deploy to Production (push) Has been cancelled
CI/CD Pipeline / Notifications (push) Has been cancelled

This commit is contained in:
harkon
2025-10-11 08:41:36 +01:00
commit b324ff09ef
276 changed files with 55220 additions and 0 deletions

View File

@@ -0,0 +1,47 @@
# Template Dockerfile for ML Services
# This uses the pre-built base-ml image which contains all heavy ML dependencies
# Only the application code is added on top (~50MB vs 1.2GB)
#
# Usage: Copy this template to apps/svc_*/Dockerfile and replace SERVICE_NAME
# Use the pre-built ML base image
ARG REGISTRY=gitea.harkon.co.uk
ARG OWNER=harkon
ARG BASE_VERSION=v1.0.1
FROM ${REGISTRY}/${OWNER}/base-ml:${BASE_VERSION}
# Switch to root to install service-specific dependencies
USER root
# Set working directory
WORKDIR /app
# Copy service-specific requirements (if any additional deps needed)
# Most ML deps are already in base-ml, so this should be minimal
COPY apps/SERVICE_NAME/requirements.txt /tmp/service-requirements.txt
# Install any service-specific dependencies (should be very few)
RUN if [ -s /tmp/service-requirements.txt ]; then \
pip install --no-cache-dir -r /tmp/service-requirements.txt; \
fi
# Copy application code
COPY libs/ ./libs/
COPY apps/SERVICE_NAME/ ./apps/SERVICE_NAME/
# Set permissions
RUN chown -R appuser:appuser /app
# Switch back to non-root user
USER appuser
# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
CMD curl -f http://localhost:8000/healthz || exit 1
# Expose port
EXPOSE 8000
# Run the application
CMD ["python", "-m", "uvicorn", "apps.SERVICE_NAME.main:app", "--host", "0.0.0.0", "--port", "8000"]

View File

@@ -0,0 +1,58 @@
# Base ML Image - Contains all heavy ML dependencies
# This image is built once and reused by all ML services (svc-ocr, svc-rag-indexer, svc-rag-retriever)
#
# Build: docker build -t gitea.harkon.co.uk/harkon/base-ml:v1.0.1 -f infra/docker/base-ml.Dockerfile .
# Push: docker push gitea.harkon.co.uk/harkon/base-ml:v1.0.1
FROM python:3.12-slim as builder
# Install build dependencies
RUN apt-get update && apt-get install -y \
build-essential \
curl \
git \
&& rm -rf /var/lib/apt/lists/*
# Create virtual environment
RUN python -m venv /opt/venv
ENV PATH="/opt/venv/bin:$PATH"
# Copy requirements files
COPY libs/requirements-base.txt /tmp/requirements-base.txt
COPY libs/requirements-ml.txt /tmp/requirements-ml.txt
# Install all dependencies (base + ML)
RUN pip install --no-cache-dir --upgrade pip && \
pip install --no-cache-dir -r /tmp/requirements-base.txt && \
pip install --no-cache-dir -r /tmp/requirements-ml.txt
# Final stage - Runtime image
FROM python:3.12-slim
# Install runtime dependencies
RUN apt-get update && apt-get install -y \
curl \
&& rm -rf /var/lib/apt/lists/* \
&& groupadd -r appuser \
&& useradd -r -g appuser appuser
# Copy virtual environment from builder
COPY --from=builder /opt/venv /opt/venv
# Set environment variables
ENV PATH="/opt/venv/bin:$PATH" \
PYTHONUNBUFFERED=1 \
PYTHONDONTWRITEBYTECODE=1
# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
CMD python -c "import sentence_transformers; import transformers; print('ML base image healthy')"
# Default user
USER appuser
# Label
LABEL maintainer="AI Tax Agent Team" \
description="Base ML image with sentence-transformers, PyTorch, and ML dependencies" \
version="1.0.1"

View File

@@ -0,0 +1,55 @@
# Base Runtime Image - Contains core dependencies for ALL services
# This image is built once and reused by all non-ML services
#
# Build: docker build -t gitea.harkon.co.uk/harkon/base-runtime:v1.0.1 -f infra/docker/base-runtime.Dockerfile .
# Push: docker push gitea.harkon.co.uk/harkon/base-runtime:v1.0.1
FROM python:3.12-slim as builder
# Install build dependencies
RUN apt-get update && apt-get install -y \
build-essential \
curl \
&& rm -rf /var/lib/apt/lists/*
# Create virtual environment
RUN python -m venv /opt/venv
ENV PATH="/opt/venv/bin:$PATH"
# Copy requirements file
COPY libs/requirements-base.txt /tmp/requirements-base.txt
# Install base dependencies
RUN pip install --no-cache-dir --upgrade pip && \
pip install --no-cache-dir -r /tmp/requirements-base.txt
# Final stage - Runtime image
FROM python:3.12-slim
# Install runtime dependencies
RUN apt-get update && apt-get install -y \
curl \
&& rm -rf /var/lib/apt/lists/* \
&& groupadd -r appuser \
&& useradd -r -g appuser appuser
# Copy virtual environment from builder
COPY --from=builder /opt/venv /opt/venv
# Set environment variables
ENV PATH="/opt/venv/bin:$PATH" \
PYTHONUNBUFFERED=1 \
PYTHONDONTWRITEBYTECODE=1
# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
CMD python -c "import fastapi; import uvicorn; print('Base runtime image healthy')"
# Default user
USER appuser
# Label
LABEL maintainer="AI Tax Agent Team" \
description="Base runtime image with FastAPI, database drivers, and core dependencies" \
version="1.0.1"