Oak Dockerfile Parser
High-performance incremental Dockerfile parser for the oak ecosystem with flexible configuration, optimized for container configuration and image building.
🎯 Overview
Oak Dockerfile is a robust parser for Dockerfile, designed to handle complete Dockerfile syntax including modern features. Built on the solid foundation of oak-core, it provides both high-level convenience and detailed AST generation for container configuration and image building.
✨ Features
- Complete Dockerfile Syntax: Supports all Dockerfile features including modern specifications
- Full AST Generation: Generates comprehensive Abstract Syntax Trees
- Lexer Support: Built-in tokenization with proper span information
- Error Recovery: Graceful handling of syntax errors with detailed diagnostics
🚀 Quick Start
Basic example:
use ;
📋 Parsing Examples
Basic Dockerfile Parsing
use ;
let parser = new;
let source = new;
let result = parser.parse;
println!;
Multi-stage Build Parsing
use ;
let parser = new;
let source = new;
let result = parser.parse;
println!;
🔧 Advanced Features
Token-Level Parsing
use ;
let parser = new;
let source = new;
let result = parser.parse;
println!;
Error Handling
use ;
let parser = new;
let source = new;
let result = parser.parse;
if let Some = result.result.err else
🏗️ AST Structure
The parser generates a comprehensive AST with the following main structures:
- Dockerfile: Root container for Dockerfile documents
- Instruction: Dockerfile instructions (FROM, RUN, COPY, etc.)
- Argument: Instruction arguments and parameters
- Stage: Build stages in multi-stage builds
- Comment: Dockerfile comments
📊 Performance
- Streaming: Parse large Dockerfiles without loading entirely into memory
- Incremental: Re-parse only changed sections
- Memory Efficient: Smart AST node allocation
- Fast Recovery: Quick error recovery for better IDE integration
🔗 Integration
Oak Dockerfile integrates seamlessly with:
- Container Analysis: Analyze Dockerfiles for security and best practices
- CI/CD Pipelines: Integrate with build and deployment workflows
- IDE Support: Language server protocol compatibility
- Security Scanning: Identify potential security issues in Dockerfiles
- Optimization: Suggest optimizations for Dockerfile structure
📚 Examples
Check out the examples directory for comprehensive examples:
- Complete Dockerfile parsing
- Multi-stage build analysis
- Security vulnerability detection
- Integration with development workflows
🤝 Contributing
Contributions are welcome!
Please feel free to submit pull requests at the project repository or open issues.