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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file dockerfile-3.4.0.tar.gz.
File metadata
- Download URL: dockerfile-3.4.0.tar.gz
- Upload date:
- Size: 7.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
238bb950985c55a525daef8bbfe994a0230aa0978c419f4caa4d9ce0a37343f1
|
|
| MD5 |
ecfda3a2d1ca457f388bdad72d8688c3
|
|
| BLAKE2b-256 |
dec92cdd6060f8f476c41a1638a9e1b28923fb0d9c075dffc41b13137199e207
|
File details
Details for the file dockerfile-3.4.0-cp39-abi3-win_amd64.whl.
File metadata
- Download URL: dockerfile-3.4.0-cp39-abi3-win_amd64.whl
- Upload date:
- Size: 1.8 MB
- Tags: CPython 3.9+, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
30202187f1885f99ac839fd41ca8150b2fd0a66fac12db0166361d0c4622e71a
|
|
| MD5 |
2a3a384109a2979603a15b2387ba05fa
|
|
| BLAKE2b-256 |
815d3d3b83501e62f6f319db884113bab89fc02b6c29ca7004049a8144eec01e
|
File details
Details for the file dockerfile-3.4.0-cp39-abi3-manylinux_2_5_x86_64.manylinux1_x86_64.whl.
File metadata
- Download URL: dockerfile-3.4.0-cp39-abi3-manylinux_2_5_x86_64.manylinux1_x86_64.whl
- Upload date:
- Size: 1.7 MB
- Tags: CPython 3.9+, manylinux: glibc 2.5+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b95102bd82e6f67c836186b51c13114aa586a20e8cb6441bde24d4070542009d
|
|
| MD5 |
6790f703abcba12985d2350fa70c83aa
|
|
| BLAKE2b-256 |
0b352cb27f4a0a68bacde1bdbc2cd4ba8d0d5be95fca04010c7bd83caa96cd20
|
File details
Details for the file dockerfile-3.4.0-cp39-abi3-macosx_14_0_arm64.whl.
File metadata
- Download URL: dockerfile-3.4.0-cp39-abi3-macosx_14_0_arm64.whl
- Upload date:
- Size: 1.6 MB
- Tags: CPython 3.9+, macOS 14.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a4549d4f038483c25906d4fec56bb6ffe82ae26e0f80a15f2c0fedbb50712053
|
|
| MD5 |
cd6310343a7a4e56a0d68e3c825db2cb
|
|
| BLAKE2b-256 |
8ebf246a02d803318131d809b13d285244e4047def667df906ad123e7d8405b2
|
File details
Details for the file dockerfile-3.4.0-cp39-abi3-macosx_13_0_x86_64.whl.
File metadata
- Download URL: dockerfile-3.4.0-cp39-abi3-macosx_13_0_x86_64.whl
- Upload date:
- Size: 1.7 MB
- Tags: CPython 3.9+, macOS 13.0+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ed33446a76007cbb3f28c247f189cc06db34667d4f59a398a5c44912d7c13f36
|
|
| MD5 |
320e04f51f0bf6f578db2f79a6585118
|
|
| BLAKE2b-256 |
a12a553b099124685f00c4cc06cda6496db02e43ca51d7b7b5dc68814c6b48be
|