dockerfile-ast
Parse a Dockerfile into an array of instructions and comments.
Last updated 2 years ago by rcjsuen .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ gnpm install dockerfile-ast 
SYNC missed versions from official npm registry.

Dockerfile AST

Node.js Builds Coverage Status Build Dependencies License: MIT npm downloads per week

The dockerfile-ast NPM module is a Dockerfile parser written in TypeScript. The module provides full programmatic access to a parsed Dockerfile.

Supported features:

  • escaped newline detection
    • escape parser directive considered when parsing
  • comments preserved
    • inlined comments in multiline instructions preserved
  • continuous empty newlines honoured (albeit discouraged as of Docker CE 17.09)
  • ARG and ENV variable lookup and resolution

Unsupported:

  • \r as a a line delimiter
    • only \r\n and \n are supported as being line delimiters
    • if a \r is detected the parser assumes that it is followed by a \n

Development Instructions

If you wish to build and compile this project, you must first install Node.js if you have not already done so. After you have installed Node.js and cloned the repository with Git, you may now proceed to build and compile the project with the following commands:

npm install
npm run build
npm test

If you are planning to change the code, use npm run watch to get the TypeScript files transpiled on-the-fly as they are modified.

Installation Instructions

To add this library as a dependency to your project, please add dockerfile-ast as a dependency in your package.json file.

Using this Module

import { DockerfileParser } from 'dockerfile-ast';

const content =
`FROM alpine
ExposE 8080`

let dockerfile = DockerfileParser.parse(content);
let instructions = dockerfile.getInstructions();
for (let instruction of instructions) {
  // FROM
  // EXPOSE
  console.log(instruction.getKeyword());
  // FROM
  // ExposE
  console.log(instruction.getInstruction());
}

Current Tags

  • 0.6.1                                ...           latest (a year ago)

44 Versions

  • 0.6.1                                ...           a year ago
  • 0.6.0                                ...           a year ago
  • 0.5.0                                ...           2 years ago
  • 0.4.2                                ...           3 years ago
  • 0.4.1                                ...           3 years ago
  • 0.4.0                                ...           3 years ago
  • 0.3.4                                ...           3 years ago
  • 0.3.3                                ...           3 years ago
  • 0.3.2                                ...           3 years ago
  • 0.3.1                                ...           3 years ago
  • 0.3.0                                ...           3 years ago
  • 0.2.1                                ...           4 years ago
  • 0.2.0                                ...           4 years ago
  • 0.1.0                                ...           4 years ago
  • 0.0.30                                ...           4 years ago
  • 0.0.29                                ...           4 years ago
  • 0.0.28                                ...           4 years ago
  • 0.0.27                                ...           4 years ago
  • 0.0.26                                ...           5 years ago
  • 0.0.25                                ...           5 years ago
  • 0.0.24                                ...           5 years ago
  • 0.0.23                                ...           5 years ago
  • 0.0.22                                ...           5 years ago
  • 0.0.21                                ...           5 years ago
  • 0.0.20                                ...           5 years ago
  • 0.0.19                                ...           5 years ago
  • 0.0.18                                ...           5 years ago
  • 0.0.17                                ...           5 years ago
  • 0.0.16                                ...           6 years ago
  • 0.0.15                                ...           6 years ago
  • 0.0.14                                ...           6 years ago
  • 0.0.13                                ...           6 years ago
  • 0.0.12                                ...           6 years ago
  • 0.0.11                                ...           6 years ago
  • 0.0.10                                ...           6 years ago
  • 0.0.9                                ...           7 years ago
  • 0.0.8                                ...           7 years ago
  • 0.0.7                                ...           7 years ago
  • 0.0.6                                ...           7 years ago
  • 0.0.5                                ...           7 years ago
  • 0.0.4                                ...           7 years ago
  • 0.0.3                                ...           7 years ago
  • 0.0.2                                ...           7 years ago
  • 0.0.1                                ...           7 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (2)
Dev Dependencies (5)
Dependents (1)

Copyright 2013 - present © cnpmjs.org | Home |