| Crates.io | oak-dockerfile |
| lib.rs | oak-dockerfile |
| version | 0.0.1 |
| created_at | 2025-10-20 16:34:31.654832+00 |
| updated_at | 2026-01-23 04:27:31.683402+00 |
| description | Dockerfile container configuration language parser with support for container image building and management. |
| homepage | https://github.com/ygg-lang/oaks |
| repository | https://github.com/ygg-lang/oaks |
| max_upload_size | |
| id | 1892300 |
| size | 65,621 |
High-performance incremental Dockerfile parser for the oak ecosystem with flexible configuration, optimized for container configuration and image building.
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.
Basic example:
use oak_dockerfile::{Parser, DockerfileLanguage, SourceText};
fn main() -> Result<(), Box<dyn std::error::Error>> {
let parser = Parser::new();
let source = SourceText::new(r#"
FROM alpine:latest
RUN apk add --no-cache bash
COPY . /app
WORKDIR /app
CMD ["bash"]
"#);
let result = parser.parse(&source);
println!("Parsed Dockerfile successfully.");
Ok(())
}
use oak_dockerfile::{Parser, DockerfileLanguage, SourceText};
let parser = Parser::new();
let source = SourceText::new(r#"
FROM node:14-alpine
WORKDIR /app
COPY package*.json ./
RUN npm ci --only=production
COPY . .
EXPOSE 3000
CMD ["npm", "start"]
"#);
let result = parser.parse(&source);
println!("Dockerfile parsed successfully.");
use oak_dockerfile::{Parser, DockerfileLanguage, SourceText};
let parser = Parser::new();
let source = SourceText::new(r#"
# Build stage
FROM golang:1.19-alpine AS builder
WORKDIR /src
COPY go.mod go.sum ./
RUN go mod download
COPY . .
RUN CGO_ENABLED=0 go build -o /app
# Runtime stage
FROM alpine:latest
RUN apk --no-cache add ca-certificates
WORKDIR /root/
COPY --from=builder /app .
EXPOSE 8080
CMD ["./app"]
"#);
let result = parser.parse(&source);
println!("Multi-stage Dockerfile parsed successfully.");
use oak_dockerfile::{Parser, DockerfileLanguage, SourceText};
let parser = Parser::new();
let source = SourceText::new("FROM alpine:latest");
let result = parser.parse(&source);
println!("Token parsing completed.");
use oak_dockerfile::{Parser, DockerfileLanguage, SourceText};
let parser = Parser::new();
let source = SourceText::new(r#"
FROM alpine:latest
RUN apk add --no-cache bash
COPY . /app
WORKDIR /app
CMD ["bash"
# Missing closing bracket
"#);
let result = parser.parse(&source);
if let Some(errors) = result.result.err() {
println!("Parse errors found: {:?}", errors);
} else {
println!("Parsed successfully.");
}
The parser generates a comprehensive AST with the following main structures:
Oak Dockerfile integrates seamlessly with:
Check out the examples directory for comprehensive examples:
Contributions are welcome!
Please feel free to submit pull requests at the project repository or open issues.