-
-
Notifications
You must be signed in to change notification settings - Fork 365
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Run applications locally with Bref Docker images #367
Closed
Guillaume-Rossignol
wants to merge
13
commits into
brefphp:master
from
Guillaume-Rossignol:local-docker-images
Closed
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
f930568
Fix runtime/php readme
Guillaume-Rossignol fddd71f
Add docker image for local dev
Guillaume-Rossignol f6ba80d
Rename dockerfile from ...-local to ...-dev and improve documentation…
Guillaume-Rossignol 62ac9f3
Improve documentation about running local docker images
Guillaume-Rossignol dc5324b
Change dev image name
Guillaume-Rossignol 2dfd550
Remove legacy layer files
mnapoli b7db4c4
Reorganize the layer files
mnapoli 5d5f51e
Merge branch 'master' into local-docker-images
mnapoli 8759e15
Document how to use Docker dev images
mnapoli 85f4a73
Generate λ docker image
Guillaume-Rossignol 69b326f
Docker image for layer generation and dev purpose
Guillaume-Rossignol ebaf684
Update documentation about running http app localy
Guillaume-Rossignol f025e44
Use lambci/provided instead of lambci/build-provided
Guillaume-Rossignol File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,15 +1,42 @@ | ||
SHELL := /bin/bash | ||
|
||
.PHONY: layers | ||
# Publish the layers on AWS Lambda | ||
publish: layers | ||
php publish.php | ||
|
||
# Build the layers | ||
layers: export/console.zip export/php-%.zip | ||
layers: export/console.zip export/php-72.zip export/php-73.zip export/php-72-fpm.zip export/php-73-fpm.zip | ||
|
||
# The PHP runtimes | ||
export/php-%.zip: | ||
cd php && make distribution | ||
export/php%.zip: build | ||
PHP_VERSION=$$(echo $@| tail -c +8|head -c -5);\ | ||
rm -f $@;\ | ||
mkdir export/tmp ; cd export/tmp ;\ | ||
docker run --entrypoint "tar" bref/$$PHP_VERSION:latest -ch -C /opt . |tar -x;zip --quiet --recurse-paths ../$$PHP_VERSION.zip . ; | ||
rm -rf export/tmp | ||
|
||
# The console runtime | ||
export/console.zip: console/bootstrap | ||
export/console.zip: layers/console/bootstrap | ||
rm -f export/console.zip | ||
cd console && zip ../export/console.zip bootstrap | ||
cd layers/console && zip ../../export/console.zip bootstrap | ||
|
||
# Build the docker container that will be used to compile PHP and its extensions | ||
compiler: compiler.Dockerfile | ||
docker build -f ${PWD}/compiler.Dockerfile -t bref/runtime/compiler:latest . | ||
|
||
# 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 -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 -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 | ||
docker push bref/php-73:latest |
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 |
---|---|---|
|
@@ -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 <[email protected]>" | ||
LABEL vendor1="Signature Tech Studio, Inc." | ||
LABEL vendor2="bref" | ||
|
File renamed without changes.
File renamed without changes.
File renamed without changes.
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,6 @@ | ||
ARG LAYER_IMAGE | ||
FROM $LAYER_IMAGE | ||
|
||
COPY ./php-fpm.conf /opt/bref/etc/php-fpm.conf | ||
EXPOSE 9000 | ||
CMD /opt/bin/php-fpm --nodaemonize --fpm-config /opt/bref/etc/php-fpm.conf |
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,24 @@ | ||
; Logging anywhere on disk doesn't make sense on lambda since instances are ephemeral | ||
error_log = /dev/stderr | ||
pid = /tmp/php-fpm.pid | ||
; Log above warning because PHP-FPM logs useless notices | ||
; We must comment this flag else uncaught exceptions/fatal errors are not reported in the logs! | ||
; TODO: report that to the PHP bug tracker | ||
;log_level = 'warning' | ||
|
||
[default] | ||
pm = static | ||
; We only need one child because a lambda can process only one request at a time | ||
pm.max_children = 1 | ||
user = nobody | ||
listen = 9000 | ||
; Allows PHP processes to access the lambda's environment variables | ||
clear_env = no | ||
; Forward stderr of PHP processes to stderr of PHP-FPM (so that it can be sent to cloudwatch) | ||
catch_workers_output = yes | ||
; New PHP 7.3 option that disables a verbose log prefix | ||
; Disabled for now until we switch to PHP 7.3 | ||
;decorate_workers_output = no | ||
; Limit the number of core dump logs to 1 to avoid filling up the /tmp disk | ||
; See https://github.com/brefphp/bref/issues/275 | ||
rlimit_core = 1 |
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,13 @@ | ||
ARG LAYER_IMAGE | ||
FROM $LAYER_IMAGE | ||
|
||
WORKDIR /opt | ||
|
||
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 | ||
|
||
WORKDIR / | ||
COPY --from=0 /opt /opt |
File renamed without changes.
File renamed without changes.
File renamed without changes.
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,12 @@ | ||
ARG LAYER_IMAGE | ||
FROM $LAYER_IMAGE | ||
|
||
WORKDIR /opt | ||
|
||
COPY bootstrap bootstrap | ||
COPY php.ini bref/etc/php/conf.d/bref.ini | ||
|
||
FROM lambci/lambda:provided | ||
|
||
WORKDIR / | ||
COPY --from=0 /opt /opt |
File renamed without changes.
File renamed without changes.
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,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 && nginx -g "daemon off;" |
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,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; | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Waiting on #332 to use
2018.03
instead.