# rajeshseenu/llm-acr-bootstrap architecture

> Architecture diagram of the GitHub repository rajeshseenu/llm-acr-bootstrap, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-08-15). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/rajeshseenu/llm-acr-bootstrap
- Repository: https://github.com/rajeshseenu/llm-acr-bootstrap

## Overview

#### Purpose and Entry Point

This repository is a run-once shell pipeline for packaging a Hugging Face model into a Docker image suitable for vLLM, then pushing it to Azure Container Registry (ACR). The executable entry point is `bootstrap.sh`; image construction is defined by `Dockerfile`.

#### Bootstrap Orchestration

`bootstrap.sh` drives the lifecycle: creates a temporary checkout, ensures Docker is available, collects model/registry/auth inputs interactively, builds, pushes, and removes local artifacts. It is intended to be invoked either directly from a checkout or streamed through `curl | bash`.

Paths: `bootstrap.sh`, `README.md`.

#### Authentication and Secret Boundary

The script supports two ACR authentication boundaries:
- Azure CLI device-code authentication (`az login --use-device-code`), avoiding password entry.
- Docker registry login with credentials supplied through stdin.

The Hugging Face access token remains in a shell variable and is injected into the build only as a BuildKit secret. It must not be persisted in the temporary checkout, Docker layers, command-line arguments, or shell history.

Paths: `bootstrap.sh`, `Dockerfile`.

#### Container Build Pipeline

`Dockerfile` is a multi-stage build. Its fetch stage downloads model artifacts from Hugging Face, with the token available only through a secret mount at `/run/secrets/hf_token`. A later runtime stage packages the fetched weights into the serving image, targeting vLLM consumption. This stage separation prevents credentials from reaching the final image.

Paths: `Dockerfile`.

#### Artifact Publishing Flow

The primary flow is:

1. User provides Hugging Face model identifier and optional token.
2. User provides ACR login server and target image name/tag.
3. `bootstrap.sh` invokes a BuildKit-enabled Docker build using `Dockerfile`.
4. Docker pushes the resulting image to the specified ACR repository.
5. The local image and build cache are removed after completion.

External endpoints include Hugging Face (`huggingface.co`), Docker Hub for base images, and the target Azure Container Registry.

Paths: `bootstrap.sh`, `Dockerfile`.

#### Cleanup and Failure Handling

Cleanup is an architectural guarantee rather than a best-effort post-step. `bootstrap.sh` registers `trap cleanup EXIT INT TERM`, so normal exit, failure, interruption, and termination trigger registry logout, removal of local image/build cache, temporary-checkout deletion, and credential-variable unsetting. Docker itself may remain installed because it is treated as a system dependency.

Paths: `bootstrap.sh`.

#### Runtime and Deployment Model

The produced artifact is a Docker image containing model weights for vLLM-oriented serving; this repository does not implement the serving application or deploy it. Azure Container Registry is the publication target, while downstream infrastructure is expected to pull and run the image. The build can be adapted for LoRA-only images by changing the fetch/final-copy relationship so base model weights reside in a separate image.

Paths: `Dockerfile`, `README.md`.

