skip to Main Content

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:

enter image description here

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


  1. 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:

    version: 0.2
    
    phases:
      install:
        commands:
          - php -v
      build:
        commands:
          - date
    

    Result:

    [Container] 2020/03/05 14:49:57 Entering phase INSTALL
    [Container] 2020/03/05 14:49:57 Running command php -v
    PHP 7.4.3 (cli) (built: Feb 26 2020 12:05:30) ( NTS )
    Copyright (c) The PHP Group
    Zend Engine v3.4.0, Copyright (c) Zend Technologies
    

    Ref:

    [1] https://docs.aws.amazon.com/codebuild/latest/userguide/build-env-ref-available.html

    Login or Signup to reply.
  2. You can use php 7.4 in build images Amazon Linux 2 standard:3.0 and Ubuntu standard:4.0 for more details follow the link below.

    https://docs.aws.amazon.com/codebuild/latest/userguide/build-env-ref-available.html

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search