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.2.0-cp38-abi3-macosx_12_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a3ff90c92f05b5bceee4742d15899b3967cda025eec14a852811d089caf3478e |
|
MD5 | ae697cd9b0dcdf12604f266869f86048 |
|
BLAKE2b-256 | a75319d0ce2471a22fa469a7748e8d45f0eaa99b38dfbfecfe24cd1ca19db41f |
Hashes for dockerfile-3.2.0-cp36-abi3-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e6bd64408386b7ba2259d85820e0fe90de1b6b8269f560f18aba100c6aa40b7d |
|
MD5 | aae3bf6bdd32c39bf9b9ca18d423b332 |
|
BLAKE2b-256 | 0ede00149a416148c609c71c8a94e5e4df14a9f62bf2fa41aeda021b76388623 |
Hashes for dockerfile-3.2.0-cp36-abi3-macosx_10_14_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e6e00b82b82042fb4df569ae00bd2648ac6c8823f51c406da31ab01c728926c2 |
|
MD5 | ddaffd905a75838b219c0c626f9df484 |
|
BLAKE2b-256 | 9e190f56ebd6d535832bfbe7c4f16c983c08ab8e01927fe9ae15e1afcfa88996 |