# renjiangyang/docker_image_pusher architecture

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

- Interactive diagram: https://gitdiagram.com/renjiangyang/docker_image_pusher
- Repository: https://github.com/renjiangyang/docker_image_pusher

## Overview

##### Project type and purpose
- This is a GitHub-Action-based automation tool (“Docker Images Pusher”) that mirrors any public Docker image (from DockerHub, gcr.io, k8s.io, ghcr.io, etc.) into an Alibaba Cloud Container Registry namespace.
- Its purpose is to let teams in China or behind network filters pull large container images quickly from a private Aliyun mirror, controlled by a simple “images.txt” list and driven entirely by GitHub Actions.

##### File structure
- Top-level files:
- README.md – explains usage, configuration, secrets.
- images.txt – the only user-editable list of source images (with optional tags and --platform flags).
- .github/workflows/docker.yaml – the CI/CD pipeline definition.
- No code libraries or backends; the “engine” is entirely the GitHub Actions workflow script using Docker CLI commands and buildx.

##### README for additional insights
- Key sections: configuration of Aliyun namespace, secrets (ALIYUN_NAME_SPACE, ALIYUN_REGISTRY_USER, ALIYUN_REGISTRY_PASSWORD, ALIYUN_REGISTRY), adding images to images.txt, optional scheduling via cron in docker.yaml.
- The workflow supports multi-arch via `--platform`, handles duplicate names by prefixing with source namespace, and can be triggered on push or on a schedule.

a. Main components
- GitHub Repository (contains images.txt + .github/workflows/docker.yaml)
- GitHub Actions Runner (hosted by GitHub)
- Source Registries (DockerHub, gcr.io, k8s.io, ghcr.io, etc.)
- Aliyun Container Registry (private mirror)
- GitHub Secrets (stores ALIYUN_* environment variables)
b. Relationships and interactions
1. Developer pushes updates to images.txt or modifies the workflow → GitHub
2. GitHub triggers the Action (on push or schedule) → Runner spins up
3. Runner reads secrets from GitHub Secrets
4. Runner reads images.txt line by line → For each image:
- Docker CLI pulls from Source Registry
- (Optional) buildx multi-arch logic
- Docker CLI pushes to Aliyun Registry using the configured namespace and credentials
5. Aliyun Registry stores mirrored images for downstream consumption
c. Architectural patterns and design principles
- “Configuration-as-code”: images.txt drives the list of mirrors.
- “Infrastructure as code” pipeline (GitHub Actions) with secrets injection.
- Stateless, ephemeral build runners – no servers to manage.
- Idempotent design: re-running the workflow only mirrors missing or updated tags.
d. Technologies, frameworks, and libraries
- GitHub Actions (workflow orchestration)
- Docker CLI & Docker buildx (image pull/build/push)
- GitHub Secrets for secure credential storage
- Alibaba Cloud Container Registry (mirror endpoint)
- Optional cron scheduling inside docker.yaml

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Swimlanes
    subgraph "Configuration" 
        direction TB
        Repo["GitHub Repository"]:::code
        README["README.md"]:::code
        ImagesTxt["images.txt"]:::code
        Workflow[".github/workflows/docker.yaml"]:::code
        Doc["doc/"]:::code
    end

    subgraph "Execution" 
        direction TB
        Runner["GitHub Actions Runner"]:::runner
        Secrets["GitHub Secrets"]:::runner
    end

    subgraph "External Services" 
        direction TB
        Sources["Source Registries<br/>(DockerHub, gcr.io, k8s.io, ghcr.io)"]:::external
        Aliyun["Alibaba Cloud Container Registry"]:::external
    end

    %% Connections
    Developer["Developer"]:::external
    Developer -->|"push"| Repo
    Repo -->|"trigger (push or cron)"| Runner
    Runner -->|"read"| ImagesTxt
    Runner -->|"read"| Secrets
    Runner -->|"pull image"| Sources
    Runner -->|"push image"| Aliyun

    %% Click events
    click Repo "https://github.com/renjiangyang/docker_image_pusher/blob/main/README.md"
    click README "https://github.com/renjiangyang/docker_image_pusher/blob/main/README.md"
    click ImagesTxt "https://github.com/renjiangyang/docker_image_pusher/blob/main/images.txt"
    click Workflow "https://github.com/renjiangyang/docker_image_pusher/blob/main/.github/workflows/docker.yaml"
    click Doc "https://github.com/renjiangyang/docker_image_pusher/tree/main/doc/"

    %% Styles
    classDef code fill:#D6EFFF,stroke:#0366d6;
    classDef runner fill:#E6FFDD,stroke:#3C9A4B;
    classDef external fill:#FFF4CE,stroke:#D69E2E;
```
