-
-
Notifications
You must be signed in to change notification settings - Fork 366
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #855 from brefphp/docker-lambda
Improve running PHP on Lambda with Docker
- Loading branch information
Showing
5 changed files
with
37 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,41 @@ | ||
This directory contains the scripts that create and publish the AWS Lambda runtimes for PHP. | ||
|
||
Read the [runtimes documentation](/docs/runtimes/README.md) to learn more. | ||
|
||
## How it works | ||
|
||
The scripts are written mainly in `Makefile`. | ||
# Bref runtimes and Docker images | ||
|
||
Multiple Docker images are created: | ||
|
||
- `bref/tmp/...` images are created locally and not published online | ||
- `bref/...` images are published on Docker Hub | ||
|
||
Workflow: | ||
Goal for the Docker images: | ||
|
||
- 1: Create the `bref/tmp/step-1/build-environment` Docker image. | ||
- `bref/tmp/step-1/build-environment` | ||
|
||
This image contains everything needed to compile PHP. This image is created standalone because | ||
it is common for each PHP version. The next step involves a different Dockerfile per PHP version. | ||
|
||
- 2: Create the `bref/build-php-XX` images. | ||
- `bref/build-php-XX` | ||
|
||
There is one image per PHP version. These images contain PHP compiled with all its extensions. | ||
It is published so that anyone can use it to compile their own extensions. | ||
It is not the final image because it contains too many things that need to be removed. | ||
|
||
- 3: Create the `bref/tmp/cleaned-build-php-XX` images. | ||
- `bref/tmp/cleaned-build-php-XX` | ||
|
||
There is one image per PHP version. These images contain PHP compiled with all its extensions, | ||
but with all extra files removed. These images do not contain the bootstrap files and PHP config files. | ||
|
||
- 4: Create the `bref/php-XX`, `bref/php-XX-fpm`, `bref/php-XX-fpm-dev` images. | ||
- `bref/php-XX`, `bref/php-XX-fpm` | ||
|
||
There is one image per PHP version. These images contain exactly what will be in the layers in `/opt`. | ||
|
||
- 5: Create the layers zip files in the `export/` directory. | ||
We zip the `/opt` directory of each Docker image. | ||
These images have 3 goals: | ||
|
||
- export `/opt` to create layers | ||
- run applications locally using Docker: this requires overloading the entrypoint if necessary | ||
- deploy applications on Lambda using Docker images: set the handler as `cmd` | ||
|
||
- `bref/php-XX-fpm-dev` | ||
|
||
Used to run web applications locally. | ||
|
||
- 6: Publish the layers on AWS. | ||
We upload and publish the layers in every AWS region using the zip files. | ||
Layers are created in the `export/` directory (we zip the `/opt` directory of each Docker image). | ||
We upload and publish the layers in every AWS region using the zip files. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
ARG PHP_VERSION | ||
FROM bref/php-$PHP_VERSION | ||
|
||
# Overwrite the original bootstrap | ||
COPY bootstrap /opt/bootstrap | ||
# Copy files to /var/runtime to support deploying as a Docker image | ||
RUN cp /opt/bootstrap /var/runtime |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters