Composer extensions installation
Asked by Ivo:

Hello guys,   

I need to install several docker dependencies for composer with my pipeline but I'm getting the errors below:   

+ composer install  
Installing dependencies from lock file (including require-dev)  
Verifying lock file contents can be installed on current platform.  
Your lock file does not contain a compatible set of packages. Please run composer update.  
`- Root `[composer.json](https://bitbucket.org/payneticsteam/clear-bank-integration-service/src/3263196ab3f5a0e6150b8561a872516871e5822d/composer.json)` requires PHP extension ext-amqp * but it is missing from your system. Install or enable PHP's amqp extension.`  
Problem 2  
- Root [composer.json](https://bitbucket.org/payneticsteam/clear-bank-integration-service/src/3263196ab3f5a0e6150b8561a872516871e5822d/composer.json) requires PHP extension ext-bcmath * but it is missing from your system. Install or enable PHP's bcmath extension.  
Problem 3  
- php-amqplib/php-amqplib is locked to version v3.6.2 and an update of this package was not requested.  
- php-amqplib/php-amqplib v3.6.2 requires ext-sockets * -> it is missing from your system. Install or enable PHP's sockets extension.  
Problem 4  
- php-amqplib/php-amqplib v3.6.2 requires ext-sockets * -> it is missing from your system. Install or enable PHP's sockets extension.  
- php-amqplib/rabbitmq-bundle 2.16.0 requires php-amqplib/php-amqplib ^2.12.2|^3.0 -> satisfiable by php-amqplib/php-amqplib[v3.6.2].  
- php-amqplib/rabbitmq-bundle is locked to version 2.16.0 and an update of this package was not requested.  
To enable extensions, verify that they are enabled in your .ini files:  
- /usr/local/etc/php/conf.d/docker-fpm.ini  
- /usr/local/etc/php/conf.d/docker-php-ext-sodium.ini  
You can also run `php --ini` in a terminal to see which files are used by PHP in CLI mode.  

``Alternatively, you can run Composer with `--ignore-platform-req=ext-amqp --ignore-platform-req=ext-bcmath --ignore-platform-req=ext-sockets` to temporarily ignore these required extensions.``

<br />

I use php:8.2.20-fpm-bullseye because there is php 8.2 support. What I did so far is to try the installation with:  

apt install php8.2-amqp  
docker-php-ext-install amqp  

How can I include and enable this dependencies to my pipeline?  

pipeline script part:   
script:  
- apt-get update \&\& apt-get install -y php8.2-dev php8.2-amqp libfreetype6-dev libjpeg62-turbo-dev libpng-dev \&\& docker-php-ext-install bcmath sockets  
- curl -sS <https://getcomposer.org/installer> \| php -- --install-dir=/usr/local/bin --filename=composer  
- composer self-update  
- composer install  
- ./vendor/bin/phpunit test  
caches:  
- composer  

<br />

Regards,


Answers:
author: Theodora Boudale
body: Hi Ivo and welcome to the community!

Pipelines builds run in Docker containers. For every step of your build, a Docker container starts (the build container) using the image you have specified in your bitbucket-pipelines.yml file. The repo is cloned in this container, and then the commands of the step's script are executed.

Since you are using php:8.2.20-fpm-bullseye, the Docker container where your build runs uses the following Dockerhub image:

* <https://hub.docker.com/layers/library/php/8.2.20-fpm-bullseye/images/sha256-43ea489cd69928ce1969607a2f4650d1f22943a2ebea9b97ccaed7b2c7958009?context=explore>

This Docker image is based on Debian 11 (bullseye), so the question is how you install these extensions in a Docker container that uses Debian 11.

I suggest reaching out to a PHP-specific forum for help with how to install these extensions in Debian 11.

You can then debug your pipeline locally using the following guide:

* <https://confluence.atlassian.com/bbkb/troubleshoot-failed-bitbucket-pipelines-locally-with-docker-1318882094.html>

When you have a command and build that works locally following this guide, it should work in Pipelines as well.

Kind regards,  
Theodora


Tags: bitbucket-cloud

bitbucket-pipelines

cloud