The Nextlevel Blog logo
  • About 
  • Research 
  • Tags 
  • Blog 
  1.   Blog
  1. Home
  2. Blog
  3. Dockerizing Fabric - A Comprehensive AI Augmentation Setup

Dockerizing Fabric - A Comprehensive AI Augmentation Setup

Posted on February 6, 2025 • 5 min read • 991 words
Ai   Docker   Selfhosted  
Ai   Docker   Selfhosted  
Share via
The Nextlevel Blog
Link copied to clipboard

On this page
Motivation   Dockerfile Breakdown   Docker Compose Configuration   Deployment Workflow   Environment Configuration   Usage Example  
Dockerizing Fabric - A Comprehensive AI Augmentation Setup

Fabric is an open-source AI framework by Daniel Miessler that enables granular AI integration into daily workflows through CLI commands, patterns, and customizable prompts[1][4]. This guide demonstrates how to containerize Fabric with Docker for simplified deployment.

Motivation  

As AI technologies continue to evolve, developers and businesses seek efficient ways to deploy and manage AI solutions. Dockerizing Fabric offers a scalable, consistent, and flexible approach to AI augmentation, enabling users to harness powerful AI capabilities while maintaining control over their infrastructure. By containerizing Fabric, we aim to simplify deployment, reduce compatibility issues, and promote best practices for AI implementation in diverse environments.

Docker is an open-source platform used to automate the deployment, scaling, and management of applications in lightweight, portable containers. Containers package an application with all its dependencies and runtime environment, ensuring consistency across different computing environments. This makes it easier to develop, ship, and run applications anywhere, improving the overall efficiency of the software development lifecycle.

Dockerfile Breakdown  

# Base image with Go for Fabric CLI
FROM golang:latest

# Install Fabric core
RUN go install github.com/danielmiessler/fabric@latest

# Configuration and web UI setup
RUN mkdir -p ~/.config/fabric && \
    mkdir /web && cd /web && \
    git clone https://github.com/danielmiessler/fabric.git /web

# Dependency installation
RUN apt-get update && apt-get upgrade -y && \
    apt-get install -y npm

# Web UI configuration
RUN cd /web/web && npm install
COPY start.sh /start.sh
RUN chmod +x /start.sh && \
    sed -i -se 's/vite dev/vite dev --host/g' /web/web/package.json

CMD ["/start.sh"]
#!/bin/sh
fabric --serve &  # Background process
cd /web/web
exec npm run dev # Foreground process (replaces the shell to retain PID 1)

This Dockerfile outlines the setup for a Docker container designed to run a web application using the Fabric CLI tool and a web interface. Here’s a step-by-step breakdown of the file:

  1. Base Image:

    FROM golang:latest
    • The container uses the official Golang image as its base, specifically the latest version. This image includes the Go programming language environment, which is necessary for building and running Go applications.
  2. Install Fabric Core:

    RUN go install github.com/danielmiessler/fabric@latest
    • This step installs the Fabric CLI tool from its GitHub repository using Go’s installation process. The Fabric tool is managed by danielmiessler, and it’s being installed at its latest version.
  3. Configuration and Web UI Setup:

    RUN mkdir -p ~/.config/fabric && \
        mkdir /web && cd /web && \
        git clone https://github.com/danielmiessler/fabric.git /web
    • Creates a configuration directory for fabric at ~/.config/fabric.
    • Sets up a directory /web for the web application and clones the Fabric repository into it. This likely contains the web UI or related resources.
  4. Dependency Installation:

    RUN apt-get update && apt-get upgrade -y && \
        apt-get install -y npm
    • Updates the package list and upgrades installed packages on the container.
    • Installs npm, which is necessary for managing Node.js packages used in the web UI.
  5. Web UI Configuration:

    RUN cd /web/web && npm install
    COPY start.sh /start.sh
    RUN chmod +x /start.sh && \
        sed -i -se 's/vite dev/vite dev --host/g' /web/web/package.json
    • Changes directory to /web/web and installs Node.js dependencies specified in package.json using npm.
    • Copies a shell script start.sh from the context into the container for starting the application.
    • Makes the start.sh script executable.
    • Modifies package.json, specifically altering the script vite dev to vite dev --host. This allows the Vite development server to accept connections from any network interface, which is often necessary for accessing the server from outside the container.
  6. Default Command:

    CMD ["/start.sh"]
    • Sets the default command to run the start.sh script when the container starts.

start.sh Script:

#!/bin/sh
fabric --serve &  # Background process
cd /web/web
exec npm run dev  # Foreground process (replaces the shell to retain PID 1)
  • The script uses the Fabric CLI tool to start serving the Fabric API in the background (fabric --serve &).
  • It then changes the working directory to /web/web and runs npm run dev. The use of exec in the script replaces the current shell with the Vite process, ensuring it runs as PID 1, which is important for proper signal handling (like termination signals) inside a Docker container.

