Giter VIP home page Giter VIP logo

dockerfile's Introduction

Build Status

dockerfile

The goal of this repository is to provide a wrapper around docker/docker's parser for dockerfiles.

python library

Installation

This project uses setuptools-golang when built from source. To build from source you'll need a go compiler.

If you're using linux and sufficiently new pip (>=8.1) you should be able to just download prebuilt manylinux1 wheels.

pip install dockerfile

Usage

There's three api functions provided by this library:

dockerfile.all_cmds()

List all of the known dockerfile cmds.

>>> dockerfile.all_cmds()
('add', 'arg', 'cmd', 'copy', 'entrypoint', 'env', 'expose', 'from', 'healthcheck', 'label', 'maintainer', 'onbuild', 'run', 'shell', 'stopsignal', 'user', 'volume', 'workdir')

dockerfile.parse_file(filename)

Parse a Dockerfile by filename. Returns a tuple of dockerfile.Command objects representing each layer of the Dockerfile. Possible exceptions:

  • dockerfile.GoIOError: The file could not be opened.
  • dockerfile.ParseError: The Dockerfile was not parseable.
>>> pprint.pprint(dockerfile.parse_file('testfiles/Dockerfile.ok'))
(Command(cmd='from', sub_cmd=None, json=False, original='FROM ubuntu:xenial', start_line=1, flags=(), value=('ubuntu:xenial',)),
 Command(cmd='cmd', sub_cmd=None, json=True, original='CMD ["echo", "hi"]', start_line=2, flags=(), value=('echo', 'hi')))

dockerfile.parse_string(s)

Parse a dockerfile using a string. Returns a tuple of dockerfile.Command objects representing each layer of the Dockerfile. Possible exceptions:

  • dockerfile.ParseError: The Dockerfile was not parseable.
>>> dockerfile.parse_string('FROM ubuntu:xenial')
(Command(cmd='from', sub_cmd=None, json=False, original='FROM ubuntu:xenial', start_line=1, flags=(), value=('ubuntu:xenial',)),)

go library

Slightly more convenient than the api provided by docker/docker? Might not be terribly useful -- the main point of this repository was a python wrapper.

Installation

go get github.com/asottile/dockerfile

Usage

godoc

dockerfile's People

Contributors

asottile avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.