As a memo so that it will be useful when you touch Docker in the future.
You can do it from the official Composer page, but composer official
Dockerfile.
FROM php:x.xx-fpm
RUN php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" && \
php -r "if (hash_file('sha384', 'composer-setup.php') === '756890a4488ce9024fc62c56153228907f1545c228516cbf63f885e036d37e9a59d27d63f46af1d4d07ee0f76181c7d3') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;" && \
php composer-setup.php
php -r "unlink('composer-setup.php');"
This seems to have a problem like changing the Dockerfile every time the version is upgraded due to the hash value on the second line.
Dockerfile.
FROM php:x.xx-fpm
COPY COPY --from=composer /usr/bin/composer /usr/bin/composer
All you have to do is write this. When you want to specify the version of composer
xx.x /usr/bin/composer /usr/bin/composer
You can do it.
ENV COMPOSER_ALLOW_SUPERUSER=1
If is specified, installation as root is permitted.
Recommended Posts