In summary, this Dockerfile sets up a development environment with Go and Node.js to run a specific web application using the Fabric CLI tool. The container exposes a development server that can be accessed externally.

Docker Compose Configuration  

services:
  fabric:
    build: ./fabric
    restart: unless-stopped
    ports:
      - 5173:5173
    volumes:
      - ./config:/root/.config/fabric

Features:

  • Persistent config storage for API keys and patterns
  • Automatic restart policy for reliability
  • Port mapping for web UI access

Deployment Workflow  

1. Build and Push to Docker Hub

# Build image
docker build -t coolmast/fabric .

# Tag and push
docker tag coolmast/fabric:latest coolmast/fabric:v1.0
docker push coolmast/fabric:latest
docker push coolmast/fabric:v1.0

2. GitHub Repository Setup

# Initialize repo
git init
git add .
git commit -m "Initial Fabric Docker setup"

# Connect to remote
git remote add origin https://github.com/coolmast/docker-fabric-web.git
git push -u origin main

Repository should contain:

├── fabric/
│   ├── Dockerfile
│   └── start.sh
├── config/
│   └── .env
└── docker-compose.yml

Environment Configuration  

DEFAULT_VENDOR=OpenAI
DEFAULT_MODEL=chatgpt-4o-latest
PATTERNS_LOADER_GIT_REPO_URL=https://github.com/danielmiessler/fabric.git
OPENAI_API_KEY=your_api_key_here

Security best practices:

  • Use Docker secrets for API keys in production
  • Maintain separate configs for dev/prod environments

Usage Example  

# Start container
docker-compose up -d

# Execute Fabric command
docker exec -it fabric_container fabric -p extract_wisdom -i input.txt

This setup combines Fabric’s core AI capabilities[1][4] with Docker’s portability, enabling:

  • Pattern management: Custom patterns via mounted configs[6]
  • Scalability: Easily deploy multiple instances

The complete implementation is available at:

  • Docker Hub: coolmast/fabric
  • GitHub: docker-fabric-web

For advanced usage, consider adding:

  • Multi-architecture builds with docker buildx
  • Kubernetes manifests for cluster deployment
  • Automated testing for pattern validation[16]

This structure provides technical depth while maintaining readability, using your actual code samples and deployment targets. The citations reference Fabric’s core functionality from the provided sources while focusing on your specific implementation.

Citations: [1] https://www.infralovers.com/blog/2024-06-25-fabric-overview/ [2] https://www.youtube.com/watch?v=v-gRAgry5Vk [3] https://github.com/danielmiessler/fabric/tree/main [4] https://danielmiessler.com/blog/fabric-origin-story [5] https://www.youtube.com/watch?v=I1r6oVc-RZQ [6] https://github.com/danielmiessler/fabric/blob/main/system.md [7] https://www.linkedin.com/posts/danielmiessler_github-danielmiesslerfabric-fabric-is-activity-7159181666731675649-OuCH [8] https://github.com/danielmiessler/fabric/activity [9] https://x.com/danielmiessler?lang=de [10] https://newsletter.danielmiessler.com/p/ul-421 [11] https://www.linkedin.com/posts/paul-filby-460485_github-danielmiesslerfabric-fabric-is-activity-7287167842595008513-ZVhw [12] https://thedispatch.ai/reports/2713/ [13] https://thedispatch.ai/reports/1592/ [14] https://github.com/danielmiessler/fabric/blob/main/patterns/extract_wisdom/system.md [15] https://www.youtube.com/watch?v=mAhYTjSpN1g [16] https://danielmiessler.com/blog/ai-is-mostly-prompting [17] https://www.linkedin.com/posts/frederick-ros_github-danielmiesslerfabric-fabric-is-activity-7239015130775064576-Jzci [18] https://www.pinterest.com/pin/70228075433949870/ [19] https://www.youtube.com/watch?v=7ftiQ8dVvO4


 How I Moved My Synology DS920+ VM to an External SSD (And Survived to Tell the Tale)
Hosting Matomo with Docker Compose: A Step-by-Step Guide 
On this page:
Motivation   Dockerfile Breakdown   Docker Compose Configuration   Deployment Workflow   Environment Configuration   Usage Example  
Nextlevel v/Peter Schneider

I work on everything cyber security and development, CVR: 42051993, mail: info@nextlevel-blog.de, phone: 60 59 76 35

Copyright © 2025 Peter Schneider. | Powered by Hinode.
The Nextlevel Blog
Code copied to clipboard