aio-libs / aiodocker

Python Docker API client based on asyncio and aiohttp

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add `mktar_from_directory` util

phlax opened this issue · comments

commented

Long story short

I have used aiodocker in a couple of projects, the one thing i find myself implementing is a mktar_from_directory function (or similar) to enable building an image with artefacts

my implementaion/s are very similar to the existing mktar_from_directory, im wondering if it would be helpful to PR this addition

How to reproduce

try to build an image that has artefacts

Looks like a great idea.
Would you prepare a pull request? Tests are required, they should be an easy excercise.

commented

@asvetlov does it mean that existing mktar_from_tar just needs a new arg directory and new line with t.add(directory, arcname='.') ?

Sorry, I cannot find mktar_from_tar function in the project.

I think a separate function is needed.
The function should not accept dockerfile argument but a folder (with dockerfile inside usually) to archive.

commented

the most simple implementation would be to send the entire directory/context - ideally it would be able to filter according to any .dockerignore function, but not sure how easy that is in terms of parsing/filtering

commented

Maybe use docker-py implementation with PatternMatcher for .dockerignore?

commented

sounds like a plan, but im guessing we would want to avoid a dependency, so i guess it would be a matter of cribbing it

commented

they also cribbed it from moby

I'd also suggest refactoring mktar_from_dockerfile and mktar_from_directory to be async context managers that closes the generated file automatically and use asynchronous file I/O (streaming).