My codebuild has been working well till today. It's failing with the following errors:
Reading state information...
E: Unable to locate package php7.1
E: Couldn't find any package by regex 'php7.1'
E: Unable to locate package php7.1-xml
E: Couldn't find any package by regex 'php7.1-xml'
E: Unable to locate package php7.1-xmlrpc
E: Couldn't find any package by regex 'php7.1-xmlrpc'
E: Unable to locate package php7.1-zip
E: Couldn't find any package by regex 'php7.1-zip'
E: Unable to locate package php7.1-mysql
E: Couldn't find any package by regex 'php7.1-mysql'
E: Unable to locate package php7.1-mbstring
E: Couldn't find any package by regex 'php7.1-mbstring'
E: Unable to locate package php7.1-mcrypt
E: Couldn't find any package by regex 'php7.1-mcrypt'
E: Unable to locate package php7.1-gd
what could be the issue? Please note that the builds have been working well with this setup. There was no change in the buildspec file.
This is what I tried:
version: 0.2
phases:
install:
commands:
- |
apt-get install -y software-properties-common
export DEBIAN_FRONTEND=noninteractive
apt-get update
LC_ALL=C.UTF-8 add-apt-repository -y ppa:ondrej/php
version: 0.2
phases:
install:
commands:
- |
apt-get install -y software-properties-common
export DEBIAN_FRONTEND=noninteractive
apt-get update
LC_ALL=C.UTF-8 add-apt-repository -y ppa:ondrej/php
apt-get update
apt-get install -y php7.1 \
php7.1-xml \
php7.1-xmlrpc \
php7.1-zip \
php7.1-mysql \
php7.1-mbstring \
php7.1-mcrypt \
php7.1-gd \
php7.1-opcache \
php7.1-dom \
php7.1-bcmath \
php7.1-curl \
unzip \
nasm
I expected the php packages to be installed normally as it has been the case.
This was an issue with the base image I was using, which was on Ubuntu 14.04. Ubuntu 14.04 LTS ended support as of April 2019, and from the ondrej repository there is no repo folder that matches ubuntu 14.04.
I had to switch my base image to aws/codebuild/standard:2.0, which fixed my problem.
When you switch to aws/codebuild/standard:2.0 it provides you with Ubuntu 18. You also have to supply a runtime like
phases:
install:
runtime-versions:
php: 7.3
I found that AWS put their PHP ini in /usr/local/etc/php/conf.d/ but when you install extensions the ini gets put into /etc/php/7.3/cli/php.ini - so you have to join the non-standard to the standard so the extension files are found.
This can be solved by adding the standard path to an ini file as follows:
touch /usr/local/etc/php/conf.d/extra_config.ini
echo extension_dir="/usr/lib/php/20180731/" >> /usr/local/etc/php/conf.d/extra_config.ini
echo extension=gd.so >> /usr/local/etc/php/conf.d/extra_config.ini
Running command php -m
The final buildspec.yml looks like this (with some debug so you can see the before and after, and the contents of the extra_config.ini:
phases:
install:
runtime-versions:
php: 7.3
commands:
- php -v
- php -m
- lsb_release -a
- LC_ALL=C.UTF-8 add-apt-repository -y ppa:ondrej/php
- apt-get update -y
- apt-get install -y php7.3-gd php7.3-xdebug
- ls /usr/lib/php/20180731
- touch /usr/local/etc/php/conf.d/extra_config.ini
- "echo extension_dir=\"/usr/lib/php/20180731/\" >> /usr/local/etc/php/conf.d/extra_config.ini"
- "echo extension=gd.so >> /usr/local/etc/php/conf.d/extra_config.ini"
- "echo zend_extension=xdebug.so >> /usr/local/etc/php/conf.d/extra_config.ini"
- cat /usr/local/etc/php/conf.d/extra_config.ini
- php -m
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With