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.GoParseError
: 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.GoParseError
: 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-3.3.0-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | dfe5d74a24d9a604ae5e7e600fdcf2398df998e1697042a70909207268eb6bbe |
|
MD5 | 8a6cf3875dc8b4d4a3869f89c7dd2c74 |
|
BLAKE2b-256 | c3d265f66868da21b1b4a9e1751f1f0a40ceff2f832f9358c0f12a7a26ba5e0e |
Hashes for dockerfile-3.3.0-cp38-abi3-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9562f325fcc262497101d9ffacfa998879f2447864512e0d7ebca6837bb4f35c |
|
MD5 | d1b51039b4a571b3add7bd08b17038af |
|
BLAKE2b-256 | d6205db57677593b2b11bfcc7c7130f4e70fa8ed2858f50eeb6a8a4b90fac3c7 |
Hashes for dockerfile-3.3.0-cp38-abi3-macosx_13_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f126e83f3d62a64b328d58fdd5fbf46e5f556d597fe546f3f67cf47141890a73 |
|
MD5 | 9d4ca0a18b805384a1a7227a3a36f843 |
|
BLAKE2b-256 | bcce91b1379d314343862c4d438692b35d2742e2632a79eed717989c04a9450c |
Hashes for dockerfile-3.3.0-cp38-abi3-macosx_12_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 808de8f323199f867e106e09448760525c82870015a37f1608189a21c1363f9c |
|
MD5 | 32bcf2044c793c20ca1f590aff9baa25 |
|
BLAKE2b-256 | 987eadfc1378c63aecc79abdcbefa2968a15952eb4440283013dc6c5951c89f3 |