# docker/build-push-action architecture

> Architecture diagram of the GitHub repository docker/build-push-action, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-01-15). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/docker/build-push-action
- Repository: https://github.com/docker/build-push-action

## Overview

##### Main Components Identification

a. Core Action Components:
- Main Action Runtime
- Context Handler (Git/Path)
- BuildKit Integration
- Registry Interface
- State Management

b. External Systems:
- Docker Registry (Docker Hub/others)
- GitHub Actions Runtime
- BuildKit Builder
- QEMU (for multi-platform builds)
- Git Repository

- GitHub Actions Runtime                                  |

- ↓

- Build-Push-Action Components                               |

- Context      |  | Build          |  | Authentication |  | Output              |      |
- Handler      |  | Orchestrator   |  | Manager        |  | Manager             |      |

- Cache        |  | Platform       |  | Secret         |                              |
- Manager      |  | Manager        |  | Handler        |                              |

- ↓

- External Services                                       |

- Docker       |  | BuildKit       |  | QEMU          |  | Git                  |      |
- Registry     |  | Builder        |  | Emulation     |  | Repository           |      |

##### Component Relationships
Following key interactions:
- Context Handler → Git Repository (for Git context)
- Build Orchestrator → BuildKit Builder
- Authentication Manager → Docker Registry
- Platform Manager → QEMU Emulation
- Cache Manager → Registry/Local Storage
- Output Manager → Docker Registry

##### Important Elements

a. Input Processing:
- Context selection (Git/Path)
- Build arguments
- Platform configurations
- Cache settings
- Secret management

b. Build Process:
- BuildKit integration
- Multi-platform support
- Cache management
- Output handling

c. Output Handling:
- Registry push
- Local load
- Build summaries
- Metadata generation

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph GH["GitHub Actions Runtime"]
        GHAR["Action Runtime"]:::runtime
        GHCI["CI/CD Pipeline"]:::ci
    end

    subgraph BA["Build-Push-Action Components"]
        MAR["Main Action Runtime"]:::core
        CH["Context Handler"]:::core
        BO["Build Orchestrator"]:::core
        AM["Authentication Manager"]:::security
        OM["Output Manager"]:::core
        CM["Cache Manager"]:::core
        PM["Platform Manager"]:::core
        SH["Secret Handler"]:::security
        SM["State Management"]:::core
    end

    subgraph EX["External Services"]
        DR["Docker Registry"]:::external
        BB["BuildKit Builder"]:::external
        QE["QEMU Emulation"]:::external
        GR["Git Repository"]:::external
    end

    subgraph TS["Test & Support"]
        RIT["Registry Interface Tests"]:::test
        BCT["Build Configuration Tests"]:::test
        MC["Mock Components"]:::test
        BC["Build Configuration"]:::config
    end

    %% Core Relationships
    GHAR --> MAR
    MAR --> CH
    CH --> GR
    MAR --> BO
    BO --> BB
    AM --> DR
    PM --> QE
    CM --> DR
    OM --> DR
    SH --> AM
    SM --> BO

    %% Test Relationships
    RIT -.-> DR
    BCT -.-> BB
    MC -.-> GHAR
    BC -.-> BO
    GHCI -.-> MAR

    %% Styling
    classDef core fill:#3498db,stroke:#2980b9,color:white
    classDef security fill:#e67e22,stroke:#d35400,color:white
    classDef external fill:#2ecc71,stroke:#27ae60,color:white
    classDef test fill:#95a5a6,stroke:#7f8c8d,color:white
    classDef runtime fill:#9b59b6,stroke:#8e44ad,color:white
    classDef ci fill:#34495e,stroke:#2c3e50,color:white
    classDef config fill:#f1c40f,stroke:#f39c12,color:black

    %% Click Events
    click MAR "https://github.com/docker/build-push-action/blob/master/src/main.ts"
    click CH "https://github.com/docker/build-push-action/blob/master/src/context.ts"
    click SM "https://github.com/docker/build-push-action/blob/master/src/state-helper.ts"
    click RIT "https://github.com/docker/build-push-action/tree/master/.github/e2e/distribution/"
    click BCT "https://github.com/docker/build-push-action/blob/master/test/multi.Dockerfile"
    click GHCI "https://github.com/docker/build-push-action/blob/master/.github/workflows/ci.yml"
    click MC "https://github.com/docker/build-push-action/blob/master/__mocks__/@actions/github.ts"
    click BC "https://github.com/docker/build-push-action/blob/master/docker-bake.hcl"

    %% Legend
    subgraph Legend
        L1["Core Component"]:::core
        L2["Security Component"]:::security
        L3["External Service"]:::external
        L4["Test Component"]:::test
        L5["Runtime"]:::runtime
        L6["CI/CD"]:::ci
        L7["Configuration"]:::config
    end
```
