I have a multi-stage build sharing single ARG (to DRY out path) between stages. Something like this:
ARG BUILD_DIR=/build
FROM alpine:latest as build
RUN apk add --no-cache gcc musl-dev
WORKDIR $BUILD_DIR
RUN echo -e '\n\
#include <stdio.h>\n\
int main (void)\n\
{ puts ("Hello, World!");}'\
>> hello.c
RUN cc -o hello hello.c
FROM alpine:latest
COPY --from=build $BUILD_DIR/hello /app
CMD ["/app"]
It gets built with no problem locally, but automated Docker Hub build fails with the following error:
Step 4/9 : WORKDIR $BUILD_DIR cannot normalize nothing
I am curious, what can cause the problem (too old build engine on Docker Hub?). And is there a better workaround than just hard-coding path in Dockerfile?