# leleobhz/snx-rs-docker architecture

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

- Interactive diagram: https://gitdiagram.com/leleobhz/snx-rs-docker
- Repository: https://github.com/leleobhz/snx-rs-docker

## Overview

##### Project Type and Purpose
- This is a container-based distribution of the “snx-rs” VPN client.
- It provides multi-architecture images (amd64, arm64, armv6) that users can pull from Quay.io and run via Podman.
- The container wraps the snx-rs binary along with required tun device, modules, and scripts.

##### File Structure
- Containerfile, Containerfile.armv6 – Docker/Buildah recipes for standard and armv6 builds.
- Makefile – orchestrates build commands, version retrieval (get_latest_version.sh), and pushes to the registry (get_container_auth.sh).
- get_latest_version.sh/get_container_auth.sh – helper scripts to fetch the upstream snx-rs release and registry credentials.
- README.md – usage instructions, supported architectures, run options, performance notes.

##### README for Insights
- Usage snippet shows how the container is run (privileged, /dev/net/tun, module mounts, PODMAN flags).
- Mentions target hosts (Raspberry Pi 1, amd64) and performance.
- Identifies the container registry (quay.io/pqatsi/snx-rs) and the tags model (latest, per-arch).

a. Build-Time Pipeline
– Developer Repo (GitHub)
– CI/CD Runner (e.g., GitHub Actions / Make)
– Scripts: get_latest_version.sh, get_container_auth.sh
– Build Engine (Podman/Buildah) running Containerfile and Containerfile.armv6
– Multi-arch Image Builder (manifest lists for amd64, arm64, armv6)
– Container Registry (quay.io/pqatsi/snx-rs)
b. Run-Time Environment
– Host OS / Device (x86, Raspberry Pi)
– Container Runtime (Podman)
– Container Instance
- snx-rs binary
- Tun/Tap device (/dev/net/tun)
- Module mount (/lib/modules:ro)
– Local Volume for sessions (/opt/snx/sessions → /var/cache/snx-rs/sessions)
– Network Namespace (–network=host, NET_ADMIN/SYS_ADMIN)
– External VPN Server (IPSec endpoint)

##### Relationships and Data Flows
- Annotation showing privileged capabilities (NET_ADMIN, SYS_ADMIN).

##### Architectural Patterns and Principles
- Single-purpose, immutable container image (one process per container).
- Multi-arch build using separate Containerfiles and a manifest list.
- Minimal base OS layers, runtime isolation via host network namespace.
- Scripts externalize versioning and registry authentication (separation of concerns).

##### Key Technologies and Frameworks
- Podman / Buildah (OCI-compliant builds & runs)
- Containerfile (Dockerfile-compatible)
- Makefile (build orchestration)
- Quay.io (registry)
- Bash scripts for automation
- snx-rs VPN client (Rust binary)

## Diagram (Mermaid)

```mermaid
graph TD
  subgraph "Build-Time Pipeline"
    GH["GitHub Repo"]:::source
    CI["CI/CD Runner"]:::service
    Make["Makefile"]:::script
    Vers["get_latest_version.sh"]:::script
    Auth["get_container_auth.sh"]:::script
    BE["Build Engine (Podman/Buildah)"]:::service
    CF1["Containerfile (amd64)"]:::build
    CF2["Containerfile.armv6"]:::build
    MAB["Multi-arch Image Builder"]:::service
    Reg[(quay.io/pqatsi/snx-rs)]:::registry
    README["README.md"]:::doc

    GH --> CI
    CI --> Make
    Make --> Vers
    Make --> Auth
    Make --> BE
    BE --> CF1
    BE --> CF2
    CF1 --> MAB
    CF2 --> MAB
    MAB --> Reg
    GH --> README
  end

  subgraph "Run-Time Environment"
    Host["Host OS/Device"]:::runtime
    Pod["Podman Runtime"]:::service
    Cont["Container Instance"]:::container
    Bin["snx-rs binary"]:::container
    Tun["/dev/net/tun"]:::device
    Mod["/lib/modules:ro"]:::device
    Vol["/var/cache/snx-rs/sessions"]:::storage
    NS["Network Namespace<br/>(NET_ADMIN, SYS_ADMIN)"]:::annotation
    VPN["External VPN Server"]:::external

    Host --> Pod
    Pod --> Cont
    Cont --> Bin
    Cont --> Tun
    Cont --> Mod
    Cont --> Vol
    Cont --> NS
    Cont -->|"IPSec"| VPN
  end

  classDef source fill:#f9f,stroke:#333,stroke-width:1px
  classDef service fill:#bbf,stroke:#333
  classDef script fill:#bfb,stroke:#333
  classDef build fill:#fbb,stroke:#333
  classDef registry fill:#fbf,stroke:#333,stroke-dasharray:5 5
  classDef doc fill:#ffd,stroke:#333
  classDef runtime fill:#ffb,stroke:#333
  classDef container fill:#bff,stroke:#333
  classDef device fill:#fff,stroke:#333,stroke-dasharray:2 2
  classDef storage fill:#ffd,stroke:#333,stroke-dasharray:4 2
  classDef annotation fill:#eee,stroke:#333,stroke-dasharray:1 1
  classDef external fill:#afa,stroke:#333,stroke-dasharray:5 2

  click CF1 "https://github.com/leleobhz/snx-rs-docker/tree/main/Containerfile"
  click CF2 "https://github.com/leleobhz/snx-rs-docker/blob/main/Containerfile.armv6"
  click Make "https://github.com/leleobhz/snx-rs-docker/tree/main/Makefile"
  click Vers "https://github.com/leleobhz/snx-rs-docker/blob/main/get_latest_version.sh"
  click Auth "https://github.com/leleobhz/snx-rs-docker/blob/main/get_container_auth.sh"
  click README "https://github.com/leleobhz/snx-rs-docker/blob/main/README.md"
```
