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

Making the default to PHP 7.2 #391

Merged
merged 9 commits into from
Dec 5, 2017
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
16 changes: 8 additions & 8 deletions builder/gen-dockerfile/src/Builder/GenFilesCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,17 +109,17 @@ 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.1.x version.
uses the latest 7.2.x version.
We recommend pinning your PHP version by running:

composer require php 7.1.* (replace it with your desired minor version)
composer require php 7.2.* (replace it with your desired minor version)

Using PHP version 7.1.x...</info>
Using PHP version 7.2.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.1.*'."
"PHP version to a minor version such as '7.2.*'."
);
}
if (substr($version, 0, 3) === '5.6') {
Expand All @@ -128,12 +128,12 @@ protected function initialize(InputInterface $input, OutputInterface $output)
} elseif (substr($version, 0, 3) === '7.0') {
$this->baseImage = $input->getOption('php70-image');
$this->detectedPhpVersion = '7.0';
} elseif (substr($version, 0, 3) === '7.2') {
$this->baseImage = $input->getOption('php72-image');
$this->detectedPhpVersion = '7.2';
} else {
} elseif (substr($version, 0, 3) === '7.1') {
$this->baseImage = $input->getOption('php71-image');
$this->detectedPhpVersion = '7.1';
} else {
$this->baseImage = $input->getOption('php72-image');
$this->detectedPhpVersion = '7.2';
}
$yamlPath = getenv('GAE_APPLICATION_YAML_PATH')
?: self::DEFAULT_YAML_PATH;
Expand Down
59 changes: 37 additions & 22 deletions builder/gen-dockerfile/tests/GenFilesCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ public function testGenFilesCommand(
'--php56-image' => 'gcr.io/google-appengine/php56:latest',
'--php70-image' => 'gcr.io/google-appengine/php70:latest',
'--php71-image' => 'gcr.io/google-appengine/php71:latest',
'--php72-image' => 'gcr.io/google-appengine/php72:latest',
];
}
if ($expectedException !== null) {
Expand Down Expand Up @@ -134,10 +135,10 @@ public function dataProvider()
'',
'/app',
'added by the php runtime builder',
'gcr.io/google-appengine/php71:latest',
'gcr.io/google-appengine/php72:latest',
["COMPOSER_FLAGS='--no-dev --prefer-dist' \\\n",
"FRONT_CONTROLLER_FILE='index.php' \\\n",
"DETECTED_PHP_VERSION='7.1' \n"
"DETECTED_PHP_VERSION='7.2' \n"
]
],
[
Expand All @@ -158,10 +159,10 @@ public function dataProvider()
'',
'/app',
'added by the php runtime builder',
'gcr.io/google-appengine/php71:latest',
'gcr.io/google-appengine/php72:latest',
["COMPOSER_FLAGS='--prefer-dist --no-dev --no-script' \\\n",
"FRONT_CONTROLLER_FILE='index.php' \\\n",
"DETECTED_PHP_VERSION='7.1' \n"
"DETECTED_PHP_VERSION='7.2' \n"
]
],
[
Expand All @@ -182,10 +183,10 @@ public function dataProvider()
'',
'/app/web',
'added by the php runtime builder',
'gcr.io/google-appengine/php71:latest',
'gcr.io/google-appengine/php72:latest',
["COMPOSER_FLAGS='--no-dev --prefer-dist' \\\n",
"FRONT_CONTROLLER_FILE='index.php' \\\n",
"DETECTED_PHP_VERSION='7.1' \\\n",
"DETECTED_PHP_VERSION='7.2' \\\n",
"IS_BATCH_DAEMON_RUNNING='true' \n",
"enable_stackdriver_integration.sh"
]
Expand All @@ -197,10 +198,10 @@ public function dataProvider()
'',
'/app/web',
'added by the php runtime builder',
'gcr.io/google-appengine/php71:latest',
'gcr.io/google-appengine/php72:latest',
["COMPOSER_FLAGS='--no-dev --prefer-dist' \\\n",
"FRONT_CONTROLLER_FILE='index.php' \\\n",
"DETECTED_PHP_VERSION='7.1' \\\n",
"DETECTED_PHP_VERSION='7.2' \\\n",
"IS_BATCH_DAEMON_RUNNING='true' \n",
"enable_stackdriver_integration.sh --individual"
]
Expand All @@ -223,7 +224,7 @@ public function dataProvider()
'',
'/app/web',
'added by the php runtime builder',
'gcr.io/google-appengine/php71:latest',
'gcr.io/google-appengine/php72:latest',
[],
'\\Google\\Cloud\\Runtimes\\Builder\\Exception\\GoogleCloudVersionException'
],
Expand All @@ -234,7 +235,7 @@ public function dataProvider()
'',
'/app/web',
'added by the php runtime builder',
'gcr.io/google-appengine/php71:latest',
'gcr.io/google-appengine/php72:latest',
[],
'\\Google\\Cloud\\Runtimes\\Builder\\Exception\\GoogleCloudVersionException'
],
Expand All @@ -245,7 +246,7 @@ public function dataProvider()
'',
'/app/web',
'added by the php runtime builder',
'gcr.io/google-appengine/php71:latest',
'gcr.io/google-appengine/php72:latest',
[],
'\\Google\\Cloud\\Runtimes\\Builder\\Exception\\GoogleCloudVersionException'
],
Expand All @@ -256,7 +257,7 @@ public function dataProvider()
'',
'/app/web',
'added by the php runtime builder',
'gcr.io/google-appengine/php71:latest',
'gcr.io/google-appengine/php72:latest',
[],
'\\Google\\Cloud\\Runtimes\\Builder\\Exception\\GoogleCloudVersionException'
],
Expand Down Expand Up @@ -286,14 +287,27 @@ public function dataProvider()
"DETECTED_PHP_VERSION='7.0' \n"
]
],
[
// PHP 7.1
__DIR__ . '/test_data/php71',
null,
'',
'/app',
'added by the php runtime builder',
'gcr.io/google-appengine/php71:latest',
["COMPOSER_FLAGS='--no-dev --prefer-dist' \\\n",
"FRONT_CONTROLLER_FILE='index.php' \\\n",
"DETECTED_PHP_VERSION='7.1' \n"
]
],
[
// values on env_variables
__DIR__ . '/test_data/values_only_on_env',
null,
'',
'/app',
'added by the php runtime builder',
'gcr.io/google-appengine/php71:latest',
'gcr.io/google-appengine/php72:latest',
[
"WHITELIST_FUNCTIONS='exec' \\\n",
"FRONT_CONTROLLER_FILE='app.php'",
Expand All @@ -313,7 +327,7 @@ public function dataProvider()
'',
'/app',
'added by the php runtime builder',
'gcr.io/google-appengine/php71:latest',
'gcr.io/google-appengine/php72:latest',
[],
'\\Google\\Cloud\\Runtimes\\Builder\\Exception\\MissingDocumentRootException'
],
Expand All @@ -324,7 +338,7 @@ public function dataProvider()
'',
'/app',
'added by the php runtime builder',
'gcr.io/google-appengine/php71:latest',
'gcr.io/google-appengine/php72:latest',
[
"WHITELIST_FUNCTIONS='exec' \\\n",
"FRONT_CONTROLLER_FILE='app.php'",
Expand All @@ -345,7 +359,7 @@ public function dataProvider()
'',
'/app',
'added by the php runtime builder',
'gcr.io/google-appengine/php71:latest',
'gcr.io/google-appengine/php72:latest',
["FRONT_CONTROLLER_FILE='app.php' \\\n"]
],
[
Expand All @@ -355,7 +369,7 @@ public function dataProvider()
'my.yaml',
'/app',
'added by the php runtime builder',
'gcr.io/google-appengine/php71:latest'
'gcr.io/google-appengine/php72:latest'
],
[
// Overrides baseImage
Expand All @@ -364,11 +378,12 @@ public function dataProvider()
'--php56-image' => 'gcr.io/php-mvm-a/php56:latest',
'--php70-image' => 'gcr.io/php-mvm-a/php70:latest',
'--php71-image' => 'gcr.io/php-mvm-a/php71:latest',
'--php72-image' => 'gcr.io/php-mvm-a/php72:latest',
],
'',
'/app',
'added by the php runtime builder',
'gcr.io/php-mvm-a/php71:latest'
'gcr.io/php-mvm-a/php72:latest'
],
[
// Has document_root set
Expand All @@ -377,7 +392,7 @@ public function dataProvider()
'',
'/app/web',
'added by the php runtime builder',
'gcr.io/google-appengine/php71:latest'
'gcr.io/google-appengine/php72:latest'
],
[
// Has document_root set in env_variables
Expand All @@ -386,7 +401,7 @@ public function dataProvider()
'',
'/app/web',
'added by the php runtime builder',
'gcr.io/google-appengine/php71:latest'
'gcr.io/google-appengine/php72:latest'
],
[
// document_root in both will throw exception
Expand All @@ -395,7 +410,7 @@ public function dataProvider()
'',
'/app/web',
'added by the php runtime builder',
'gcr.io/google-appengine/php71:latest',
'gcr.io/google-appengine/php72:latest',
[],
'\\Google\\Cloud\\Runtimes\\Builder\\Exception\\EnvConflictException'
],
Expand All @@ -415,7 +430,7 @@ public function dataProvider()
'',
'/app',
'added by the php runtime builder',
'gcr.io/google-appengine/php56:latest',
'gcr.io/google-appengine/php72:latest',
[],
'\\Google\\Cloud\\Runtimes\\Builder\\Exception\\ExactVersionException'
]
Expand Down
5 changes: 5 additions & 0 deletions builder/gen-dockerfile/tests/test_data/php71/app.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
env: flex
runtime: php

