Skip to content

Commit

Permalink
Improved upgradability of PHP (#201)
Browse files Browse the repository at this point in the history
* PHP AB#903911

* Improved PHP upgradability with build image

* Styling
  • Loading branch information
dorfire authored Jun 10, 2019
1 parent 1df84ce commit ace9b0e
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 11 deletions.
2 changes: 2 additions & 0 deletions build/__php-versions.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# This file was auto-generated from 'build-constants.yaml'. Changes may be overridden.

PHP_BUILD_BASE_TAG='20190530.1'
PHP_RUNTIME_BASE_TAG='20190530.1'
COMPOSER_VERSION='1.8.4'
COMPOSER_SHA384='48e3236262b34d30969dca3c37281b3b4bbe3221bda826ac6a9a62d6444cdb0dcd0615698a5cbe587c3f0fe57a54d8f5'
PHP73_VERSION='7.3.5'
Expand Down
4 changes: 3 additions & 1 deletion build/build-buildimages.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ declare -r REPO_DIR=$( cd $( dirname "$0" ) && cd .. && pwd )

# Load all variables
source $REPO_DIR/build/__variables.sh
source $REPO_DIR/build/__php-versions.sh

cd "$BUILD_IMAGES_BUILD_CONTEXT_DIR"

Expand Down Expand Up @@ -61,8 +62,9 @@ BuildAndTagStage buildscriptbuilder

builtImageTag="$DOCKER_BUILD_IMAGES_REPO:latest"
docker build -t $builtImageTag \
--build-arg AI_KEY=$APPLICATION_INSIGHTS_INSTRUMENTATION_KEY \
--build-arg AGENTBUILD=$BUILD_SIGNED \
--build-arg PHP_BUILD_BASE_TAG=$PHP_BUILD_BASE_TAG \
--build-arg AI_KEY=$APPLICATION_INSIGHTS_INSTRUMENTATION_KEY \
$ctxArgs -f "$BUILD_IMAGES_DOCKERFILE" .

echo
Expand Down
2 changes: 2 additions & 0 deletions build/build-constants.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@
file-name-prefix: __
- name: php-versions
constants:
php-build-base-tag: 20190530.1
php-runtime-base-tag: 20190530.1
composer-version: 1.8.4
composer-sha384: 48e3236262b34d30969dca3c37281b3b4bbe3221bda826ac6a9a62d6444cdb0dcd0615698a5cbe587c3f0fe57a54d8f5
php73-version: 7.3.5
Expand Down
23 changes: 16 additions & 7 deletions images/build/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# Start declaration of Build-Arg to determine where the image is getting built (devops agents or local)
# Start declaration of Build-Arg to determine where the image is getting built (DevOps agents or local)
ARG AGENTBUILD
ARG PHP_BUILD_BASE_TAG
FROM buildpack-deps:stretch AS main
# End declaration of Build-Arg to determine where the image is getting built (devops agents or local)
# End declaration of Build-Arg to determine where the image is getting built (DevOps agents or local)

# Configure locale (required for Python)
# NOTE: Do NOT move it from here as it could have global implications
Expand Down Expand Up @@ -319,6 +320,12 @@ RUN if [ -z "$AGENTBUILD" ]; then \
fi
RUN chmod a+x /opt/buildscriptgen/GenerateBuildScript

# Docker doesn't support variables in --from, so we're using an intermediate stage
FROM mcr.microsoft.com/oryx/php-build-base:5.6-${PHP_BUILD_BASE_TAG} AS php56-build-base
FROM mcr.microsoft.com/oryx/php-build-base:7.0-${PHP_BUILD_BASE_TAG} AS php70-build-base
FROM mcr.microsoft.com/oryx/php-build-base:7.2-${PHP_BUILD_BASE_TAG} AS php72-build-base
FROM mcr.microsoft.com/oryx/php-build-base:7.3-${PHP_BUILD_BASE_TAG} AS php73-build-base

###
# Build run script generators (to be used by the `oryx run-script` command)
###
Expand Down Expand Up @@ -365,16 +372,18 @@ COPY --from=mcr.microsoft.com/oryx/build-yarn-cache:20190326.8 /usr/local/share/
# Copy PHP versions
COPY images/build/php/prereqs/install-prereqs.sh /tmp/php/install-prereqs.sh
RUN . /tmp/php/install-prereqs.sh
COPY --from=mcr.microsoft.com/oryx/php-build-base:5.6-20190530.1 /opt /opt
COPY --from=mcr.microsoft.com/oryx/php-build-base:7.0-20190530.1 /opt /opt
COPY --from=mcr.microsoft.com/oryx/php-build-base:7.2-20190530.1 /opt /opt
COPY --from=mcr.microsoft.com/oryx/php-build-base:7.3-20190530.1 /opt /opt

COPY --from=php56-build-base /opt /opt
COPY --from=php70-build-base /opt /opt
COPY --from=php72-build-base /opt /opt
COPY --from=php73-build-base /opt /opt

RUN ln -s /opt/php/5.6 /opt/php/5 \
&& ln -s /opt/php/7.3 /opt/php/7 \
&& ln -s /opt/php/7 /opt/php/lts \
&& ln -s /opt/php/lts/bin/php /usr/local/bin/php

# Build script generator content, currently docker doesn't support variables in --from
# Build script generator content. Docker doesn't support variables in --from
# so we are building an extra stage to copy binaries from correct build stage
COPY --from=buildscriptbuilder /opt/buildscriptgen/ /opt/buildscriptgen/
RUN ln -s /opt/buildscriptgen/GenerateBuildScript /usr/local/bin/oryx
Expand Down
2 changes: 1 addition & 1 deletion images/runtime/php/generateDockerfiles.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,6 @@ do
sed -i "s|$IMAGE_NAME_PLACEHOLDER|$PHP_IMAGE_NAME|g" "$TARGET_DOCKERFILE_BASE"
sed -i "s|$PHP_VERSION_PLACEHOLDER|$PHP_VERSION|g" "$TARGET_DOCKERFILE_BASE"

RUNTIME_BASE_IMAGE_NAME="mcr.microsoft.com/oryx/php-base:$VERSION_DIRECTORY-20190530.1"
RUNTIME_BASE_IMAGE_NAME="mcr.microsoft.com/oryx/php-base:$VERSION_DIRECTORY-$PHP_RUNTIME_BASE_TAG"
sed -i "s|$RUNTIME_BASE_IMAGE_NAME_PLACEHOLDER|$RUNTIME_BASE_IMAGE_NAME|g" "$TARGET_DOCKERFILE"
done
2 changes: 2 additions & 0 deletions src/BuildScriptGenerator/PhpVersions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ namespace Microsoft.Oryx.Common
{
public static class PhpVersions
{
public const string PhpBuildBaseTag = "20190530.1";
public const string PhpRuntimeBaseTag = "20190530.1";
public const string ComposerVersion = "1.8.4";
public const string ComposerSha384 = "48e3236262b34d30969dca3c37281b3b4bbe3221bda826ac6a9a62d6444cdb0dcd0615698a5cbe587c3f0fe57a54d8f5";
public const string Php73Version = "7.3.5";
Expand Down
4 changes: 2 additions & 2 deletions vsts/pipelines/buildimage-bases.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ jobs:

- template: templates/_buildimage-bases.job-template.yml
parameters:
displayName: Build and push PHP base images for build
displayName: Build and push PHP build base images
scriptPath: ./build/build-buildimage-bases.sh
imageDir: php
artifactsFileName: php-buildimage-bases.txt

- template: templates/_buildimage-bases.job-template.yml
parameters:
displayName: Build and push PHP base images for runtime
displayName: Build and push PHP runtime base images
scriptPath: ./build/build-runtimeimages-bases.sh
imageDir: php
artifactsFileName: php-runtimeimage-bases.txt
Expand Down

0 comments on commit ace9b0e

Please sign in to comment.