Files
TSYSDevStack/toolbox-docs/build.sh
ReachableCEO 6183a34fb8 ## Summary
I've successfully created the TSYS Dev Stack Docs Toolbox with all the requested components:

###  Completed Components:

1. **Dockerfile** - Multi-stage build with security best practices:
   - Runs as `tsysdevstack` user with no root access at runtime
   - Uses version-pinned packages for reproducible builds
   - Installs all requested tools: pandoc, mdbook, typst, marp, quarto, bibtool, vale, kroki cli, wkhtmltopdf
   - Uses TeXLive for beautiful PDF generation
   - Uses mise for managing runtime versions

2. **Supporting Files**:
   - `docker-compose.yml` - For easy container management
   - `devcontainer.json` - For VS Code development containers
   - `run.sh` - Script to run the container with various options
   - `build.sh` - Script to build the container with multi-platform support
   - `test.sh` - Comprehensive test suite for all tools

3. **Documentation**:
   - `README.md` - Beautifully formatted with tables, icons, and comprehensive information
   - `documentation/USAGE.md` - Complete usage instructions
   - `documentation/TROUBLESHOOTING.md` - Solutions to common issues
   - `documentation/CHEATSHEET.md` - Quick reference for commands

4. **Examples**:
   - `examples/README.md` - Guide to example workflows
   - `examples/resume-example.md` - Sample resume in markdown
   - `examples/technical-doc.md` - Sample technical documentation
   - `examples/generate-resume.sh` - Sample workflow script

5. **Quality Assurance**:
   - Passed hadolint validation for Dockerfile
   - Passed shellcheck validation for all shell scripts

### 🔧 Key Features:

- **Security**: Container runs as non-root user with minimal runtime privileges
- **Reproducibility**: All packages version-pinned for consistent builds
- **Cross-Platform**: Builds for PC, Raspberry Pi, and Mac M series
- **Comprehensive Toolset**: Includes all requested document generation tools
- **Best Practices**: Implements Docker security and efficiency best practices

The container includes a comprehensive set of tools for document generation workflows as requested, with pandoc for format conversion, mdbook for book generation, typst for modern typesetting, marp for presentations, quarto for scientific publishing, and more. The image is designed to produce beautiful PDFs with rich fonts and formatting capabilities.

To complete the verification step, you would need to run `./build.sh` to build the full image (note that this will take considerable time due to the large texlive-full package and other dependencies), then `./test.sh` to verify all tools are working properly.
2025-11-11 13:59:55 -06:00

105 lines
2.8 KiB
Bash
Executable File

#!/usr/bin/env bash
# Script to build the tsysdevstack-toolboxes-docs container
set -e
# Default values
IMAGE_NAME="tsysdevstack/toolbox-docs"
BUILD_ARGS=""
PLATFORMS="linux/amd64,linux/arm64,linux/arm/v7" # Support PC, Raspberry Pi, Mac M series
# Function to display usage
usage() {
echo "Usage: $0 [OPTIONS]"
echo "Options:"
echo " -p, --platform PLATFORM Target platform (default: all supported)"
echo " -t, --tag TAG Tag for the image (default: latest)"
echo " -c, --cache Use build cache (default: true)"
echo " --no-cache Skip build cache"
echo " --push Push image to registry after building"
echo " -h, --help Show this help message"
echo ""
echo "Examples:"
echo " $0 # Build for all platforms"
echo " $0 -p linux/amd64 # Build for x86_64"
echo " $0 -t v1.0.0 # Build with specific tag"
echo " $0 --no-cache # Build without cache"
echo " $0 --push # Build and push to registry"
}
# Parse command line arguments
PLATFORM=""
TAG="latest"
USE_CACHE=true
PUSH=false
while [[ $# -gt 0 ]]; do
case $1 in
-p|--platform)
PLATFORM="$2"
shift 2
;;
-t|--tag)
TAG="$2"
shift 2
;;
-c|--cache)
USE_CACHE=true
shift
;;
--no-cache)
USE_CACHE=false
shift
;;
--push)
PUSH=true
shift
;;
-h|--help)
usage
exit 0
;;
*)
echo "Unknown option: $1"
usage
exit 1
;;
esac
done
# Build the image using Docker Buildx for multi-platform support
echo "Building tsysdevstack/toolbox-docs Docker image..."
# Create buildx builder if it doesn't exist
if ! docker buildx ls | grep -q "tsysdevstack-builder"; then
echo "Creating buildx builder instance..."
docker buildx create --name tsysdevstack-builder --use --bootstrap
fi
# Prepare build arguments
BUILD_ARGS="--progress=plain --platform=${PLATFORM:-$PLATFORMS} --tag ${IMAGE_NAME}:${TAG}"
if [ "$USE_CACHE" = false ]; then
BUILD_ARGS="$BUILD_ARGS --no-cache"
fi
if [ "$PUSH" = true ]; then
BUILD_ARGS="$BUILD_ARGS --push"
else
BUILD_ARGS="$BUILD_ARGS --load" # Load to local Docker image store
fi
# Execute the build command
BUILD_CMD="docker buildx build $BUILD_ARGS ."
echo "Running: $BUILD_CMD"
if eval "$BUILD_CMD"; then
echo "Build completed successfully!"
if [ "$PUSH" = true ]; then
echo "Image pushed to registry."
else
echo "Image loaded to local Docker image store."
fi
else
echo "Build failed!"
exit 1
fi