dnephin / dobi

A build automation tool for Docker applications
https://dnephin.github.io/dobi/
Apache License 2.0
311 stars 36 forks source link

Support variables interpolation for mount.bind #113

Closed OnkelTem closed 6 years ago

OnkelTem commented 6 years ago

According to documentation variables interpolation isn't supported. I wonder why this is so?

dnephin commented 6 years ago

Since mount.bind is a relative path on the host I haven't found a use case yet that required it to support variables yet. I've been trying to only add variables to fields as they are needed.

Do you have a use case that requires it to support variables?

OnkelTem commented 6 years ago

Yes, sure. Imagine that git clone someurl <project> command is wrapped into a docker container. So that you could run it with random destination.

Here comes two problems:

1) There is no way to pass <project> directly, instead we should use an environment variable:

$ PROJECT=project dobi fetch-project

2) It's not gonna interpolate that:

  mount=project-destination
    bind: ./projects/${PROJECT}
    path: /workdir

P.S. Note that docker-compose suffers from the same limitation. They don't have any documentation about what is allowed for interpolation and what is not. My trials show that it doesn't interpolate volume's local paths.

dnephin commented 6 years ago

I've updated this issue to be a feature request. Would you be interested in adding it? The changes needs to be made here:

https://github.com/dnephin/dobi/blob/692a02f32162d8e59894c8c9a2f181b1b74ec714/config/mount.go#L98-L112

by adding another resolver.Resolve. The resolved value would need to be passed to fs.ExpandUser() before storing it on conf.Bind.

and the docs are here: https://github.com/dnephin/dobi/blob/692a02f32162d8e59894c8c9a2f181b1b74ec714/docs/source/variables.rst

OnkelTem commented 6 years ago

That's great!

Daniel, do you mean that I can update the docs?

dnephin commented 6 years ago

I'm asking if you would be interested in making the code change, and also update the docs.

dnephin commented 6 years ago

This is in 0.11