Skip to content
This repository has been archived by the owner on Oct 19, 2023. It is now read-only.

Add support for php7.4 and 8.0 #533

Merged
merged 1 commit into from
Oct 6, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@
.php_cs.cache
builder/php-test.yaml
deb-package-builder/pkg/
.vscode/launch.json
workspace.code-workspace
153 changes: 153 additions & 0 deletions NOTES.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
# Notes

When using Cloud Build for `build_packages.sh`, any of the packages that are built are not saved until the build completes for a PHP version. Some of the libraries and extensions can take quite a while to build on Cloud Build - libv8, grpc, for example.

You can build those locally and upload them to the Bucket for Build Packages mentioned below and then run Cloud Build and it will create the rest in the same bucket.

## GCP Requirements

A Google Cloud Project
`gsutil` and `gcloud` installed and configured.

Permissions and APIs enabled for:
- Cloud Build
- Cloud Storage
- Bucket for Build Packages *i.e. {your-unique-id}-php-mvm-a*
- Bucket for Distributions *i.e. {your-unique-id}-gcp-php-packages*
- Container Registry
- Built Images/Containers will be tagged, uploaded and affiliated with your GCP Project ID *i.e. gcr.io/your-project-123457/php*

## Building Packages
*see README in package-builder*

## Uploading Local Packages to GCS
After building the packages locally (php, extensions, libraries), you can upload the built artifacts directly to the `*-php-mvm-a` bucket.

Navigate to the local directory where the `deb-package-builder` Docker image saved the packages that have been built, *i.e.*

```bash
cd ~/gcloud/packages/pkg
gsutil -m rsync -d -r ./ gs://{your-unique-id}-php-mvm-a/ubuntu-packages
```

## Creating the Runtime Distribution

Processes packages for each version of php, their extensions and the shared libraries from the `*-php-mvm-a` gcs bucket and bundles them into distributions in the `*-gcp-php-packages` bucket.

Distributions include: stable, unstable and one according to the build time. These are used when building the Docker images later.

**Environment Variables:**

Specify the following variables when issuing commands or add them to your
environment:

**DEB_TMP_DIR**

> Directory on host OS where packages will be downloaded
`/home/{user}/tmp/php-build`

**UBUNTU_GCS_PATH**
> Google Cloud Storage Bucket from your GC Project used while
> building packages with Cloud Build (full path)
> `gs://{your-unique-id}-php-mvm-a/ubuntu-packages`

**GCP_PACKAGE_BUCKET**
> Google Cloud Storage Bucket from your project that hosts the
> runtime distribution for stable, unstable and each build
> (collection of > deb packages) (fully qualified path)
> `gs://{your-unique-id}-gcp-php-packages`

**Parameters**
`debian` (default) OR `ubuntu`

**Steps**
```bash
cd php-docker

DEB_TMP_DIR="/home/{user}/gcloud/tmp/php-build" \
UBUNTU_GCS_PATH="gs://{your-unique-id}-php-mvm-a/ubuntu-packages" \
GCP_PACKAGE_BUCKET="{your-unique-id}-gcp-php-packages" \
./scripts/update-gcs.sh ubuntu
```
## Generating Images, Running Tests
**Environment Variables:**

**TAG**
> Unique Identifier for the built images? (latest or custom?)

**Steps**
```bash
cd php-docker
GCP_PACKAGE_BUCKET={your_unique_id}-gcp-php-packages TAG={custom-tag} GOOGLE_PROJECT_ID=your-project-123456 ./scripts/build_images.sh
```

