# watonomous/wato_base_images architecture

> Architecture diagram of the GitHub repository watonomous/wato_base_images, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-06-30). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/watonomous/wato_base_images
- Repository: https://github.com/watonomous/wato_base_images

## Overview

##### Project Type and Purpose
- This is not a full-stack app or microservice mesh but a DevOps toolset: a GitHub-Actions-driven pipeline for building and pushing Docker “base” images (for multiple monorepos) to a container registry.
- The README and file tree show:
- A JSON config (`.github/include/base_image_config.json`) listing the image definitions
- A reusable GitHub Actions template + shell script (`.github/templates/docker_context/*`) that reads that config to drive builds
- Two specialized Dockerfiles (`inject_ros2.Dockerfile`, `inject_wato_base.Dockerfile`)
- A script to push ARM64 variants (`deploy_arm64.sh`)
- A workflow (`.github/workflows/build_base_images.yml`) that ties it all together

##### Analyzing the File Structure
- Top-level
- `README.md` explains usage
- `inject_*.Dockerfile` – image build blueprints
- `deploy_arm64.sh` – supports ARM64 builds/pushes
- `.github/`
- `workflows/build_base_images.yml` – CI pipeline definition
- `templates/docker_context` – a custom Action plus shell logic for reading the JSON and constructing the Docker build contexts
- `include/base_image_config.json` – the single source of truth for “which” images to build and tag, and what each one contains

##### Key Components
a. CONFIGURATION LAYER
– base_image_config.json (defines image names, versions, build args)
– deploy_arm64.sh (for alternate-arch builds)
b. PIPELINE LAYER (GitHub Actions)
– build_base_images workflow
– docker_context composite action (template)
c. BUILD ARTIFACTS
– inject_wato_base.Dockerfile
– inject_ros2.Dockerfile
– generated Docker contexts per image
d. EXTERNAL SERVICES
– Docker daemon (local or GitHub runners)
– Docker Hub (or ghcr.io) registry

##### Interactions and Data Flow
1. A human or scheduled trigger invokes the “Build Monorepo Base Images” workflow.
2. The workflow reads `base_image_config.json` via the `docker_context` Action + `docker_context.sh`.
3. For each image entry in JSON, the Action:
- populates a temp build context (copies the right Dockerfile + adds config)
- runs `docker build` (on `x86_64` runners) or `deploy_arm64.sh` (on ARM hardware)
- tags & pushes to the registry
4. The registry holds published images, ready for downstream monorepos.

##### Architectural Patterns and Principles
- Configuration-driven builds: central JSON → dynamic context generation
- “Pipeline as code”: all steps in GitHub Actions YAML + composite Action
- Modular Dockerfiles: separate concerns (ROS2 vs base)
- Extensibility: new images are just new JSON entries + optional Dockerfile

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Configuration & Source Layer
    subgraph "Configuration & Source"
        Config["base_image_config.json"]:::config
        Script["deploy_arm64.sh"]:::script
        subgraph "Image Blueprints"
            WATO["inject_wato_base.Dockerfile"]:::dockerfile
            ROS2["inject_ros2.Dockerfile"]:::dockerfile
        end
    end

    %% CI/CD Pipeline Layer
    subgraph "CI/CD Pipeline"
        Human(("Manual/Scheduled Trigger")):::external
        Workflow["build_base_images.yml"]:::workflow
        Composite["docker_context Composite Action"]:::workflow
        ActionDef["action.yml"]:::workflow
        ActionLogic["docker_context.sh"]:::script
    end

    %% External Systems Layer
    subgraph "External Systems"
        Docker[(Docker Engine)]:::external
        Registry[(Container Registry)]:::external
    end

    %% Connections
    Human -->|"triggers workflow"| Workflow
    Workflow -->|"uses Composite Action"| Composite
    Composite -->|"reads image definitions"| Config
    Composite -->|"executes logic"| ActionLogic
    Composite -->|"defines interface"| ActionDef
    Composite -->|"populates context & docker build"| Docker
    Script -->|"ARM64 build & push"| Docker
    Docker -->|"push <image>:<tag>"| Registry

    %% Click Events
    click Config "https://github.com/watonomous/wato_base_images/blob/main/.github/include/base_image_config.json"
    click Script "https://github.com/watonomous/wato_base_images/blob/main/deploy_arm64.sh"
    click Workflow "https://github.com/watonomous/wato_base_images/blob/main/.github/workflows/build_base_images.yml"
    click ActionDef "https://github.com/watonomous/wato_base_images/blob/main/.github/templates/docker_context/action.yml"
    click ActionLogic "https://github.com/watonomous/wato_base_images/blob/main/.github/templates/docker_context/docker_context.sh"
    click ROS2 "https://github.com/watonomous/wato_base_images/blob/main/inject_ros2.Dockerfile"
    click WATO "https://github.com/watonomous/wato_base_images/blob/main/inject_wato_base.Dockerfile"

    %% Styles
    classDef config fill:#a8f0a8,stroke:#333,stroke-width:1px
    classDef dockerfile fill:#a8d0ff,stroke:#333,stroke-width:1px
    classDef script fill:#fff2a8,stroke:#333,stroke-width:1px
    classDef workflow fill:#ffb07c,stroke:#333,stroke-width:1px
    classDef external fill:#d3d3d3,stroke:#333,stroke-width:1px,stroke-dasharray: 5 5
```
