asottile / dockerfile

Parse a dockerfile into a high-level representation using the official go parser
MIT License
101 stars 19 forks source link

Upgrade buildkit version and support heredocs syntax #174

Open roi-orca opened 1 year ago

roi-orca commented 1 year ago

Support heredocs syntax and add them to the command output to consume it. Currently instructions with heredocs syntax break the parsing (added undefined commands to the output) https://docs.docker.com/engine/reference/builder/#here-documents https://www.docker.com/blog/introduction-to-heredocs-in-dockerfiles/ Thanks!

roi-orca commented 11 months ago

@asottile

asottile commented 11 months ago

@roi-orca

duaraghav8 commented 4 weeks ago

@asottile @roi-orca Hey guys. Thanks for this project, really helpful!

I just ran into this issue myself. Any plans on resolving this soon? I see an open PR to upgrade buildkit version, so wanted to check if if you're going to be merging soon.

ATM, this ends up parsing the shell commands inside as separate Commands

>>> print(run)
RUN <<EOF
source $HOME/.bashrc && echo $HOME
EOF

>>> t = dockerfile.parse_string(run)

>>> t
(Command(cmd='RUN', sub_cmd=None, json=False, original='RUN <<EOF', start_line=1, end_line=1, flags=(), value=('<<EOF',)), Command(cmd='source', sub_cmd=None, json=False, original='source $HOME/.bashrc && echo $HOME', start_line=2, end_line=2, flags=(), value=('',)), Command(cmd='EOF', sub_cmd=None, json=False, original='EOF', start_line=3, end_line=3, flags=(), value=('',)))

Thanks

asottile commented 1 week ago

I don't have any plans -- the dependabot PR doesn't really mean anything as it was auto generated. if a test is added and the version is bumped then I can review it and release it but I'm not going to bump the version just to bump it unless there's a demonstrated reason to do so