artifact-editor/Dockerfile

119 lines
3.6 KiB
Docker

# Artifact Editor - AI-enhanced visual artifact creation
#
# Multi-stage build:
# Stage 1: Build CmdForge base
# Stage 2: Build Artifact Editor with CmdForge
#
# Build: docker build -t artifact-editor .
# Run: docker run -it --rm artifact-editor artifact-ai --help
# GUI: See usage examples at bottom
# ==============================================================================
# Stage 1: CmdForge Base
# ==============================================================================
FROM python:3.12-slim AS cmdforge
WORKDIR /cmdforge
ARG CMDFORGE_REPO=https://gitea.brrd.tech/rob/CmdForge.git
RUN apt-get update && apt-get install -y --no-install-recommends git && \
git clone ${CMDFORGE_REPO} . || \
echo "Clone failed - will need COPY in next stage"
RUN pip install --no-cache-dir -e . || true
# ==============================================================================
# Stage 2: Artifact Editor
# ==============================================================================
FROM python:3.12-slim
LABEL maintainer="rob"
LABEL description="Artifact Editor - AI-enhanced diagram and artifact creation"
# Install system dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
git \
curl \
plantuml \
# PyQt6 dependencies (for GUI - optional for CLI use)
libgl1-mesa-glx \
libegl1-mesa \
libxkbcommon0 \
libdbus-1-3 \
libxcb-cursor0 \
libxcb-icccm4 \
libxcb-keysyms1 \
libxcb-shape0 \
libxcb-xinerama0 \
libxcb-randr0 \
libxcb-render-util0 \
# For inkscape/rsvg (SVG to PNG conversion)
librsvg2-bin \
&& rm -rf /var/lib/apt/lists/*
# Install Node.js and mermaid-cli (optional, for Mermaid diagrams)
RUN curl -fsSL https://deb.nodesource.com/setup_20.x | bash - && \
apt-get install -y nodejs && \
npm install -g @mermaid-js/mermaid-cli 2>/dev/null || true && \
rm -rf /var/lib/apt/lists/*
WORKDIR /app
# Copy CmdForge from stage 1
COPY --from=cmdforge /cmdforge /cmdforge
# Install CmdForge
RUN pip install --no-cache-dir -e /cmdforge
# Copy Artifact Editor files
COPY pyproject.toml README.md ./
COPY src/ ./src/
COPY cmdforge/ ./cmdforge/
COPY install.sh ./
# Install Artifact Editor and dependencies
RUN pip install --no-cache-dir -e . && \
pip install --no-cache-dir PyQt6 pygments
# Create directories
RUN mkdir -p /root/.cmdforge /root/.local/bin
# Install artifact CmdForge tools
RUN ./install.sh
# Install CmdForge example tools
RUN python /cmdforge/examples/install.py 2>/dev/null || true && \
cmdforge refresh 2>/dev/null || true
# Add local bin to PATH
ENV PATH="/root/.local/bin:${PATH}"
# Healthcheck - verify CLI tools work
RUN artifact-ai --help && \
artifact-export --help && \
cmdforge list | head -5
# Default: show help
CMD ["artifact-ai", "--help"]
# ==============================================================================
# Usage Examples:
# ==============================================================================
# docker build -t artifact-editor .
#
# CLI (no display required):
# docker run -it --rm artifact-editor artifact-ai --format plantuml --instruction "Create class diagram"
# docker run -it --rm artifact-editor artifact-export --format plantuml --to /tmp/out.svg
# echo "@startuml\nA->B\n@enduml" | docker run -i --rm artifact-editor artifact-export --format plantuml --to /dev/stdout
#
# GUI (requires X11 forwarding):
# xhost +local:docker
# docker run -it --rm \
# -e DISPLAY=$DISPLAY \
# -e QT_QPA_PLATFORM=xcb \
# -v /tmp/.X11-unix:/tmp/.X11-unix \
# artifact-editor artifact-editor
#
# Interactive shell:
# docker run -it --rm artifact-editor bash