Main entry points: [`bootstrap.sh`](https://github.com/rajeshseenu/llm-acr-bootstrap/blob/main/bootstrap.sh) (Bootstrap Pipeline), [`Dockerfile`](https://github.com/rajeshseenu/llm-acr-bootstrap/blob/main/Dockerfile) (Model Fetch Stage), [`README.md`](https://github.com/rajeshseenu/llm-acr-bootstrap/blob/main/README.md) (Usage Guide)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_orchestration["Bootstrap Orchestration"]
  node_readme["Usage Guide<br/>documentation<br/>[README.md]"]
  node_bootstrap["Bootstrap Pipeline<br/>shell entry point<br/>[bootstrap.sh]"]
  node_temp_checkout["Temporary Checkout<br/>workspace"]
  node_docker_daemon{{"Docker with BuildKit<br/>build runtime"}}
  node_azure_cli["Azure CLI Device Login<br/>authentication"]
  node_docker_login["Docker Registry Login<br/>authentication"]
  node_cleanup["Trap Cleanup<br/>lifecycle guard<br/>[bootstrap.sh]"]
end

subgraph group_build["Container Build"]
  node_dockerfile["Multi-stage Recipe<br/>Dockerfile"]
  node_fetch_stage["Model Fetch Stage<br/>build stage"]
  node_runtime_stage["vLLM Runtime Image<br/>build stage"]
end

subgraph group_external["External Services"]
  node_hf[("Hugging Face<br/>model source")]
  node_docker_hub[("Docker Hub<br/>base image registry")]
  node_acr[("Azure Container Registry<br/>image registry")]
  node_downstream{{"Downstream Serving<br/>deployment consumer"}}
end

node_user(("Operator<br/>user"))

node_user -->|"reads"| node_readme
node_user -->|"runs; supplies model and target"| node_bootstrap
node_bootstrap -->|"creates"| node_temp_checkout
node_bootstrap -->|"ensures and invokes"| node_docker_daemon
node_bootstrap -.->|"optional auth"| node_azure_cli
node_bootstrap -->|"registry auth"| node_docker_login
node_azure_cli -->|"authenticates to"| node_acr
node_docker_login -->|"authenticates to"| node_acr
node_docker_daemon -->|"builds from"| node_dockerfile
node_dockerfile -->|"defines"| node_fetch_stage
node_dockerfile -->|"defines"| node_runtime_stage
node_fetch_stage -->|"downloads model; secret token mount"| node_hf
node_fetch_stage -->|"copies fetched weights"| node_runtime_stage
node_docker_hub -->|"provides base image"| node_fetch_stage
node_docker_hub -->|"provides base image"| node_runtime_stage
node_runtime_stage -->|"pushes tagged image"| node_acr
node_acr -->|"image is pulled by"| node_downstream
node_bootstrap -->|"registers EXIT/INT/TERM trap"| node_cleanup
node_cleanup -->|"deletes"| node_temp_checkout
node_cleanup -->|"removes local image and cache"| node_docker_daemon
node_cleanup -->|"logs out"| node_acr

click node_readme "https://github.com/rajeshseenu/llm-acr-bootstrap/blob/main/README.md"
click node_bootstrap "https://github.com/rajeshseenu/llm-acr-bootstrap/blob/main/bootstrap.sh"
click node_dockerfile "https://github.com/rajeshseenu/llm-acr-bootstrap/blob/main/Dockerfile"
click node_fetch_stage "https://github.com/rajeshseenu/llm-acr-bootstrap/blob/main/Dockerfile"
click node_runtime_stage "https://github.com/rajeshseenu/llm-acr-bootstrap/blob/main/Dockerfile"
click node_cleanup "https://github.com/rajeshseenu/llm-acr-bootstrap/blob/main/bootstrap.sh"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_readme,node_bootstrap,node_temp_checkout,node_docker_daemon,node_azure_cli,node_docker_login,node_cleanup toneBlue
class node_dockerfile,node_fetch_stage,node_runtime_stage toneAmber
class node_hf,node_docker_hub,node_acr,node_downstream toneMint
class node_user toneNeutral
```

## Components

### Bootstrap Orchestration

- [Usage Guide](https://github.com/rajeshseenu/llm-acr-bootstrap/blob/main/README.md): documentation · `README.md`
- [Bootstrap Pipeline](https://github.com/rajeshseenu/llm-acr-bootstrap/blob/main/bootstrap.sh): shell entry point · Run-once build, publish, and cleanup orchestrator. · `bootstrap.sh`
- **Temporary Checkout**: workspace · Ephemeral working directory removed by cleanup.
- **Docker with BuildKit**: build runtime
- **Azure CLI Device Login**: authentication · Optional device-code ACR authentication path.
- **Docker Registry Login**: authentication · Credentials are provided through stdin.
- [Trap Cleanup](https://github.com/rajeshseenu/llm-acr-bootstrap/blob/main/bootstrap.sh): lifecycle guard · Runs on exit, failure, interruption, or termination. · `bootstrap.sh`

### Container Build

- [Multi-stage Recipe](https://github.com/rajeshseenu/llm-acr-bootstrap/blob/main/Dockerfile): Dockerfile · `Dockerfile`
- [Model Fetch Stage](https://github.com/rajeshseenu/llm-acr-bootstrap/blob/main/Dockerfile): build stage · Downloads model artifacts with a BuildKit secret mount. · `Dockerfile`
- [vLLM Runtime Image](https://github.com/rajeshseenu/llm-acr-bootstrap/blob/main/Dockerfile): build stage · Packages fetched weights without the Hugging Face token. · `Dockerfile`

### External Services

- **Hugging Face**: model source
- **Docker Hub**: base image registry
- **Azure Container Registry**: image registry · Publication target for the built image.
- **Downstream Serving**: deployment consumer · External infrastructure pulls and runs the vLLM-oriented image.

### Other components

- **Operator**: user

## Connections

- Operator → Usage Guide: reads
- Operator → Bootstrap Pipeline: runs; supplies model and target
- Bootstrap Pipeline → Temporary Checkout: creates
- Bootstrap Pipeline → Docker with BuildKit: ensures and invokes
- Bootstrap Pipeline → Azure CLI Device Login: optional auth
- Bootstrap Pipeline → Docker Registry Login: registry auth
- Azure CLI Device Login → Azure Container Registry: authenticates to
- Docker Registry Login → Azure Container Registry: authenticates to
- Docker with BuildKit → Multi-stage Recipe: builds from
- Multi-stage Recipe → Model Fetch Stage: defines
- Multi-stage Recipe → vLLM Runtime Image: defines
- Model Fetch Stage → Hugging Face: downloads model; secret token mount
- Model Fetch Stage → vLLM Runtime Image: copies fetched weights
- Docker Hub → Model Fetch Stage: provides base image
- Docker Hub → vLLM Runtime Image: provides base image
- vLLM Runtime Image → Azure Container Registry: pushes tagged image
- Azure Container Registry → Downstream Serving: image is pulled by
- Bootstrap Pipeline → Trap Cleanup: registers EXIT/INT/TERM trap
- Trap Cleanup → Temporary Checkout: deletes
- Trap Cleanup → Docker with BuildKit: removes local image and cache
- Trap Cleanup → Azure Container Registry: logs out