runtime_config:
document_root: /app
5 changes: 5 additions & 0 deletions builder/gen-dockerfile/tests/test_data/php71/composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"require": {
"php": "7.1.*"
}
}
18 changes: 18 additions & 0 deletions cloudbuild.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,24 @@ steps:
waitFor: ['php71-custom-app', 'test-runner']
id: php71-custom-test

# php72-custom test
- name: gcr.io/cloud-builders/docker
args: ['build', '-t', 'gcr.io/${_GOOGLE_PROJECT_ID}/php72-custom:$_TAG', '.']
dir: testapps/php72_custom
waitFor: ['php-onbuild']
id: php72-custom-build
- name: gcr.io/gcp-runtimes/structure_test
args: ['-i', 'gcr.io/${_GOOGLE_PROJECT_ID}/php72-custom:$_TAG', '--config', 'php72.yaml', '-v']
waitFor: ['php72-custom-build']
- name: gcr.io/cloud-builders/docker
args: ['run', '--net=nw_$_TAG', '--name=php72-custom', '-d', 'gcr.io/${_GOOGLE_PROJECT_ID}/php72-custom:$_TAG']
waitFor: ['php72-custom-build', 'test-network']
id: php72-custom-app
- name: gcr.io/cloud-builders/docker
args: ['run', '--net=nw_$_TAG','-v', '/workspace:/workspace', 'gcr.io/${_GOOGLE_PROJECT_ID}/php-test-runner:$_TAG', '/workspace/testapps/php72_custom/tests']
waitFor: ['php72-custom-app', 'test-runner']
id: php72-custom-test