## TODO
- Build Process (`php-docker/package-builder`)
- Scripts
- Review Changes/Additions to `functions.sh`
- [x] `download_from_git` - still needed in interim
- Libraries
- [x] Fix Packaging for librabbitmq
- [x] Remove Build of libvips, use bionic version
- Extensions
- References
- [Pagely PHP Versions and Supported Extensions](https://support.pagely.com/hc/en-us/articles/360057574951-PHP-Versions-and-Supported-Extensions-Reference)
- apcu
- [x] Enabled in php8.0
- apcu_bc
- [x] Obsolete in php8.0
- cassandra
- [x] Fix invalid symlink for libcassandra.so
- jsond/jsonc
- included natively in 7.4+
- Sodium
- [ ] Enabled and test in 7.4 and 8.0
- Phalcon
- Requires v5.0 to be released for php8 support
- [ ] PhalconTest removed for 8.0, determine how to skip/ignore
- php-80
- [ ] amqp
- [ ] Test
- [x] apcu
- [ ] cassandra
- [ ] hprose
- [ ] lua
- [ ] phalcon
- [ ] stackdriver_debugger
- [ ] Test
- [ ] Submit PR
- [ ] tcpwrap
- [ ] v8js
- [x] vips
- [x] xmlrpc - added as extension
- [x] xsl - part of xml,dom
- Tests
- Structure
- Switched to [container-structure-test](https://github.com/GoogleContainerTools/container-structure-test)
- Fix licensing tests or exclude the couple of packages causing an issue?
- [ ] php-73
- [ ] php-74
- [ ] php-80
- Cannot find the copyright files for the following libraries
- libext2fs `/usr/share/doc/libext2fs/copyright`
- libssl-dev `../libssl1.1/copyright` in `/usr/share/doc/libssl-dev/copyright`
- openssl `../libssl1.1/copyright` in `/usr/share/doc/openssl/copyright`
- Extension
- [ ] php-73
- [ ] php-74
- [ ] php-80
- Legacy Extension
- [ ] php-73
- [ ] php-74
- [ ] php-80
- Custom
- [ ] php-73
- [ ] php-74
- [ ] php-80
- Travis - check_versions
- `VersionTest.php`
- [x] Fix failures when searching for gcp-phpXX packages
- [x] Need to point to custom built artifacts, not ones affiliated with Google.
- [x] Reconfigure travis settings for testing custom build, if necessary
- nginx
- [ ] Determine how to enable `ngx_http_lua_module` for bionic nginx OR determine if using PPA `ondrej/nginx-mainline` is suitable. (*see* `php-base/nginx.conf`)
2 changes: 1 addition & 1 deletion builder/gen-dockerfile/Dockerfile.in
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# Dockerfile for PHP builder step 1
# Creates Dockerfile and .dockerignore

FROM ${PHP_71_IMAGE}
FROM ${PHP_80_IMAGE}

RUN mkdir /builder
COPY . /builder
Expand Down
2 changes: 1 addition & 1 deletion builder/gen-dockerfile/phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit bootstrap="./tests/bootstrap.php" colors="true">
<testsuites>
<testsuite>
<testsuite name="gen-dockerfile">
<directory>tests</directory>
</testsuite>
</testsuites>
Expand Down
53 changes: 15 additions & 38 deletions builder/gen-dockerfile/src/Builder/GenFilesCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,40 +58,22 @@ protected function configure()
->setName('create')
->setDescription('Create Dockerfile and .dockerignore file')
->addOption(
'php74-image',
null,
InputOption::VALUE_REQUIRED,
'The PHP 74 base image of the Dockerfile'
)
->addOption(
'php73-image',
null,
InputOption::VALUE_REQUIRED,
'The PHP 73 base image of the Dockerfile'
)
->addOption(
'php72-image',
'php80-image',
null,
InputOption::VALUE_REQUIRED,
'The PHP 72 base image of the Dockerfile'
'The PHP 80 base image of the Dockerfile'
)
->addOption(
'php71-image',
null,
InputOption::VALUE_REQUIRED,
'The PHP 71 base image of the Dockerfile'
)
->addOption(
'php70-image',
'php74-image',
null,
InputOption::VALUE_REQUIRED,
'The PHP 70 base image of the Dockerfile'
'The PHP 74 base image of the Dockerfile'
)
->addOption(
'php56-image',
'php73-image',
null,
InputOption::VALUE_REQUIRED,
'The PHP 56 base image of the Dockerfile'
'The PHP 73 base image of the Dockerfile'
)
->addOption(
'workspace',
Expand All @@ -117,32 +99,27 @@ protected function initialize(InputInterface $input, OutputInterface $output)
$output->writeln("<info>
There is no PHP runtime version specified in composer.json, or
we don't support the version you specified. Google App Engine
uses the latest 7.4.x version.
uses the latest 8.0.x version.
We recommend pinning your PHP version by running:

composer require php 7.4.* (replace it with your desired minor version)
composer require php 8.0.* (replace it with your desired minor version)

Using PHP version 7.4.x...</info>
Using PHP version 8.0.x...</info>
");
} elseif ($version === DetectPhpVersion::EXACT_VERSION_SPECIFIED) {
throw new ExactVersionException(
"An exact PHP version was specified in composer.json. Please pin your" .
"PHP version to a minor version such as '7.4.*'."
"PHP version to a minor version such as '8.0.*'."
);
}
if (substr($version, 0, 3) === '5.6') {
$this->detectedPhpVersion = '5.6';
} elseif (substr($version, 0, 3) === '7.0') {
$this->detectedPhpVersion = '7.0';
} elseif (substr($version, 0, 3) === '7.1') {
$this->detectedPhpVersion = '7.1';
} elseif (substr($version, 0, 3) === '7.2') {
$this->detectedPhpVersion = '7.2';
} elseif (substr($version, 0, 3) === '7.3') {
if (substr($version, 0, 3) === '7.3') {
$this->detectedPhpVersion = '7.3';
} else {
} elseif (substr($version, 0, 3) === '7.4') {
$this->detectedPhpVersion = '7.4';
} else {
$this->detectedPhpVersion = '8.0';
}

$yamlPath = getenv('GAE_APPLICATION_YAML_PATH')
?: self::DEFAULT_YAML_PATH;
if (file_exists($this->workspace . '/' . $yamlPath)) {
Expand Down
3 changes: 1 addition & 2 deletions builder/gen-dockerfile/src/DetectPhpVersion.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,9 @@ public static function isExactVersion($constraint)
private static function detectAvailableVersions()
{
return [
trim(file_get_contents('/opt/php80_version')),
trim(file_get_contents('/opt/php74_version')),
trim(file_get_contents('/opt/php73_version')),
trim(file_get_contents('/opt/php72_version')),
trim(file_get_contents('/opt/php71_version')),
];
}
}
Loading