ConfigTemplate with a Build container with a docke...
# 🌱|help-and-getting-started
i
Hello, My Name is Ralph and I work at Wayfair, been here before but this is a new account with my personal email. I have the following use case: Let's consider `RepoA`: I have a folder called
kafka
and inside kafka I am using a
ConfigTemplate
to define multiple Configs, one of them is a
build for a container
that references
dockerfile: ./kafka.Dockerfile
Inside the kafka folder I have my
kafka.Dockerfile
root -> [kafka] -> kafka.Dockerfile garden.yml with ConfigTemplate garden.yml with RenderTemplate When I try to use RenderTemplate from the root of the repo, it looks like I have to touch the
dockerfile
path now to be relative to the root and must now change
dockerfile: ./kafka.Dockerfile
. into
dockerfile: ./kafka/kafka.Dockerfile
Looks like it is now taking the relative path with respect to the root and not with respect to where the ConfigTemplate is defined, which is under kafka folder. Is this a bug or am I missing some property in config/render settings? The problem is compounded when I have
RepoB
that is including
RepoA
as a source, when I have a garden.yml on the root level of
RepoB
referencing the ConfigTemplate in
RepoA
it can't find the dockerfile as well, I can see the dockerfile under
.garden/sources/project/RepoA/kafka/kafka.Dockerfile
but it can't figure out the correct relative path... Help 🙂 Thank you.
Can we have a value in path.source to pull it from the current folder of the file? perhaps that would fix it... Is there such a variable I can use?
s
Hi @incalculable-family-77679! Thanks for writing this up. This is a limitation of Garden as things stand, but this PR adds a
${template.path}
  variable that gives you the absolute path to the directory containing the ConfigTemplate being rendered. So in your case, you could use
dockerfile: ${template.path}/kafka.Dockerfile
. https://github.com/garden-io/garden/pull/6736 It's still in review, but if it's approved and merged, I think that should address this for you.
i
Thank you @swift-garage-61180 usually we get an error that says can't use absolute path in docker file if we hardcore one, I assume this PR will also allow that?
Yesterday night I was able to get around this bug by using an indirect fix, bundling the files in exec and pulling them from there, I got this idea from a bug reported earlier which looks to have the same cause as my bug. https://github.com/garden-io/garden/issues/5201 In my case I didn't have a dynamic docker file but still the same workaround of using exec worked, I'm guessing because exec will use its own base path so things work as expected.
But seems to me that a correct fix would be for RenderTemplate to use the base path of the template rather than it's own base path, otherwise it won't work without always using the templatePath... What do you think? Or at least a boolean value in ConfigTemplate that tells RenderTemplate to use its own base path. Thank you so much for looking into this
b
Creative approach! Glad that my comment helped 🙂 👍
As we are a little low on resources right before christmas, it's unlikely that we can finalise a solution for the problem this year. Thank you for the report though!
Glad you can work around this for now using the exec approach.
@incalculable-family-77679 It would be extremely helpful if you open a github issue and include a small example project that works stand-alone and demonstrates the issue in there, e.g. a
project.garden.yml
snippet or a zip file. For other users it would be really helpful too if you can also include an outline of your work around in that issue.
i
Thank you, give me sometime too, I can deliver this issue and perhaps a PR as a fix the beginning of the year, as things are hectic for us around Christmas. I'd like to see if it's easy to contribute.
b
No worries, take your time. Thank you so much, also for the willingness to dig into the code! It might be that it's not trivial, but definitely happy to provide guidance even in a WIP PR!
i
message has been deleted
Sounds good. Happy holidays
b
For you too 🎅
s
@incalculable-family-77679 We've got a half-finished draft PR that addresses this, I'm hoping to find time to wrap it up in the next week or two. I'll keep you posted.
2 Views