I am trying to run my laravel app on docker. Its an old app I am trying to resurface and was built on php 7.1
Locally, it works fine.
On Docker, I used the following config:
FROM php:7.1-fpm-alpine
RUN docker-php-ext-install pdo pdo_mysql sockets
RUN curl -sS https://getcomposer.org/installer | php -- \
--install-dir=/usr/local/bin --filename=composer
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer
WORKDIR /app
COPY . .
RUN composer install
Its not allowing me to install composer and gives the following error:
[stage-0 7/7] RUN composer install: #0 0.221 Composer 2.3.0 dropped support for PHP <7.2.5 and you are running 7.1.33, please upgrade PHP or use Composer 2.2 LTS via "composer self-update --2.2". Aborting.
I tried doing RUN composer self-update --2.2
instead but its the same error.
Can anyone tell me how to go install this specific version of composer on docker.
Thank you
CodePudding user response:
All composer releases are accessible via their GitHub repository, including the composer.phar
binary archive files. Instead of instaling the latest version from getcomposer.org, just use a version that works with your PHP version.
The composer.phar
for composer 2.2.9 can be found here: https://github.com/composer/composer/releases/tag/2.2.9
CodePudding user response:
Composer installer permit to choose the version:
Get the installer
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" php -r "if (hash_file('sha384', 'composer-setup.php') === '55ce33d7678c5a611085589f1f3ddf8b3c52d662cd01d4ba75c0ee0459970c2200a51f492d557530c71c15d8dba01eae') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
or use cURL to get the installer.
Install version
php composer-setup.php --2.2