dockerfile


Namedockerfile JSON
Version 3.3.1 PyPI version JSON
download
home_pagehttps://github.com/asottile/dockerfile
SummaryParse a dockerfile into a high-level representation using the official go parser.
upload_time2023-09-05 13:52:24
maintainer
docs_urlNone
authorAnthony Sottile
requires_python>=3.8
licenseMIT
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            [![build status](https://github.com/asottile/dockerfile/actions/workflows/main.yml/badge.svg)](https://github.com/asottile/dockerfile/actions/workflows/main.yml)
[![pre-commit.ci status](https://results.pre-commit.ci/badge/github/asottile/dockerfile/main.svg)](https://results.pre-commit.ci/latest/github/asottile/dockerfile/main)

dockerfile
==========

The goal of this repository is to provide a wrapper around
[docker/docker](https://github.com/docker/docker)'s parser for dockerfiles.


## python library

### Installation

This project uses [setuptools-golang](https://github.com/asottile/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.

```python
>>> 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.

```python
>>> 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.

```python
>>> 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](https://godoc.org/github.com/asottile/dockerfile)

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/asottile/dockerfile",
    "name": "dockerfile",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": "",
    "keywords": "",
    "author": "Anthony Sottile",
    "author_email": "asottile@umich.edu",
    "download_url": "https://files.pythonhosted.org/packages/54/94/754d7d016f4fbbadcd280b2f99fb9b86567ef9094b241affa40c75083fe4/dockerfile-3.3.1.tar.gz",
    "platform": null,
    "description": "[![build status](https://github.com/asottile/dockerfile/actions/workflows/main.yml/badge.svg)](https://github.com/asottile/dockerfile/actions/workflows/main.yml)\n[![pre-commit.ci status](https://results.pre-commit.ci/badge/github/asottile/dockerfile/main.svg)](https://results.pre-commit.ci/latest/github/asottile/dockerfile/main)\n\ndockerfile\n==========\n\nThe goal of this repository is to provide a wrapper around\n[docker/docker](https://github.com/docker/docker)'s parser for dockerfiles.\n\n\n## python library\n\n### Installation\n\nThis project uses [setuptools-golang](https://github.com/asottile/setuptools-golang)\nwhen built from source.  To build from source you'll need a go compiler.\n\nIf you're using linux and sufficiently new pip (>=8.1) you should be able to\njust download prebuilt manylinux1 wheels.\n\n```\npip install dockerfile\n```\n\n### Usage\n\nThere's three api functions provided by this library:\n\n#### `dockerfile.all_cmds()`\n\nList all of the known dockerfile cmds.\n\n```python\n>>> dockerfile.all_cmds()\n('add', 'arg', 'cmd', 'copy', 'entrypoint', 'env', 'expose', 'from', 'healthcheck', 'label', 'maintainer', 'onbuild', 'run', 'shell', 'stopsignal', 'user', 'volume', 'workdir')\n```\n\n#### `dockerfile.parse_file(filename)`\n\nParse a Dockerfile by filename.\nReturns a `tuple` of `dockerfile.Command` objects representing each layer of\nthe Dockerfile.\nPossible exceptions:\n- `dockerfile.GoIOError`: The file could not be opened.\n- `dockerfile.GoParseError`: The Dockerfile was not parseable.\n\n```python\n>>> pprint.pprint(dockerfile.parse_file('testfiles/Dockerfile.ok'))\n(Command(cmd='from', sub_cmd=None, json=False, original='FROM ubuntu:xenial', start_line=1, flags=(), value=('ubuntu:xenial',)),\n Command(cmd='cmd', sub_cmd=None, json=True, original='CMD [\"echo\", \"hi\"]', start_line=2, flags=(), value=('echo', 'hi')))\n```\n\n#### `dockerfile.parse_string(s)`\n\nParse a dockerfile using a string.\nReturns a `tuple` of `dockerfile.Command` objects representing each layer of\nthe Dockerfile.\nPossible exceptions:\n- `dockerfile.GoParseError`: The Dockerfile was not parseable.\n\n```python\n>>> dockerfile.parse_string('FROM ubuntu:xenial')\n(Command(cmd='from', sub_cmd=None, json=False, original='FROM ubuntu:xenial', start_line=1, flags=(), value=('ubuntu:xenial',)),)\n```\n\n## go library\n\nSlightly more convenient than the api provided by docker/docker?  Might not be\nterribly useful -- the main point of this repository was a python wrapper.\n\n### Installation\n\n```\ngo get github.com/asottile/dockerfile\n```\n\n### Usage\n\n[godoc](https://godoc.org/github.com/asottile/dockerfile)\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Parse a dockerfile into a high-level representation using the official go parser.",
    "version": "3.3.1",
    "project_urls": {
        "Homepage": "https://github.com/asottile/dockerfile"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "46c8bbc9cbfba6943a422b3c72a6e862665d7d811aed882fe2f0698cf6b2f008",
                "md5": "c2ebe2cc079a7a207aba232f337c6266",
                "sha256": "c222ee8b26017df0d9c5dcb9c4e02452f508137fc89e214758f68d57c50f5d2a"
            },
            "downloads": -1,
            "filename": "dockerfile-3.3.1-cp38-abi3-macosx_12_0_x86_64.whl",
            "has_sig": false,
            "md5_digest": "c2ebe2cc079a7a207aba232f337c6266",
            "packagetype": "bdist_wheel",
            "python_version": "cp38",
            "requires_python": ">=3.8",
            "size": 1995184,
            "upload_time": "2023-09-05T14:07:40",
            "upload_time_iso_8601": "2023-09-05T14:07:40.101329Z",
            "url": "https://files.pythonhosted.org/packages/46/c8/bbc9cbfba6943a422b3c72a6e862665d7d811aed882fe2f0698cf6b2f008/dockerfile-3.3.1-cp38-abi3-macosx_12_0_x86_64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "97f5ae500b918d6cf4229f26ab40bfec06cad0af5425dd471e747c4fea26d0c9",
                "md5": "14c74940bce2af293bda4989bc0c3d39",
                "sha256": "93bc503ed34dbbb52214753c560942f59686b3f26d0ed392d6b48fa3c238c0b1"
            },
            "downloads": -1,
            "filename": "dockerfile-3.3.1-cp38-abi3-macosx_13_0_arm64.whl",
            "has_sig": false,
            "md5_digest": "14c74940bce2af293bda4989bc0c3d39",
            "packagetype": "bdist_wheel",
            "python_version": "cp38",
            "requires_python": ">=3.8",
            "size": 1883989,
            "upload_time": "2023-09-05T14:06:40",
            "upload_time_iso_8601": "2023-09-05T14:06:40.055315Z",
            "url": "https://files.pythonhosted.org/packages/97/f5/ae500b918d6cf4229f26ab40bfec06cad0af5425dd471e747c4fea26d0c9/dockerfile-3.3.1-cp38-abi3-macosx_13_0_arm64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "ad6029cac20ce5d96022d0976cf562f4f28f18a224cd95e7a4558b9fd56ee08c",
                "md5": "54eae8029f9cbd148fd28b2a832e88e3",
                "sha256": "16a0c353e8d41dfedcbbb39d2c3e911ed5379269ee9fddd7f2fd7dc8d43c957e"
            },
            "downloads": -1,
            "filename": "dockerfile-3.3.1-cp38-abi3-manylinux_2_5_x86_64.manylinux1_x86_64.whl",
            "has_sig": false,
            "md5_digest": "54eae8029f9cbd148fd28b2a832e88e3",
            "packagetype": "bdist_wheel",
            "python_version": "cp38",
            "requires_python": ">=3.8",
            "size": 1996537,
            "upload_time": "2023-09-05T13:56:47",
            "upload_time_iso_8601": "2023-09-05T13:56:47.721539Z",
            "url": "https://files.pythonhosted.org/packages/ad/60/29cac20ce5d96022d0976cf562f4f28f18a224cd95e7a4558b9fd56ee08c/dockerfile-3.3.1-cp38-abi3-manylinux_2_5_x86_64.manylinux1_x86_64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "1bc03acb22254f005c9a1c90a26b95a60ac21bd7dd54058d59d34ba8638f0913",
                "md5": "ea27199bf9559bc18ef21c49092729a7",
                "sha256": "af88c99a1366622a288b663a660159b1e2c599bcad094563af7bbc3a1be3035f"
            },
            "downloads": -1,
            "filename": "dockerfile-3.3.1-cp38-abi3-win_amd64.whl",
            "has_sig": false,
            "md5_digest": "ea27199bf9559bc18ef21c49092729a7",
            "packagetype": "bdist_wheel",
            "python_version": "cp38",
            "requires_python": ">=3.8",
            "size": 1958147,
            "upload_time": "2023-09-05T14:07:42",
            "upload_time_iso_8601": "2023-09-05T14:07:42.023282Z",
            "url": "https://files.pythonhosted.org/packages/1b/c0/3acb22254f005c9a1c90a26b95a60ac21bd7dd54058d59d34ba8638f0913/dockerfile-3.3.1-cp38-abi3-win_amd64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "5494754d7d016f4fbbadcd280b2f99fb9b86567ef9094b241affa40c75083fe4",
                "md5": "3c7dcd948e92afacd66c9d6509734f38",
                "sha256": "4790b3d96d1018302b27661f9624d851a4b7113bce1dbb2d7509991e81a387a9"
            },
            "downloads": -1,
            "filename": "dockerfile-3.3.1.tar.gz",
            "has_sig": false,
            "md5_digest": "3c7dcd948e92afacd66c9d6509734f38",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 6858,
            "upload_time": "2023-09-05T13:52:24",
            "upload_time_iso_8601": "2023-09-05T13:52:24.244415Z",
            "url": "https://files.pythonhosted.org/packages/54/94/754d7d016f4fbbadcd280b2f99fb9b86567ef9094b241affa40c75083fe4/dockerfile-3.3.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-09-05 13:52:24",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "asottile",
    "github_project": "dockerfile",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "tox": true,
    "lcname": "dockerfile"
}
        
Elapsed time: 0.14680s