Hi all! In our Python monorepo we have several app...
# general
c
Hi all! In our Python monorepo we have several apps that we package as docker images, in several layers. Since they are very similar, I created a macro to handle that, and use parameters to specify things that are specific to each app. Almost all is well. It's a bit tricky when it comes to file dependencies, because these are sent as parameters and it's not enough to add them as dependencies of the image target, but need to be part of a COPY directive too. And here the issue is that I don't know if I can get the file target details from inside the macro. Currently I am basically repeating the declaration of the files, but that is not ideal. What I'd like to be able to do is to iterate through the dependencies and read their source field, which I can then use to dynamically create COPY directives. Is that possible? Is there an alternative solution? Was my explanation clear enough? Thanks in advance!
Hmm, to answer myself, I can use the parameters to generate the file targets too, then I have all the info. But I wonder, is this a proper use of macros?
b
BUILD files (and macros) are normal Python code, so passing in parameters that get transformed into
COPY
statements and extra
dependencies=[...]
values seems good to me. We do things like that with our use of pants too
🙏🏽 1