[FIX] Composer.phar Installer auto-version SHA

Problem: against best practice, the composer.phar installer download checksum was hard coded, but the latest version of the installer was downloaded, resulting in the checksum often not matching the package; build would ultimately fail.
Solution: grab the latest checksum value along with the latest installer package.

More instructions: https://getcomposer.org/doc/faqs/how-to-install-composer-programmatically.md
This commit is contained in:
aschonbe
2017-03-14 15:07:16 -04:00
committed by GitHub
parent 93492db9dd
commit ce70c0ffc9

View File

@@ -5,7 +5,6 @@ MAINTAINER ngineered <support@ngineered.co.uk>
ENV php_conf /usr/local/etc/php-fpm.conf ENV php_conf /usr/local/etc/php-fpm.conf
ENV fpm_conf /usr/local/etc/php-fpm.d/www.conf ENV fpm_conf /usr/local/etc/php-fpm.d/www.conf
ENV php_vars /usr/local/etc/php/conf.d/docker-vars.ini ENV php_vars /usr/local/etc/php/conf.d/docker-vars.ini
ENV composer_hash 55d6ead61b29c7bdee5cccfb50076874187bd9f21f65d8991d46ec5cc90518f447387fb9f76ebae1fbbacf329e583e30
ENV NGINX_VERSION 1.11.10 ENV NGINX_VERSION 1.11.10
@@ -172,8 +171,9 @@ RUN echo @testing http://nl.alpinelinux.org/alpine/edge/testing >> /etc/apk/repo
mkdir -p /var/www/app && \ mkdir -p /var/www/app && \
mkdir -p /run/nginx && \ mkdir -p /run/nginx && \
mkdir -p /var/log/supervisor && \ mkdir -p /var/log/supervisor && \
EXPECTED_COMPOSER_SIGNATURE=$(wget -q -O - https://composer.github.io/installer.sig) && \
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" && \ php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" && \
php -r "if (hash_file('SHA384', 'composer-setup.php') === '${composer_hash}') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;" && \ php -r "if (hash_file('SHA384', 'composer-setup.php') === '${EXPECTED_COMPOSER_SIGNATURE}') { echo 'Composer.phar Installer verified'; } else { echo 'Composer.phar Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;" && \
php composer-setup.php --install-dir=/usr/bin --filename=composer && \ php composer-setup.php --install-dir=/usr/bin --filename=composer && \
php -r "unlink('composer-setup.php');" && \ php -r "unlink('composer-setup.php');" && \
pip install -U pip && \ pip install -U pip && \