testcontainers-go
testcontainers-go copied to clipboard
Feature request: Enable using stdin when starting docker compose
It would be a nice feature if one can use stdin to inject a docker compose file on the fly instead of using a file path. Docker Compose supports this. Wenn giving -
as filename to command line option -f
docker compose reads the configuration from stdin.
Maybe somewhere here this can be done (but I am not good enough to make an acceptable pull request).
Hello! A possible solution you can use today is to write your io.Writer
to a temporary file and pass it to Compose.
content := []byte("temporary file's content")
dir, err := ioutil.TempDir("", "example")
if err != nil {
log.Fatal(err)
}
defer os.RemoveAll(dir) // clean up
tmpfn := filepath.Join(dir, "tmpfile")
if err := ioutil.WriteFile(tmpfn, content, 0666); err != nil {
log.Fatal(err)
}
tmpfn.Name()
can be passed to NewLocalDockerCompose
Let me know if it works for you!
This works and is ok for me but reading from stdin would be a little bit nicer and cleaner. ;-) Thanks in advance.
@normanjaeckel I added a comment in https://github.com/testcontainers/testcontainers-go/pull/457, which asks for delaying the review of #457 after the revamp of the docker-compose module in #476 takes place
@normanjaeckel I created #2509 to support passing an io.Reader to the compose API. That will allow you to generate the compose files on the fly and just pass the readers. Do you think this is enough for you?
Thanks!
Sounds good. I do not have time for now to check this again but I thank you very much for the follow up.