dock2tauri

Dock2Tauri Architecture

This document provides a high-level overview of Dock2Tauri’s architecture, components, and data flow.

Overview

Dock2Tauri is a bridge that transforms Docker containers into native desktop applications using Tauri. It consists of multiple launcher interfaces, a Tauri desktop application, and supporting infrastructure.

┌─────────────────┐    ┌──────────────────┐    ┌─────────────────┐
│   User Input    │    │    Launchers     │    │  Tauri Desktop  │
│                 │    │                  │    │   Application   │
│ • Docker Image  │───▶│ • Bash Script    │───▶│                 │
│ • Dockerfile    │    │ • Python CLI     │    │ • WebView       │
│ • Host/Cont Port│    │ • Node.js Script │    │ • Container     │
│ • Build Flags   │    │ • Makefile       │    │   Proxy/Bridge  │
└─────────────────┘    └──────────────────┘    └─────────────────┘
                                │                        │
                                ▼                        ▼
                       ┌──────────────────┐    ┌─────────────────┐
                       │ Docker Container │    │  Native Bundle  │
                       │                  │    │                 │
                       │ • Web App/Service│    │ • .deb, .rpm    │
                       │ • Port Mapping   │    │ • .AppImage     │
                       │ • Auto-restart   │    │ • .msi, .dmg    │
                       └──────────────────┘    └─────────────────┘

Components

1. Launchers (Frontend Interface)

Multiple entry points providing unified CLI across different environments:

Bash Script (scripts/dock2tauri.sh)

Python CLI (scripts/dock2tauri.py + taurido package)

Node.js Script (scripts/dock2tauri.js)

Makefile Targets

2. Configuration System

Ephemeral Tauri Config

Environment Variables

Custom Build Paths System (v1.0.x+)

Advanced Configuration Architecture providing complete flexibility for build workflows:

┌─────────────────┐    ┌──────────────────────┐    ┌─────────────────┐
│  CLI Arguments  │───▶│  Argument Processor   │───▶│  Build System   │
│                 │    │                      │    │                 │
│ --output-dir=   │    │ • parse_custom_opts() │    │ • EXPORT_DIR    │
│ --app-name=     │    │ • FILTERED_ARGS       │    │ • tauri config  │
│ --filename=     │    │ • Environment sync    │    │ • Bundle naming │
│ --copy-to=      │    │ • Path resolution     │    │ • Multi-copy    │
└─────────────────┘    └──────────────────────┘    └─────────────────┘

Configuration Flow:

  1. Environment Loading (.env → defaults)
  2. CLI Argument Parsing (custom options extraction)
  3. Configuration Merge (CLI overrides environment)
  4. Path Resolution (absolute/relative path handling)
  5. Tauri Config Generation (dynamic productName injection)
  6. Build Execution (custom paths applied)
  7. Multi-Location Distribution (optional copying)

Key Features:

3. Tauri Desktop Application

Core Architecture

┌─────────────────────────────────────────────────────────┐
│                    Tauri App                            │
│  ┌─────────────────┐  ┌─────────────────────────────────┐ │
│  │     Frontend    │  │           Backend              │ │
│  │                 │  │                                │ │
│  │ • HTML/CSS/JS   │  │ • Rust Core                    │ │
│  │ • WebView       │◄─┤ • Docker Integration          │ │
│  │ • Control Panel │  │ • Container Management        │ │
│  │                 │  │ • Bundle Generation           │ │
│  └─────────────────┘  └─────────────────────────────────┘ │
│                                     │                    │
└─────────────────────────────────────┼────────────────────┘
                                      │
                                      ▼
                           ┌─────────────────┐
                           │ Docker Daemon   │
                           │                 │
                           │ • Container     │
                           │   Lifecycle     │
                           │ • Port Mapping  │
                           │ • Health Checks │
                           └─────────────────┘

Frontend (app/)

Backend (src-tauri/)

4. Build and Packaging System

