Skip to main content

package parsing docker files

Project description

Docker parser

Docker attempts to simplify machine processing of dockerfiles. This moduel is not intended to extend docker SDK or build images, instead it attempts to parse instructions into simply manipulatable python objects, deduce state of environment in which commands are executed and allow modification of resulting dockerfile.

Instalation

pip3 install docker-parser

Usage

Print all executed RUN commands

from docker_parser import parser

with open("dockerfile") as src:
    dockerfile = parser.Parser.loads(src.read())

for cmd in dockerfile.run():
    print(cmd.arg)

dockerfile:

FROM ubuntu:20.04
ENV DEBIAN_FRONTEND=noninteractive
RUN apt update
RUN apt install -y gcc make
COPY ./src /var/tmp/
WORKDIR /var/tmp/src
RUN make

output:

apt update
apt install -y gcc make
make

for more examples refer to examples

Contributing

To contribute:

  1. Increment version in pyproject.toml
  2. Create merge request to preprod branch
  3. Once your changes are reviewed and merged, pipeline publishes new version to testpypi
  4. After verifying that changes don't break rest of the code and don't justify major release, changes will be pushed to main branch and pushed to production pypi

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

docker_parser-0.0.8.tar.gz (10.5 MB view hashes)

Uploaded Source

Built Distribution

docker_parser-0.0.8-py3-none-any.whl (9.5 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page