I have an AWS pipeline established with an EC2 instance deploying a Laravel application on to it. A new package was required that needs PHP7.4.
What I’m trying to do:
Simply update the PHP version used within my pipeline which is accepted in the AWS guideline.
What steps I’ve taken:
I updated my buildspec.yml
file to:
runtime-versions:
php: 7.4
However, I end up with the following error in the log:
What I’ve tried:
I added pre-build commands to update the repositories (as below)
pre_build:
run-as: ec2-user
commands:
- apt-get update
- apt-get upgrade -y
- apt-get install -y php7.4-cli php7.4-zip
- phpenmod zip
Essentially, it looks like the instance cannot find the version of PHP. Has anyone encountered this before and if so, how can I update the version without starting from scratch?
2
Answers
There is no php 7.4 runtime in CodeBuild Linux curated images. I have requested a document update via GitHub link at bottom of page [1].
For your use case, I would recommend to update the Image of Environment to custom image ‘php:7.4.3-cli’ which is hosted on Dockerhub to use this image as your build container.
I tested this with a simple buildspec:
Result:
Ref:
[1] https://docs.aws.amazon.com/codebuild/latest/userguide/build-env-ref-available.html
You can use php 7.4 in build images
Amazon Linux 2 standard:3.0
andUbuntu standard:4.0
for more details follow the link below.https://docs.aws.amazon.com/codebuild/latest/userguide/build-env-ref-available.html