Not sure if something like this is what you are looking for ... changing a bit of what you already have. My main question is: what are you trying to achieve with this part ?: '$(dirname $(find/opt -name "ruby" | grep -i bin)):$PATH'Part of the problem may be the use of single and double quotes leading to extensions.
FROM alpine:3.4
RUN PATH_TO_ADD=$(dirname $(find /opt -name "ruby" | grep -i bin)) || echo Error locating files
ENV PATH "$PATH:$PATH_TO_ADD"
source
share