# php71-extensions test
- name: gcr.io/cloud-builders/docker
args: ['build', '-t', 'gcr.io/${_GOOGLE_PROJECT_ID}/php71-extensions:$_TAG', '.']
Expand Down
6 changes: 3 additions & 3 deletions integration-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ steps:
waitFor: ['-']
id: test-runner

# php71_e2e test
# php72_e2e test
- name: gcr.io/${_GOOGLE_PROJECT_ID}/php-test-runner:$_TAG
args: ['/workspace/testapps/php71_e2e/tests']
args: ['/workspace/testapps/php72_e2e/tests']
waitFor: ['test-runner']
id: php71_e2e
id: php72_e2e
env:
- 'SERVICE_ACCOUNT_JSON=${_SERVICE_ACCOUNT_JSON}'
- 'TAG=${_TAG}-e2e'
Expand Down
2 changes: 1 addition & 1 deletion php-base/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ RUN mkdir -p $APP_DIR $UPLOAD_DIR $SESSION_SAVE_PATH \
$APP_DIR $UPLOAD_DIR $SESSION_SAVE_PATH \
$NGINX_USER_CONF_DIR $WWW_HOME $COMPOSER_HOME \
&& chmod 755 $UPLOAD_DIR $SESSION_SAVE_PATH $COMPOSER_HOME \
# For easy access to php with `su www-data -c $CMD`
&& ln -sf ${PHP_DIR}/bin/php /usr/bin/php
# Linking for easy access to php with `su www-data -c $CMD`

