Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow Passing in Context as io.ReadCloser #110

Closed
ClaytonNorthey92 opened this issue Oct 30, 2019 · 3 comments · Fixed by #113
Closed

Allow Passing in Context as io.ReadCloser #110

ClaytonNorthey92 opened this issue Oct 30, 2019 · 3 comments · Fixed by #113

Comments

@ClaytonNorthey92
Copy link
Contributor

Description
As of now, when we allow a user to build and image from a Dockerfile, we only allow them to pass in the build context as a string, which is meant to be the path to the build context on their filesystem. Then we archive that directory before we send it to the Docker API, so it becomes a type that implements ReadCloser

I would like to allow the ability to use a ReadCloser as the context in FromDockerfile. This would allow consumers of our API to dynamically set files within the archive before sending it to the Docker API, and would be less implicit than what we do now. However, I would like to also keep our current functionality because I like the abstraction.

To Reproduce
Not a bug. No reproduction steps.

Expected behavior
I am not sure what we want the API to look like, maybe:

type FromDockerfile struct {
    Context string
    ContextArchive io.ReadCloser
    Dockerfile string
}

if the consumer sets both Context and ContextArchive we could return an error, specifying that you should only choose one or the other.

Additional context
this conversation started this idea

@ClaytonNorthey92
Copy link
Contributor Author

@gianarb @mdelapenya what do you guys think of this one?

@gianarb
Copy link
Collaborator

gianarb commented Nov 12, 2019

I like the idea @ClaytonNorthey92 and I think it is a well-known interface in Go, let's do it as you suggested! Can you also write a set of examples for both scenarios?
Thanks

@ClaytonNorthey92
Copy link
Contributor Author

Hey @gianarb thanks! Yes I will make sure I include both documentation and tests for both scenarios (by Context as a string and as an io.ReadCloser)

ClaytonNorthey92 pushed a commit to ClaytonNorthey92/testcontainers-go that referenced this issue Nov 14, 2019
resolves testcontainers#110

Added a ContextArchive attribute to the FromDockerfile struct, this
allows a user to pass in an io.Reader as the Docker build context.
A user will now be allowed to create a dynamic build in code and send it
to the build.

Added test cases for both scenarios (using a local filepath and an
archive).  Added example to README.
gianarb added a commit that referenced this issue Nov 20, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants