# jpetazzo/minimage architecture

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

- Interactive diagram: https://gitdiagram.com/jpetazzo/minimage
- Repository: https://github.com/jpetazzo/minimage

## Overview

##### Main Components

a) Source Code Layer
- Source files by language (C, Go, Python, Rust, Java)
- That these are simple test programs (hello world, whatsmyip)

b) Docker Build System
- Multi-stage build configurations
- Build stages (compilation/preparation)
- Run stages (final image)

c) Image Types Classification
- Base images (Alpine, Ubuntu, Scratch, etc.)
- Language-specific images (golang, openjdk, python, rust)
- Static vs. Dynamic builds

**Layer 1: Source Code**
- Simple Programs
- Hello World (C, Go, Python, Rust, Java)
- WhatsMyIP (Go)
- Python Packages (PyYAML, Data Science)

**Layer 2: Build Configurations**
- Single-stage Builds
- Direct builds (e.g., rust-alpine)
- Multi-stage Builds
- Build Stage
- Compiler/SDK images
- Build options (static, dynamic)
- Run Stage
- Minimal runtime images

**Layer 3: Final Images**
- Full OS-based
- Ubuntu
- Debian
- Minimal OS
- Alpine
- Busybox
- No OS
- Scratch

##### Additional Notes

- Size comparison metrics between different approaches
- Notes about compatibility constraints
- Recommended combinations for each language
- Optimization techniques used in each approach

## Diagram (Mermaid)

```mermaid
graph TB
    %% Styles and classes
    classDef source fill:#e1f5fe,stroke:#01579b
    classDef build fill:#e8f5e9,stroke:#2e7d32
    classDef image fill:#fff3e0,stroke:#e65100
    classDef error fill:#ffebee,stroke:#c62828
    classDef legend fill:#f5f5f5,stroke:#616161

    %% Legend
    subgraph Legend
        L1[Source Files]:::source
        L2[Build Configurations]:::build
        L3[Final Images]:::image
        L4[Error Cases]:::error
    end

    %% Source Code Layer
    subgraph SourceCode
        C[C Source]:::source
        Go[Go Source]:::source
        Python[Python Source]:::source
        Rust[Rust Source]:::source
        Java[Java Source]:::source
    end

    %% Build System Layer
    subgraph BuildSystem
        SingleStage[Single-stage Builds]:::build
        MultiStage[Multi-stage Builds]:::build
    end

    %% Build Configurations
    subgraph BuildConfigs
        CBuild[C Builds]:::build
        GoBuild[Go Builds]:::build
        PythonBuild[Python Builds]:::build
        RustBuild[Rust Builds]:::build
        JavaBuild[Java Builds]:::build
    end

    %% Final Images Layer
    subgraph FinalImages
        Ubuntu[Ubuntu Based]:::image
        Alpine[Alpine Based]:::image
        Scratch[Scratch Based]:::image
    end

    %% Error Cases
    subgraph Errors
        NoWorkdir[Missing Workdir]:::error
        InvalidConfig[Invalid Configurations]:::error
    end

    %% Relationships
    C --> CBuild
    Go --> GoBuild
    Python --> PythonBuild
    Rust --> RustBuild
    Java --> JavaBuild

    CBuild --> |Static| Scratch
    CBuild --> |Dynamic| Alpine
    GoBuild --> |CGO disabled| Scratch
    GoBuild --> |CGO enabled| Alpine
    PythonBuild --> Alpine
    RustBuild --> Scratch
    JavaBuild --> |Native Image| Scratch
    JavaBuild --> |JVM| Alpine
    JavaBuild --> |Full JDK| Ubuntu

    %% Click events
    click C "https://github.com/jpetazzo/minimage/blob/master/hello.c"
    click Go "https://github.com/jpetazzo/minimage/blob/master/hello.go"
    click Python "https://github.com/jpetazzo/minimage/blob/master/hello.py"
    click Rust "https://github.com/jpetazzo/minimage/blob/master/hello.rs"
    click Java "https://github.com/jpetazzo/minimage/blob/master/hello.java"
    click CBuild "https://github.com/jpetazzo/minimage/blob/master/Dockerfile.hello-c.gcc*"
    click GoBuild "https://github.com/jpetazzo/minimage/blob/master/Dockerfile.hello-go.*"
    click PythonBuild "https://github.com/jpetazzo/minimage/blob/master/Dockerfile.hello-py.*"
    click RustBuild "https://github.com/jpetazzo/minimage/blob/master/Dockerfile.hello-rust.*"
    click JavaBuild "https://github.com/jpetazzo/minimage/blob/master/Dockerfile.hello-java.*"
    click NoWorkdir "https://github.com/jpetazzo/minimage/blob/master/Dockerfile.hello-go.golang.ubuntu-noworkdir.err"
    click InvalidConfig "https://github.com/jpetazzo/minimage/blob/master/docker-compose.err.yaml"
```
