diff --git a/runtime/Makefile b/runtime/Makefile index d25dd4df7..ebd6bdf9c 100644 --- a/runtime/Makefile +++ b/runtime/Makefile @@ -28,30 +28,14 @@ compiler: compiler.Dockerfile # Compile PHP and its extensions build: compiler docker build -f ${PWD}/php-intermediary.Dockerfile -t bref/php-72-intermediary:latest $(shell helpers/docker_args.sh versions.ini php72) . - cd layers/fpm ; docker build -f ${PWD}/layers/fpm/Dockerfile -t bref/php-72-fpm:latest --build-arg LAYER_IMAGE=bref/php-72-intermediary:latest . ; cd ../.. - cd layers/function ; docker build -f ${PWD}/layers/function/Dockerfile -t bref/php-72:latest --build-arg LAYER_IMAGE=bref/php-72-intermediary:latest . ; cd ../.. + cd layers/fpm ; docker build -t bref/php-72-fpm:latest --build-arg LAYER_IMAGE=bref/php-72-intermediary:latest . ; cd ../.. + cd layers/fpm-dev ; docker build -t bref/php-72-fpm-dev:latest --build-arg LAYER_IMAGE=bref/php-72-intermediary:latest . ; cd ../.. + cd layers/function ; docker build -t bref/php-72:latest --build-arg LAYER_IMAGE=bref/php-72-intermediary:latest . ; cd ../.. docker build -f ${PWD}/php-intermediary.Dockerfile -t bref/php-73-intermediary:latest $(shell helpers/docker_args.sh versions.ini php73) . - cd layers/fpm ; docker build -f ${PWD}/layers/fpm/Dockerfile -t bref/php-73-fpm:latest --build-arg LAYER_IMAGE=bref/php-73-intermediary:latest . ; cd ../.. - cd layers/function ; docker build -f ${PWD}/layers/function/Dockerfile -t bref/php-73:latest --build-arg LAYER_IMAGE=bref/php-73-intermediary:latest . ; cd ../.. - -# Export the compiled PHP artifacts into zip files that can be uploaded as Lambda layers -distribution: build - # Run the export script for PHP 7.2 - docker run --rm \ - --env PHP_SHORT_VERSION=72 \ - --volume ${PWD}/layers:/layers:ro \ - --volume ${PWD}/export:/export \ - --volume ${PWD}/export.sh:/export.sh:ro \ - bref/php-72:latest \ - /export.sh - # Run the export script for PHP 7.3 - docker run --rm \ - --env PHP_SHORT_VERSION=73 \ - --volume ${PWD}/layers:/layers:ro \ - --volume ${PWD}/export:/export \ - --volume ${PWD}/export.sh:/export.sh:ro \ - bref/php-73:latest \ - /export.sh + cd layers/fpm ; docker build -t bref/php-73-fpm:latest --build-arg LAYER_IMAGE=bref/php-73-intermediary:latest . ; cd ../.. + cd layers/fpm-dev ; docker build -t bref/php-73-fpm-dev:latest --build-arg LAYER_IMAGE=bref/php-73-intermediary:latest . ; cd ../.. + cd layers/function ; docker build -t bref/php-73:latest --build-arg LAYER_IMAGE=bref/php-73-intermediary:latest . ; cd ../.. + cd layers/web; docker build -t bref/web:latest . ; cd ../.. publish: build docker push bref/php-72:latest diff --git a/runtime/compiler.Dockerfile b/runtime/compiler.Dockerfile index 6d016ce2c..17c2d6d83 100644 --- a/runtime/compiler.Dockerfile +++ b/runtime/compiler.Dockerfile @@ -8,7 +8,7 @@ # https://docs.aws.amazon.com/lambda/latest/dg/current-supported-versions.html # AWS has kindly provided us with it as a base docker image. # https://github.com/aws/amazon-linux-docker-images/tree/2017.03 -FROM amazonlinux:2017.03 +FROM amazonlinux:2 LABEL authors="Bubba Hines " LABEL vendor1="Signature Tech Studio, Inc." LABEL vendor2="bref" diff --git a/runtime/layers/fpm-dev/Dockerfile b/runtime/layers/fpm-dev/Dockerfile index 2ddd4e1da..7d7f8b953 100644 --- a/runtime/layers/fpm-dev/Dockerfile +++ b/runtime/layers/fpm-dev/Dockerfile @@ -1,9 +1,6 @@ -ARG LAYER_IMAGE=bref/php-73:latest +ARG LAYER_IMAGE FROM $LAYER_IMAGE -WORKDIR /opt/bin +COPY ./php-fpm.conf /opt/bref/etc/php-fpm.conf EXPOSE 9000 - -COPY ./local/php-fpm.conf /opt/bref/etc/php-fpm.conf - -CMD [ "php-fpm", "-F", "-y", "/opt/bref/etc/php-fpm.conf" ] +CMD /opt/bin/php-fpm -F -y /opt/bref/etc/php-fpm.conf diff --git a/runtime/layers/fpm/Dockerfile b/runtime/layers/fpm/Dockerfile index b65915571..7babf2783 100644 --- a/runtime/layers/fpm/Dockerfile +++ b/runtime/layers/fpm/Dockerfile @@ -7,7 +7,7 @@ COPY bootstrap bootstrap COPY php.ini bref/etc/php/conf.d/bref.ini COPY php-fpm.conf bref/etc/php-fpm.conf -FROM lambci/lambda:provided +FROM lambci/lambda:build-provided WORKDIR / COPY --from=0 /opt /opt diff --git a/runtime/layers/function/Dockerfile b/runtime/layers/function/Dockerfile index b61e28560..ea9ce607d 100644 --- a/runtime/layers/function/Dockerfile +++ b/runtime/layers/function/Dockerfile @@ -6,7 +6,7 @@ WORKDIR /opt COPY bootstrap bootstrap COPY php.ini bref/etc/php/conf.d/bref.ini -FROM lambci/lambda:provided +FROM lambci/lambda:build-provided WORKDIR / COPY --from=0 /opt /opt diff --git a/runtime/layers/web/Dockerfile b/runtime/layers/web/Dockerfile new file mode 100644 index 000000000..19a2a0cab --- /dev/null +++ b/runtime/layers/web/Dockerfile @@ -0,0 +1,4 @@ +FROM nginx:latest +COPY default.conf /etc/nginx/conf.d/default.conf + +CMD sed -i "s|##DOCUMENT_ROOT##|$DOCUMENT_ROOT|g" /etc/nginx/conf.d/default.conf;sed -i "s|##HANDLER##|$HANDLER|g" /etc/nginx/conf.d/default.conf&& cat /etc/nginx/conf.d/default.conf&& nginx -g "daemon off;" diff --git a/runtime/layers/web/default.conf b/runtime/layers/web/default.conf new file mode 100644 index 000000000..b7a7b7547 --- /dev/null +++ b/runtime/layers/web/default.conf @@ -0,0 +1,14 @@ + server { + server_name php-docker.local; + root /var/task/##DOCUMENT_ROOT##; + + # Allow /src/index.php and src/test.php. This two routes should be in the .stack.yaml + location = / { + fastcgi_split_path_info ^(.+\.php)(/.+)$; + fastcgi_pass php:9000; + include fastcgi_params; + include fastcgi_params; + fastcgi_param SCRIPT_FILENAME /var/task/##HANDLER##; + fastcgi_param PATH_INFO $fastcgi_path_info; + } + } diff --git a/runtime/php-intermediary.Dockerfile b/runtime/php-intermediary.Dockerfile index d7ebcd132..d8df68891 100644 --- a/runtime/php-intermediary.Dockerfile +++ b/runtime/php-intermediary.Dockerfile @@ -48,7 +48,6 @@ RUN mkdir -p ${BUILD_DIR} \ # - php # Used By: # - xml2 -ARG plop ARG zlib ENV VERSION_ZLIB=${zlib} ENV ZLIB_BUILD_DIR=${BUILD_DIR}/xml2 @@ -479,7 +478,7 @@ RUN ln -s /opt/bref/sbin/* /opt/bin # Now we get rid of everything that is unnecessary. All the build tools, source code, and anything else # that might have created intermediate layers for docker. Back to base AmazonLinux we started with. -FROM amazonlinux:2017.03 +FROM amazonlinux:2 ENV INSTALL_DIR="/opt/bref" ENV PATH="/opt/bin:${PATH}" \ LD_LIBRARY_PATH="${INSTALL_DIR}/lib64:${INSTALL_DIR}/lib"