Skip to content

Commit d9302de

Browse files
committed
Update the PHP 8.2 and 8.3 build scripts too
1 parent 676b12e commit d9302de

File tree

2 files changed

+74
-52
lines changed

2 files changed

+74
-52
lines changed

php-82/Dockerfile

Lines changed: 37 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -501,6 +501,9 @@ RUN mkdir -p /bref-layer/bin \
501501
# Copy the PHP binary
502502
RUN cp ${INSTALL_DIR}/bin/php /bref-layer/bin/php && chmod +x /bref-layer/bin/php
503503

504+
# Copy the PHP-FPM binary
505+
RUN cp ${INSTALL_DIR}/sbin/php-fpm /bref-layer/bin/php-fpm
506+
504507
# Copy all the external PHP extensions
505508
RUN cp $(php -r 'echo ini_get("extension_dir");')/* /bref-layer/bref/extensions/
506509

@@ -510,6 +513,7 @@ RUN cp $(php -r 'echo ini_get("extension_dir");')/* /bref-layer/bref/extensions/
510513
# into `/bref-layer` (the temp directory for the future Lambda layer)
511514
COPY --link utils/lib-copy /bref/lib-copy
512515
RUN php /bref/lib-copy/copy-dependencies.php /bref-layer/bin/php /bref-layer/lib
516+
RUN php /bref/lib-copy/copy-dependencies.php /bref-layer/bin/php-fpm /bref-layer/lib
513517
RUN php /bref/lib-copy/copy-dependencies.php /bref-layer/bref/extensions/apcu.so /bref-layer/lib
514518
RUN php /bref/lib-copy/copy-dependencies.php /bref-layer/bref/extensions/intl.so /bref-layer/lib
515519
RUN php /bref/lib-copy/copy-dependencies.php /bref-layer/bref/extensions/opcache.so /bref-layer/lib
@@ -523,46 +527,53 @@ RUN cp ${CA_BUNDLE} /bref-layer/bref/ssl/cert.pem
523527
RUN cp ${INSTALL_DIR}/bref/ssl/openssl.cnf /bref-layer/bref/ssl/openssl.cnf
524528

525529

526-
# ---------------------------------------------------------------
527-
# Start from a clean image to copy only the files we need
528-
FROM public.ecr.aws/lambda/provided:al2-${IMAGE_VERSION_SUFFIX} as isolation
530+
# ----------------------------------------------------------------------------
531+
# Start from a clean image to copy only the files we need for the Lambda layer
532+
FROM public.ecr.aws/lambda/provided:al2-${IMAGE_VERSION_SUFFIX} as function
529533

530534
# We selected the files in /bref-layer, now we copy them to /opt (the real directory for the Lambda layer)
531535
COPY --link --from=build-environment /bref-layer /opt
532536

533-
COPY --link layers/bootstrap.php /opt/bref/bootstrap.php
534-
535-
536-
FROM isolation as function
537-
538-
COPY --link layers/function/bref.ini /opt/bref/etc/php/conf.d/
537+
COPY --link src/php.ini /opt/bref/etc/php/conf.d/bref.ini
538+
COPY --link src/php-fpm.conf /opt/bref/etc/php-fpm.conf
539539

540-
COPY --link layers/function/bootstrap.sh /opt/bootstrap
540+
COPY --link src/bootstrap.php /opt/bootstrap
541541
# Copy files to /var/runtime to support deploying as a Docker image
542-
COPY --link layers/function/bootstrap.sh /var/runtime/bootstrap
542+
COPY --link src/bootstrap.php /var/runtime/bootstrap
543543
RUN chmod +x /opt/bootstrap && chmod +x /var/runtime/bootstrap
544544

545545

546-
# Up until here the entire file has been designed as a top-down reading/execution.
547-
# Everything necessary for the `function` layer has been installed, isolated and
548-
# packaged. Now we'll go back one step and start from the extensions so that we
549-
# can install fpm. Then we'll start the fpm layer and quickly isolate fpm.
546+
# ----------------------------------------------------------------------------
547+
# Build the dev image with xdebug
548+
FROM build-environment as build_dev
550549

551-
FROM build-environment as fpm-extension
550+
RUN mkdir -p /opt/bref/extensions
552551

553-
RUN cp ${INSTALL_DIR}/sbin/php-fpm /bref-layer/bin/php-fpm
554-
RUN php /bref/lib-copy/copy-dependencies.php /bref-layer/bin/php-fpm /bref-layer/lib
552+
# Install xdebug
553+
RUN pecl install xdebug-3.4.2
554+
RUN cp $(php -r "echo ini_get('extension_dir');")/xdebug.so /opt/bref/extensions
555555

556556

557-
FROM isolation as fpm
557+
FROM function as dev
558558

559-
COPY --link --from=fpm-extension /bref-layer /opt
559+
COPY --link --from=build_dev /opt /opt
560+
COPY --link src/dev-entrypoint.sh /bref-entrypoint.sh
561+
RUN chmod +x /bref-entrypoint.sh
560562

561-
COPY --link layers/fpm/bref.ini /opt/bref/etc/php/conf.d/
563+
# Install node to run the JS app below
564+
RUN yum install https://rpm.nodesource.com/pub_16.x/nodistro/repo/nodesource-release-nodistro-1.noarch.rpm -y
565+
RUN yum install --setopt=nodesource-nodejs.module_hotfixes=1 --setopt=skip_missing_names_on_install=False -y nodejs
562566

563-
COPY --link layers/fpm/bootstrap.sh /opt/bootstrap
564-
# Copy files to /var/runtime to support deploying as a Docker image
565-
COPY --link layers/fpm/bootstrap.sh /var/runtime/bootstrap
566-
RUN chmod +x /opt/bootstrap && chmod +x /var/runtime/bootstrap
567+
# Install the bref/local-api-gateway app in our container (avoids running 2 containers)
568+
COPY --link --from=bref/local-api-gateway /app /local-api-gateway
569+
EXPOSE 8000
570+
571+
# Add `php/conf.dev.d` to the path where PHP looks for configuration files
572+
ENV PHP_INI_SCAN_DIR="/opt/bref/etc/php/conf.d:/var/task/php/conf.d:/var/task/php/conf.dev.d"
573+
574+
# Add composer
575+
COPY --link --from=composer/composer:2-bin /composer /usr/bin/composer
567576

568-
COPY --link layers/fpm/php-fpm.conf /opt/bref/etc/php-fpm.conf
577+
# Originally the entrypoint is `/lambda-entrypoint.sh` and CMD contains the handler name
578+
# We override the entrypoint to run our own logic
579+
ENTRYPOINT [ "/bref-entrypoint.sh" ]

php-83/Dockerfile

Lines changed: 37 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -501,6 +501,9 @@ RUN mkdir -p /bref-layer/bin \
501501
# Copy the PHP binary
502502
RUN cp ${INSTALL_DIR}/bin/php /bref-layer/bin/php && chmod +x /bref-layer/bin/php
503503

504+
# Copy the PHP-FPM binary
505+
RUN cp ${INSTALL_DIR}/sbin/php-fpm /bref-layer/bin/php-fpm
506+
504507
# Copy all the external PHP extensions
505508
RUN cp $(php -r 'echo ini_get("extension_dir");')/* /bref-layer/bref/extensions/
506509

@@ -510,6 +513,7 @@ RUN cp $(php -r 'echo ini_get("extension_dir");')/* /bref-layer/bref/extensions/
510513
# into `/bref-layer` (the temp directory for the future Lambda layer)
511514
COPY --link utils/lib-copy /bref/lib-copy
512515
RUN php /bref/lib-copy/copy-dependencies.php /bref-layer/bin/php /bref-layer/lib
516+
RUN php /bref/lib-copy/copy-dependencies.php /bref-layer/bin/php-fpm /bref-layer/lib
513517
RUN php /bref/lib-copy/copy-dependencies.php /bref-layer/bref/extensions/apcu.so /bref-layer/lib
514518
RUN php /bref/lib-copy/copy-dependencies.php /bref-layer/bref/extensions/intl.so /bref-layer/lib
515519
RUN php /bref/lib-copy/copy-dependencies.php /bref-layer/bref/extensions/opcache.so /bref-layer/lib
@@ -523,46 +527,53 @@ RUN cp ${CA_BUNDLE} /bref-layer/bref/ssl/cert.pem
523527
RUN cp ${INSTALL_DIR}/bref/ssl/openssl.cnf /bref-layer/bref/ssl/openssl.cnf
524528

525529

526-
# ---------------------------------------------------------------
527-
# Start from a clean image to copy only the files we need
528-
FROM public.ecr.aws/lambda/provided:al2-${IMAGE_VERSION_SUFFIX} as isolation
530+
# ----------------------------------------------------------------------------
531+
# Start from a clean image to copy only the files we need for the Lambda layer
532+
FROM public.ecr.aws/lambda/provided:al2-${IMAGE_VERSION_SUFFIX} as function
529533

530534
# We selected the files in /bref-layer, now we copy them to /opt (the real directory for the Lambda layer)
531535
COPY --link --from=build-environment /bref-layer /opt
532536

533-
COPY --link layers/bootstrap.php /opt/bref/bootstrap.php
534-
535-
536-
FROM isolation as function
537-
538-
COPY --link layers/function/bref.ini /opt/bref/etc/php/conf.d/
537+
COPY --link src/php.ini /opt/bref/etc/php/conf.d/bref.ini
538+
COPY --link src/php-fpm.conf /opt/bref/etc/php-fpm.conf
539539

540-
COPY --link layers/function/bootstrap.sh /opt/bootstrap
540+
COPY --link src/bootstrap.php /opt/bootstrap
541541
# Copy files to /var/runtime to support deploying as a Docker image
542-
COPY --link layers/function/bootstrap.sh /var/runtime/bootstrap
542+
COPY --link src/bootstrap.php /var/runtime/bootstrap
543543
RUN chmod +x /opt/bootstrap && chmod +x /var/runtime/bootstrap
544544

545545

546-
# Up until here the entire file has been designed as a top-down reading/execution.
547-
# Everything necessary for the `function` layer has been installed, isolated and
548-
# packaged. Now we'll go back one step and start from the extensions so that we
549-
# can install fpm. Then we'll start the fpm layer and quickly isolate fpm.
546+
# ----------------------------------------------------------------------------
547+
# Build the dev image with xdebug
548+
FROM build-environment as build_dev
550549

551-
FROM build-environment as fpm-extension
550+
RUN mkdir -p /opt/bref/extensions
552551

553-
RUN cp ${INSTALL_DIR}/sbin/php-fpm /bref-layer/bin/php-fpm
554-
RUN php /bref/lib-copy/copy-dependencies.php /bref-layer/bin/php-fpm /bref-layer/lib
552+
# Install xdebug
553+
RUN pecl install xdebug-3.4.2
554+
RUN cp $(php -r "echo ini_get('extension_dir');")/xdebug.so /opt/bref/extensions
555555

556556

557-
FROM isolation as fpm
557+
FROM function as dev
558558

559-
COPY --link --from=fpm-extension /bref-layer /opt
559+
COPY --link --from=build_dev /opt /opt
560+
COPY --link src/dev-entrypoint.sh /bref-entrypoint.sh
561+
RUN chmod +x /bref-entrypoint.sh
560562

561-
COPY --link layers/fpm/bref.ini /opt/bref/etc/php/conf.d/
563+
# Install node to run the JS app below
564+
RUN yum install https://rpm.nodesource.com/pub_16.x/nodistro/repo/nodesource-release-nodistro-1.noarch.rpm -y
565+
RUN yum install --setopt=nodesource-nodejs.module_hotfixes=1 --setopt=skip_missing_names_on_install=False -y nodejs
562566

563-
COPY --link layers/fpm/bootstrap.sh /opt/bootstrap
564-
# Copy files to /var/runtime to support deploying as a Docker image
565-
COPY --link layers/fpm/bootstrap.sh /var/runtime/bootstrap
566-
RUN chmod +x /opt/bootstrap && chmod +x /var/runtime/bootstrap
567+
# Install the bref/local-api-gateway app in our container (avoids running 2 containers)
568+
COPY --link --from=bref/local-api-gateway /app /local-api-gateway
569+
EXPOSE 8000
570+
571+
# Add `php/conf.dev.d` to the path where PHP looks for configuration files
572+
ENV PHP_INI_SCAN_DIR="/opt/bref/etc/php/conf.d:/var/task/php/conf.d:/var/task/php/conf.dev.d"
573+
574+
# Add composer
575+
COPY --link --from=composer/composer:2-bin /composer /usr/bin/composer
567576

568-
COPY --link layers/fpm/php-fpm.conf /opt/bref/etc/php-fpm.conf
577+
# Originally the entrypoint is `/lambda-entrypoint.sh` and CMD contains the handler name
578+
# We override the entrypoint to run our own logic
579+
ENTRYPOINT [ "/bref-entrypoint.sh" ]

0 commit comments

Comments
 (0)