dockerfile


Namedockerfile JSON
Version 3.4.0 PyPI version JSON
download
home_pagehttps://github.com/asottile/dockerfile
SummaryParse a dockerfile into a high-level representation using the official go parser.
upload_time2025-01-04 20:40:55
maintainerNone
docs_urlNone
authorAnthony Sottile
requires_python>=3.9
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": null,
    "docs_url": null,
    "requires_python": ">=3.9",
    "maintainer_email": null,
    "keywords": null,
    "author": "Anthony Sottile",
    "author_email": "asottile@umich.edu",
    "download_url": "https://files.pythonhosted.org/packages/de/c9/2cdd6060f8f476c41a1638a9e1b28923fb0d9c075dffc41b13137199e207/dockerfile-3.4.0.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.4.0",
    "project_urls": {
        "Homepage": "https://github.com/asottile/dockerfile"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "a12a553b099124685f00c4cc06cda6496db02e43ca51d7b7b5dc68814c6b48be",
                "md5": "320e04f51f0bf6f578db2f79a6585118",
                "sha256": "ed33446a76007cbb3f28c247f189cc06db34667d4f59a398a5c44912d7c13f36"
            },
            "downloads": -1,
            "filename": "dockerfile-3.4.0-cp39-abi3-macosx_13_0_x86_64.whl",
            "has_sig": false,
            "md5_digest": "320e04f51f0bf6f578db2f79a6585118",
            "packagetype": "bdist_wheel",
            "python_version": "cp39",
            "requires_python": ">=3.9",
            "size": 1740573,
            "upload_time": "2025-01-04T20:49:37",
            "upload_time_iso_8601": "2025-01-04T20:49:37.128922Z",
            "url": "https://files.pythonhosted.org/packages/a1/2a/553b099124685f00c4cc06cda6496db02e43ca51d7b7b5dc68814c6b48be/dockerfile-3.4.0-cp39-abi3-macosx_13_0_x86_64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "8ebf246a02d803318131d809b13d285244e4047def667df906ad123e7d8405b2",
                "md5": "cd6310343a7a4e56a0d68e3c825db2cb",
                "sha256": "a4549d4f038483c25906d4fec56bb6ffe82ae26e0f80a15f2c0fedbb50712053"
            },
            "downloads": -1,
            "filename": "dockerfile-3.4.0-cp39-abi3-macosx_14_0_arm64.whl",
            "has_sig": false,
            "md5_digest": "cd6310343a7a4e56a0d68e3c825db2cb",
            "packagetype": "bdist_wheel",
            "python_version": "cp39",
            "requires_python": ">=3.9",
            "size": 1639801,
            "upload_time": "2025-01-04T20:49:41",
            "upload_time_iso_8601": "2025-01-04T20:49:41.173352Z",
            "url": "https://files.pythonhosted.org/packages/8e/bf/246a02d803318131d809b13d285244e4047def667df906ad123e7d8405b2/dockerfile-3.4.0-cp39-abi3-macosx_14_0_arm64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "0b352cb27f4a0a68bacde1bdbc2cd4ba8d0d5be95fca04010c7bd83caa96cd20",
                "md5": "6790f703abcba12985d2350fa70c83aa",
                "sha256": "b95102bd82e6f67c836186b51c13114aa586a20e8cb6441bde24d4070542009d"
            },
            "downloads": -1,
            "filename": "dockerfile-3.4.0-cp39-abi3-manylinux_2_5_x86_64.manylinux1_x86_64.whl",
            "has_sig": false,
            "md5_digest": "6790f703abcba12985d2350fa70c83aa",
            "packagetype": "bdist_wheel",
            "python_version": "cp39",
            "requires_python": ">=3.9",
            "size": 1663209,
            "upload_time": "2025-01-04T20:49:42",
            "upload_time_iso_8601": "2025-01-04T20:49:42.667566Z",
            "url": "https://files.pythonhosted.org/packages/0b/35/2cb27f4a0a68bacde1bdbc2cd4ba8d0d5be95fca04010c7bd83caa96cd20/dockerfile-3.4.0-cp39-abi3-manylinux_2_5_x86_64.manylinux1_x86_64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "815d3d3b83501e62f6f319db884113bab89fc02b6c29ca7004049a8144eec01e",
                "md5": "2a3a384109a2979603a15b2387ba05fa",
                "sha256": "30202187f1885f99ac839fd41ca8150b2fd0a66fac12db0166361d0c4622e71a"
            },
            "downloads": -1,
            "filename": "dockerfile-3.4.0-cp39-abi3-win_amd64.whl",
            "has_sig": false,
            "md5_digest": "2a3a384109a2979603a15b2387ba05fa",
            "packagetype": "bdist_wheel",
            "python_version": "cp39",
            "requires_python": ">=3.9",
            "size": 1809411,
            "upload_time": "2025-01-04T20:49:44",
            "upload_time_iso_8601": "2025-01-04T20:49:44.239473Z",
            "url": "https://files.pythonhosted.org/packages/81/5d/3d3b83501e62f6f319db884113bab89fc02b6c29ca7004049a8144eec01e/dockerfile-3.4.0-cp39-abi3-win_amd64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "dec92cdd6060f8f476c41a1638a9e1b28923fb0d9c075dffc41b13137199e207",
                "md5": "ecfda3a2d1ca457f388bdad72d8688c3",
                "sha256": "238bb950985c55a525daef8bbfe994a0230aa0978c419f4caa4d9ce0a37343f1"
            },
            "downloads": -1,
            "filename": "dockerfile-3.4.0.tar.gz",
            "has_sig": false,
            "md5_digest": "ecfda3a2d1ca457f388bdad72d8688c3",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9",
            "size": 7729,
            "upload_time": "2025-01-04T20:40:55",
            "upload_time_iso_8601": "2025-01-04T20:40:55.952774Z",
            "url": "https://files.pythonhosted.org/packages/de/c9/2cdd6060f8f476c41a1638a9e1b28923fb0d9c075dffc41b13137199e207/dockerfile-3.4.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-01-04 20:40:55",
    "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: 1.61730s