I'd like to conditionally set some ENV vars in my Dockerfile based on certain build ARGs. For one reason or another, the ENV var doesn't map directly to the actual build ARG i.e. I can NOT do the following:
ARG myvar
ENV MYVAR $MYVAR
It's complex enough a mapping that I can't just do, like, "prefix-${$MYVAR}", or whatever, either.
I'm aware of just using a shell command with EXPORT instead (and then having access to if statements), but exporting the environmental variable this way won't persist across containers the way I need to. If the only solution is to just repeatedly prefix the needed env for every RUN/CMD I need it for (and all the logic needed to get there), then I would accept that.
I'm also aware of this answer Conditional ENV in Dockerfile, which does have one solution where a (essentially) ternary is used to trigger a certain ENV value, but because my situation is more complex, I can't just use that given solution.
Is there a way to write "logic" inside Dockerfiles, while still having access to Docker commands like ENV?
Any help would be really appreciated!
PS.
This is a Dockerfile to build a Node image, so my last few steps look basically like
RUN npm run build
CMD ["npm", "run", "start"]