Parse a dockerfile into a high-level representation using the official go parser.
Project description
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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Hashes for dockerfile-2.1.0-cp37-cp37m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bcfa8fb13411accd37dfda738fd08fc81bf403c7384c681f2655bf853a60bc26 |
|
MD5 | 8380ef095dacd49ba182e5e179adc50e |
|
BLAKE2b-256 | b1d524d7eb1d1b2f7ce4371fde1be5805e6cd77acbf2a71e3a9b892973a2e2f0 |
Hashes for dockerfile-2.1.0-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ee5bcd42c7ed8ae340fb2b633cea7a5e5543458dad01b4064e4edf3fcae1f7d3 |
|
MD5 | bd84acb3a5c891732824ed3d07ee6cf5 |
|
BLAKE2b-256 | d4f471ca84f9fac12162d41e5b42a66ed6729be9936ffc1e86fd6aae43f7493d |
Hashes for dockerfile-2.1.0-cp36-cp36m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a8d306204e878a3a479bfb71db329516d9d8151ef4051021c0ca12caa9bf9abd |
|
MD5 | 8d763d1231db0cea4cf8db211d82162a |
|
BLAKE2b-256 | e3640a2ca2b21249455045fe70efa78a17bd8aada70170263849b305b5cd13eb |
Hashes for dockerfile-2.1.0-cp36-cp36m-macosx_10_14_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b90a7d29e2d4931cc152bc5f5725f643a8a9e18fbb6c9a063b9011a2aca90cc2 |
|
MD5 | 26d950de1c5535807605f059bcbdedf2 |
|
BLAKE2b-256 | e753de0604e6212bfab6ba7f8344e7791f3e7782b73624fc61e5d8f71fad3ee9 |
Hashes for dockerfile-2.1.0-cp35-cp35m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ab27b53cf31645cf30773ab6430f6c2969fac378d2dcbbac3d4c5325549baac9 |
|
MD5 | b20dbf71376f6dbdc270d2cc78ceedd9 |
|
BLAKE2b-256 | 1b58df4ce9d91a016b9a3a06cb8b67619095b981141af5743363b2d7ce7fe194 |
Hashes for dockerfile-2.1.0-cp34-cp34m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 67a52684eb0fd6cea0d10658fb5fa1a083f6aada67c63fb22b2f7f58e5c0aaf9 |
|
MD5 | 5635a3025696905c1afe0af599a107aa |
|
BLAKE2b-256 | 54e5b6b3f9f9446e213712749721a4f46b474e99e48b97b8a9cf34652e12e704 |
Hashes for dockerfile-2.1.0-cp27-cp27mu-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9dd0e0f5ae9ef9111a60d635e0e3aa66f0c84e7ef1e4c19a42ff0dca8d3d178a |
|
MD5 | cdd71860a822a8f7ddc63deaf395f876 |
|
BLAKE2b-256 | 0e89ca830c249319195311ae7072cdef10d1aaa0d791f9dcf599d8682fc451ad |
Hashes for dockerfile-2.1.0-cp27-cp27m-macosx_10_14_intel.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3754846f3a47a17d8cffed000bf5b124a2b1e16ad03aa7705769c3d6aa794165 |
|
MD5 | 49d78f920c8b063ee400e1f6d359f09e |
|
BLAKE2b-256 | 893014fdc422cfea3c7be70b91be202161b8b9a9eef97f82cc5b5d75d1fd92dd |