Bundle Generation Pipeline

Source → Docker Build → Tauri Config → Native Compile → Bundle Creation
   │           │              │              │              │
   ▼           ▼              ▼              ▼              ▼
Dockerfile  Container     temp.json       Binary      .deb/.rpm/etc
   │        Ready         Generated       Compiled       Generated
   │           │              │              │              │
   └───────────┴──────────────┴──────────────┴──────────────┘
                               │
                               ▼ (Export to dist/)
                    ┌─────────────────────────────┐
                    │     Platform Folders       │
                    │                             │
                    │ • dist/linux-x64/          │
                    │ • dist/linux-arm64/        │
                    │ • dist/windows-x64/        │
                    │ • dist/macos-x64/          │
                    │ • dist/macos-arm64/        │
                    │ • dist/android-apk/        │
                    └─────────────────────────────┘

Cross-Compilation Intelligence

5. Docker Integration

Container Lifecycle Management

  1. Image Resolution: Handle both images and Dockerfiles
  2. Build Process: Local Dockerfile builds with context
  3. Container Launch: Port mapping, networking, restart policies
  4. Health Monitoring: Readiness checks with configurable timeouts
  5. Cleanup: Automatic container removal on app exit

Network Architecture

Desktop App (Tauri)    Host System         Docker Container
       │                    │                      │
       │ ┌─────────────────┐ │ ┌─────────────────┐  │
       └─┤   WebView       ├─┼─┤   Port Forward  ├──┘
         │ localhost:HOST  │ │ │ HOST:CONTAINER  │
         └─────────────────┘ │ └─────────────────┘
                             │
                             │ ┌─────────────────┐
                             └─┤ Docker Daemon   │
                               └─────────────────┘

Data Flow

Development Mode (cargo tauri dev)

  1. Configuration: Generate ephemeral tauri.conf.json with devUrl
  2. Container Start: Launch Docker container with port mapping
  3. Health Check: Wait for service readiness
  4. Tauri Launch: Start development server with WebView pointing to container
  5. Live Development: Hot reload and debugging capabilities

Production Build (--build)

  1. Multi-target Detection: Scan for installed Rust targets and toolchains
  2. Bundle Generation: Create native packages per platform
  3. Export Organization: Copy artifacts to dist/<platform>/ with README
  4. Cross-compilation: Attempt feasible targets based on available tools
  5. Final Artifacts: Ready-to-distribute native applications

Configuration Flow

CLI Args → Environment Variables → Default Values
    │              │                    │
    ▼              ▼                    ▼
┌─────────────────────────────────────────────┐
│          Unified Configuration             │
│                                            │
│ • Docker image/Dockerfile                  │
│ • Host/Container ports                     │
│ • Build targets and flags                  │
│ • Health check configuration              │
│ • Bundler preferences                      │
└─────────────────────────────────────────────┘
                     │
                     ▼
            ┌─────────────────┐
            │ Tauri Config    │
            │ Generator       │
            └─────────────────┘
                     │
                     ▼
            ┌─────────────────┐
            │  temp.json      │
            │ (ephemeral)     │
            └─────────────────┘

Extension Points

Adding New Launchers

  1. Implement unified CLI interface
  2. Generate compatible Tauri configuration
  3. Handle container lifecycle (start, stop, cleanup)
  4. Support Dockerfile and image inputs
  5. Maintain feature parity with existing launchers

Custom Bundlers

  1. Extend generate_tauri_config_json() in launchers
  2. Add bundler detection logic
  3. Update platform mapping in map_target_to_platform()
  4. Ensure cleanup and error handling

Cross-compilation Targets

  1. Add target to CANDIDATE_TARGETS array
  2. Implement toolchain detection in can_cross_compile_target()
  3. Update platform mapping
  4. Document required dependencies

Security Considerations

Container Isolation

Network Security

Build Security

Performance Characteristics

Build Times

Resource Usage

Optimization Opportunities