# Put other config and shell files into place.
COPY nginx.conf fastcgi_params gzip_params "${NGINX_DIR}/"
Expand Down
18 changes: 12 additions & 6 deletions php-base/build-scripts/composer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ else
set -e
fi

DEFAULT_PHP_VERSION="7.1"
DEFAULT_PHP_VERSION="7.2"

if [ -f ${APP_DIR}/composer.json ]; then
if [ -n "${DETECTED_PHP_VERSION}" ]; then
Expand All @@ -36,16 +36,16 @@ if [ -f ${APP_DIR}/composer.json ]; then

if [ "${PHP_VERSION}" == "exact" ]; then
cat<<EOF
An exact PHP version was specified in composer.json. Please pin your PHP version to a minor version such as '7.1.*'.
An exact PHP version was specified in composer.json. Please pin your PHP version to a minor version such as '7.2.*'.
EOF
exit 1
elif [ "${PHP_VERSION}" != "5.6" ] && [ "${PHP_VERSION}" != "7.0" ] && [ "${PHP_VERSION}" != "7.1" ]; then
elif [ "${PHP_VERSION}" != "5.6" ] && [ "${PHP_VERSION}" != "7.0" ] && [ "${PHP_VERSION}" != "7.1" ] && [ "${PHP_VERSION}" != "7.2" ]; then
cat<<EOF
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.1.x version. We recommend pinning your PHP version by running:
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.2.x version. We recommend pinning your PHP version by running:

composer require php 7.1.* (replace it with your desired minor version)
composer require php 7.2.* (replace it with your desired minor version)

Using PHP version 7.1.x...
Using PHP version 7.2.x...
EOF
PHP_VERSION=${DEFAULT_PHP_VERSION}
fi
Expand All @@ -63,6 +63,12 @@ EOF
apt-get remove -y gcp-php71
rm -rf /var/lib/apt/lists/*
fi
if [ "${PHP_VERSION}" == "7.2" ]; then
apt-get -y update
/bin/bash /build-scripts/install_php72.sh
apt-get remove -y gcp-php71
rm -rf /var/lib/apt/lists/*
fi
fi

echo "Using PHP version: ${PHP_VERSION}"
Expand Down
1 change: 1 addition & 0 deletions php-base/build-scripts/detect_php_version.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ public static function version($constraint, $availableVersions = null)
private static function detectAvailableVersions()
{
return [
trim(file_get_contents('/opt/php72_version')),
trim(file_get_contents('/opt/php71_version')),
trim(file_get_contents('/opt/php70_version')),
trim(file_get_contents('/opt/php56_version'))
Expand Down
2 changes: 1 addition & 1 deletion testapps/build_pipeline_php56/composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"require": {
"php": "^5.6",
"php": "5.6.*",
"google/cloud": "*",
"grpc/grpc": "*",
"silex/silex": "^1.3"
Expand Down
Loading