diff --git a/README.md b/README.md index c5902c1..9a26a81 100644 --- a/README.md +++ b/README.md @@ -150,3 +150,16 @@ dockerfile: Dockerfile ``` will look for the dockerfile relative to the rockerc.yaml file + +## Configuration Examples + +See the [examples/](examples/) directory for comprehensive configuration examples: + +- **[examples/basic.yaml](examples/basic.yaml)** - Simple starter configuration with core extensions +- **[examples/advanced.yaml](examples/advanced.yaml)** - Feature-rich development setup +- **[examples/dockerfile.yaml](examples/dockerfile.yaml)** - Using a custom Dockerfile +- **[examples/global-config.yaml](examples/global-config.yaml)** - System-wide defaults +- **[examples/intel-gpu.yaml](examples/intel-gpu.yaml)** - Mounting Intel GPU for hardware acceleration +- **[examples/blacklist.yaml](examples/blacklist.yaml)** - Excluding extensions + +Each example includes detailed inline comments explaining the configuration options and their purposes. diff --git a/examples/advanced.yaml b/examples/advanced.yaml new file mode 100644 index 0000000..54c3268 --- /dev/null +++ b/examples/advanced.yaml @@ -0,0 +1,48 @@ +# Advanced rockerc.yaml Example +# +# This example demonstrates a more complex configuration building on top +# of the basic core extensions with additional features commonly used in +# development workflows. +# +# Equivalent rocker command: +# rocker --pull --persist-image --x11 --user --cwd --git --git-clone \ +# --ssh --ssh-client --nvidia --pixi --uv --deps --dev-helpers --curl \ +# --volume /data:/workspace/data --shm-size 2g \ +# --name my-dev-container -- ubuntu:24.04 + +# Base Docker image +image: ubuntu:24.04 + +# Container name (optional) +# If not specified, rockerc generates a name based on the project directory +name: my-dev-container + +# Custom volume mount (optional) +# Useful for mounting external data directories or shared storage +# Format: HOST_PATH:CONTAINER_PATH[:OPTIONS] +volume: /data:/workspace/data + +# Increase shared memory size for applications that need it +# (e.g., PyTorch DataLoader with multiple workers, Chrome/Firefox) +shm-size: 2g + +# Comprehensive list of development extensions +args: + # Core extensions (from basic.yaml) + - pull # Pull latest image version + - persist-image # Keep the image after container stops + - x11 # X11 forwarding for GUI applications + - user # Match host user inside container + - cwd # Mount current working directory + - git # Use the global Git settings from the host + - git-clone # Install git, git-lfs, and ca-certificates for cloning + - ssh # Forward SSH agent into the container + - ssh-client # Install openssh-client and mount ~/.ssh directory + + # Additional advanced features + - nvidia # Enable NVIDIA GPU support + - pixi # Install pixi package manager + - uv # Install uv Python package manager + - deps # Install common system dependencies + - dev-helpers # Add development tools (emacs, byobu) + - curl # Install curl diff --git a/examples/basic.yaml b/examples/basic.yaml new file mode 100644 index 0000000..474df39 --- /dev/null +++ b/examples/basic.yaml @@ -0,0 +1,25 @@ +# Basic rockerc.yaml Example +# +# This is a comprehensive baseline configuration with core extensions +# that are useful for most development workflows. +# +# Equivalent rocker command: +# rocker --pull --persist-image --x11 --user --cwd --git \ +# --git-clone --ssh --ssh-client -- ubuntu:24.04 + +# The base Docker image to use +image: ubuntu:24.04 + +# List of rocker extensions to enable +# These are considered "core" extensions for most development workflows +args: + # Core extensions + - pull # Pull the latest version of the image before running + - persist-image # Keep the image after container stops + - x11 # Enable X11 forwarding for GUI applications + - user # Create a user inside the container matching your host user + - cwd # Mount current working directory into the container + - git # Use the global Git settings from the host + - git-clone # Install git, git-lfs, and ca-certificates for cloning + - ssh # Forward SSH agent into the container + - ssh-client # Install openssh-client and mount ~/.ssh directory diff --git a/examples/blacklist.yaml b/examples/blacklist.yaml new file mode 100644 index 0000000..a8b3f6b --- /dev/null +++ b/examples/blacklist.yaml @@ -0,0 +1,44 @@ +# Extension Blacklist Example +# +# Use extension-blacklist to exclude unwanted extensions, particularly +# useful when you have global extensions in ~/.rockerc.yaml but want to +# disable specific ones for a project. +# +# This is useful for: +# - Disabling GPU support for CPU-only projects +# - Skipping X11 for headless containers +# - Removing conflicting or unnecessary extensions + +image: ubuntu:24.04 + +args: + # Core extensions (excluding x11 and ssh for headless use) + - pull + - persist-image + - user + - cwd + - git + - git-clone + + # Project-specific extensions + - pixi + +# Exclude specific extensions +# These will be filtered out even if present in global config or args above +extension-blacklist: + - nvidia # No GPU needed for this project + - x11 # Headless container - no GUI + - cuda # No CUDA support needed + - ssh # No SSH server needed + - ssh-client # No SSH client needed + +# How blacklist works: +# 1. Global config (~/.rockerc.yaml) might have: [pull, persist-image, x11, user, cwd, git, git-clone, ssh, ssh-client, cuda] +# 2. Project config (this file) has args: [pull, persist-image, user, cwd, git, git-clone, pixi] +# 3. Merged args before blacklist: [pull, persist-image, x11, user, cwd, git, git-clone, ssh, ssh-client, cuda, pixi] +# 4. After applying blacklist: [pull, persist-image, user, cwd, git, git-clone, pixi] +# +# Result: x11, ssh, ssh-client, cuda from global config are excluded + +# You can also have blacklist in global config to system-wide exclude extensions +# and override it per-project by adding them back to args diff --git a/examples/dockerfile.yaml b/examples/dockerfile.yaml new file mode 100644 index 0000000..a074da0 --- /dev/null +++ b/examples/dockerfile.yaml @@ -0,0 +1,38 @@ +# Dockerfile-based rockerc.yaml Example +# +# Instead of using a pre-built image, you can specify a Dockerfile to build. +# rockerc will build the image and tag it automatically based on your +# project directory name. +# +# Note: When using dockerfile, the 'pull' extension is automatically removed +# since you're building locally. +# +# The dockerfile path is relative to the location of rockerc.yaml + +# Path to Dockerfile (relative to this rockerc.yaml) +dockerfile: ./Dockerfile + +# Extensions to apply to the built image +args: + # Core extensions (pull will be auto-removed when using dockerfile) + - pull # Will be automatically removed for local builds + - persist-image # Keep the image after container stops + - x11 # X11 forwarding + - user # User matching + - cwd # Mount working directory + - git # Use the global Git settings from the host + - git-clone # Install git, git-lfs, and ca-certificates for cloning + - ssh # Forward SSH agent into the container + - ssh-client # Install openssh-client and mount ~/.ssh directory + + # Additional extensions + - nvidia # GPU support (if your Dockerfile supports it) + +# Example Dockerfile content you might use: +# --- +# FROM ubuntu:24.04 +# RUN apt-get update && apt-get install -y \ +# python3 \ +# python3-pip \ +# build-essential +# --- diff --git a/examples/global-config.yaml b/examples/global-config.yaml new file mode 100644 index 0000000..81c21e8 --- /dev/null +++ b/examples/global-config.yaml @@ -0,0 +1,38 @@ +# Global rockerc Configuration Example +# +# Save this as ~/.rockerc.yaml to set system-wide defaults +# that apply to all projects unless overridden. +# +# Project-specific rockerc.yaml files will: +# - Merge their 'args' list with these global args (duplicates removed) +# - Override other fields like 'image', 'name', 'volume', etc. +# - Can blacklist global extensions using 'extension-blacklist' +# +# This is useful for: +# - Setting up common development tools across all projects +# - Configuring user preferences (git, ssh, etc.) +# - Defining standard GPU or display settings + +# No image specified here - projects will provide their own +# Or you can set a default: +# image: ubuntu:24.04 + +# Global extensions applied to all containers +args: + # Core extensions - applied to all projects + - pull # Always pull latest images + - persist-image # Keep images after container stops + - x11 # Always enable X11 for GUI apps + - user # Always match host user + - cwd # Mount working directory + - git # Use the global Git settings from the host + - git-clone # Install git, git-lfs, and ca-certificates for cloning + - ssh # Forward SSH agent into the container + - ssh-client # Install openssh-client and mount ~/.ssh directory + + # Additional global extensions (customize as needed) + - dev-helpers # Development tools in all containers + - cuda # GPU support (if you have NVIDIA GPU) + +# You can also set global volumes +# volume: ~/.config:/home/user/.config:ro diff --git a/examples/intel-gpu.yaml b/examples/intel-gpu.yaml new file mode 100644 index 0000000..820fc7f --- /dev/null +++ b/examples/intel-gpu.yaml @@ -0,0 +1,36 @@ +# Intel GPU Example +# +# This example demonstrates how to mount Intel GPU devices for hardware +# acceleration in the container. This is useful for graphics rendering, +# video encoding/decoding, and compute workloads on Intel integrated GPUs. +# +# The key is using the 'devices' field to mount /dev/dri, which provides +# access to Intel GPU Direct Rendering Infrastructure. + +image: ubuntu:24.04 + +args: + # Core extensions + - pull # Pull latest image version + - persist-image # Keep the image after container stops + - x11 # X11 forwarding for GUI applications + - user # Match host user inside container + - cwd # Mount current working directory + - git # Use the global Git settings from the host + - git-clone # Install git, git-lfs, and ca-certificates for cloning + - ssh # Forward SSH agent into the container + - ssh-client # Install openssh-client and mount ~/.ssh directory + +# Mount Intel GPU devices +# /dev/dri contains the renderD128 and card0 nodes for GPU access +devices: /dev/dri + +# This configuration enables: +# - OpenGL rendering on Intel integrated graphics +# - Hardware video encoding/decoding (VAAPI, QSV) +# - OpenCL compute on Intel GPUs +# +# Verify GPU access inside the container with: +# ls -la /dev/dri +# vainfo # For video acceleration info (install vainfo package) +# glxinfo | grep "OpenGL renderer" # For OpenGL info diff --git a/rockerc.yaml b/rockerc.yaml index 9cc924b..777a37b 100644 --- a/rockerc.yaml +++ b/rockerc.yaml @@ -7,13 +7,19 @@ image: ubuntu:24.04 args: - - jquery - - x11 - - user - - pull + # Core extensions + - pull # Pull latest image version + - persist-image # Keep the image after container stops + - x11 # X11 forwarding for GUI applications + - user # Match host user inside container + - cwd # Mount current working directory + - git # Use the global Git settings from the host + - git-clone # Install git, git-lfs, and ca-certificates for cloning + - ssh # Forward SSH agent into the container + - ssh-client # Install openssh-client and mount ~/.ssh directory + + # Project-specific extensions - deps - - git - - cwd - pixi - uv - jquery diff --git a/specs/24/yaml-examples/plan.md b/specs/24/yaml-examples/plan.md new file mode 100644 index 0000000..f029b64 --- /dev/null +++ b/specs/24/yaml-examples/plan.md @@ -0,0 +1,73 @@ +# Implementation Plan for rockerc.yaml Examples + +## Files to Create + +### 1. examples/ Directory Structure +Create a new `examples/` directory at the project root containing: + +- `examples/basic.yaml` - Simple configuration with image and common extensions +- `examples/advanced.yaml` - Complex configuration with multiple features +- `examples/dockerfile.yaml` - Using a Dockerfile instead of an image +- `examples/global-config.yaml` - Example for ~/.rockerc.yaml +- `examples/vscode.yaml` - VS Code specific configuration +- `examples/blacklist.yaml` - Demonstrating extension-blacklist feature +- `examples/README.md` - Comprehensive documentation of syntax and options + +### 2. Documentation Updates +- Update main README.md to reference examples +- Add detailed configuration reference to examples/README.md + +## Configuration Options to Document + +### Required Fields +- `image`: Docker image to use (e.g., `ubuntu:24.04`) +- `dockerfile`: Alternative to image - path to Dockerfile + +### Args Field +- List of rocker extensions to enable +- Common extensions: x11, user, pull, git, cwd, nvidia, cuda, etc. +- Custom extensions available through rocker plugins + +### Optional Fields +- `name`: Container name +- `image-name`: Image name for the built image +- `volume`: Custom volume mounts (format: `HOST:CONTAINER:OPTIONS`) +- `extension-blacklist`: List of extensions to exclude + +### CLI Integration +- How CLI arguments merge with YAML config +- CLI extensions append to config extensions +- CLI image overrides config image + +## Examples to Create + +### Basic Example +Simple dev container with common tools + +### Advanced Example +Full-featured setup with: +- GPU support (nvidia) +- X11 forwarding +- Custom volume mounts +- Git integration +- Multiple dev tools + +### Dockerfile Example +Using a custom Dockerfile instead of a base image + +### Global Config Example +System-wide defaults in ~/.rockerc.yaml + +### VS Code Example +Configuration optimized for VS Code devcontainer workflow + +### Blacklist Example +Show how to exclude unwanted extensions from global config + +## Implementation Steps +1. Create examples/ directory +2. Write each example YAML file with inline comments +3. Create examples/README.md with comprehensive documentation +4. Update main README.md to reference examples +5. Test each example to ensure they work +6. Run CI to validate diff --git a/specs/24/yaml-examples/spec.md b/specs/24/yaml-examples/spec.md new file mode 100644 index 0000000..efe806f --- /dev/null +++ b/specs/24/yaml-examples/spec.md @@ -0,0 +1,11 @@ +# Add Example rockerc.yaml Files + +**Spec:** +- Create comprehensive example rockerc.yaml files demonstrating various configurations +- Document the YAML syntax and structure +- Show how rocker CLI arguments translate to YAML configuration +- Include examples for common use cases (basic, advanced, global config) +- Document quirks and limitations +- Update README.md with links to examples + +**Addresses:** Issue #120