Dockerfile RUN command returns The command ‘/bin/sh -c … ;fi’ returned a non-zero code: 1

I’m running this command inside of my Dockerfile via the RUN command. This seems like it should work but errors instead.

RUN if [ ! -d "../vendor" ]; then \
curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/bin/ --filename=composer && \ composer install && rm $(which composer) \
;fi
view raw Dockerfile hosted with ❤ by GitHub

I haven’t spent the time to figure out exactly why, so to fix (by fix i mean hack) this I just simply created two RUN commands like this:

RUN if [ ! -d "$PWD/vendor" ]; then \
curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/bin/ --filename=composer \
;fi
RUN if [ ! -d "$PWD/vendor" ]; then \
composer install && rm $(which composer) \
;fi
view raw Dockerfile hosted with ❤ by GitHub

I could probably check to see if the composer package is installed instead of checking if the directory is there when running the composer download shell command.

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.