Skip to content

Commit 414a787

Browse files
authored
Refactor to a single layer (#256)
* Refactor to a single layer * Fix * Fixes * Finish merging php.ini files * Update the PHP 8.2 and 8.3 build scripts too
1 parent 84ff1f5 commit 414a787

File tree

21 files changed

+180
-384
lines changed

21 files changed

+180
-384
lines changed

.github/workflows/tests.yml

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -73,13 +73,6 @@ jobs:
7373
- name: Test that layers can be exported
7474
run: |
7575
make layer-php-${{ matrix.php_version }}
76-
make layer-php-${{ matrix.php_version }}-fpm
77-
env:
78-
CPU: ${{ matrix.cpu }}
79-
80-
- name: Test that the "console" layer can be exported
81-
run: make layer-console
82-
if: ${{ matrix.php_version == 80 }}
8376
env:
8477
CPU: ${{ matrix.cpu }}
8578

Makefile

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,7 @@ docker-images-php-%:
4141

4242

4343
# Build Lambda layers (zip files) *locally*
44-
layers: layer-php-80 layer-php-81 layer-php-82 layer-php-83 layer-php-84 layer-php-80-fpm layer-php-81-fpm layer-php-82-fpm layer-php-83-fpm layer-php-84-fpm
45-
# Build the console layer only once (x86 and single PHP version)
46-
@if [ ${CPU} = "x86" ]; then \
47-
$(MAKE) layer-console; \
48-
fi
49-
layer-console:
50-
./utils/docker-zip-dir.sh bref/console-zip console
44+
layers: layer-php-80 layer-php-81 layer-php-82 layer-php-83 layer-php-84
5145
# This rule matches with a wildcard, for example `layer-php-80`.
5246
# The `$*` variable will contained the matched part, in this case `php-80`.
5347
layer-%:
@@ -58,15 +52,8 @@ layer-%:
5852
# Uses the current AWS_PROFILE. Most users will not want to use this option
5953
# as this will publish all layers to all regions + publish all Docker images.
6054
upload-layers: upload-layers-php-80 upload-layers-php-81 upload-layers-php-82 upload-layers-php-83 upload-layers-php-84
61-
# Upload the console layer only once (x86 and single PHP version)
62-
@if [ ${CPU} = "x86" ]; then \
63-
LAYER_NAME=console $(MAKE) -C ./utils/lambda-publish publish-parallel; \
64-
fi
6555
upload-layers-php-%:
66-
# Upload the function layers to AWS
6756
LAYER_NAME=${CPU_PREFIX}php-$* $(MAKE) -C ./utils/lambda-publish publish-parallel
68-
# Upload the FPM layers to AWS
69-
LAYER_NAME=${CPU_PREFIX}php-$*-fpm $(MAKE) -C ./utils/lambda-publish publish-parallel
7057

7158

7259
# Publish Docker images to Docker Hub.
@@ -78,8 +65,7 @@ upload-to-docker-hub-php-%:
7865

7966
set -e ; \
8067
for image in \
81-
"bref/${CPU_PREFIX}php-$*" "bref/${CPU_PREFIX}php-$*-fpm" "bref/${CPU_PREFIX}php-$*-console" \
82-
"bref/${CPU_PREFIX}build-php-$*" "bref/${CPU_PREFIX}php-$*-fpm-dev"; \
68+
"bref/${CPU_PREFIX}php-$*" "bref/${CPU_PREFIX}build-php-$*" "bref/${CPU_PREFIX}php-$*-dev"; \
8369
do \
8470
docker tag $$image $$image:2 ; \
8571
docker tag $$image $$image:${DOCKER_TAG} ; \
@@ -102,7 +88,4 @@ clean-%:
10288
docker image rm --force bref/${CPU_PREFIX}build-php-$* \
10389
bref/${CPU_PREFIX}php-$* \
10490
bref/${CPU_PREFIX}php-$*-zip \
105-
bref/${CPU_PREFIX}php-$*-fpm \
106-
bref/${CPU_PREFIX}php-$*-fpm-zip \
107-
bref/${CPU_PREFIX}php-$*-fpm-dev \
108-
bref/${CPU_PREFIX}php-$*-console
91+
bref/${CPU_PREFIX}php-$*-dev

README.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,10 +148,8 @@ Anything we want to make available in AWS Lambda is possible by preparing the ri
148148
bref/ # custom Bref files
149149
extensions/ # PHP extensions
150150
...
151-
php-fpm-runtime/ # the built-in FPM runtime
152151
etc/php/conf.d/ # automatically loaded php.ini files
153152
bref.ini
154-
bootstrap.php # (for the function layer only)
155153

156154
bootstrap # entrypoint of the runtime
157155

docker-bake.hcl

Lines changed: 14 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
group "default" {
2-
targets = ["build-php", "php", "php-fpm", "console-zip", "console", "php-fpm-dev"]
2+
targets = ["build-php", "php", "php-dev"]
33
}
44

55
variable "CPU" {
@@ -23,9 +23,9 @@ variable "PHP_COMPILATION_FLAGS" {
2323

2424
target "build-php" {
2525
dockerfile = "php-${PHP_VERSION}/Dockerfile"
26-
target = "build-environment"
27-
tags = ["bref/${CPU_PREFIX}build-php-${PHP_VERSION}"]
28-
args = {
26+
target = "build-environment"
27+
tags = ["bref/${CPU_PREFIX}build-php-${PHP_VERSION}"]
28+
args = {
2929
"IMAGE_VERSION_SUFFIX" = "${IMAGE_VERSION_SUFFIX}"
3030
"PHP_COMPILATION_FLAGS" = "${PHP_COMPILATION_FLAGS}"
3131
}
@@ -34,9 +34,9 @@ target "build-php" {
3434

3535
target "php" {
3636
dockerfile = "php-${PHP_VERSION}/Dockerfile"
37-
target = "function"
38-
tags = ["bref/${CPU_PREFIX}php-${PHP_VERSION}"]
39-
args = {
37+
target = "function"
38+
tags = ["bref/${CPU_PREFIX}php-${PHP_VERSION}"]
39+
args = {
4040
"IMAGE_VERSION_SUFFIX" = "${IMAGE_VERSION_SUFFIX}"
4141
"PHP_COMPILATION_FLAGS" = "${PHP_COMPILATION_FLAGS}"
4242
}
@@ -46,58 +46,18 @@ target "php" {
4646
platforms = ["${DOCKER_PLATFORM}"]
4747
}
4848

49-
target "php-fpm" {
49+
target "php-dev" {
5050
dockerfile = "php-${PHP_VERSION}/Dockerfile"
51-
target = "fpm"
52-
tags = ["bref/${CPU_PREFIX}php-${PHP_VERSION}-fpm"]
53-
args = {
51+
target = "dev"
52+
tags = ["bref/${CPU_PREFIX}php-${PHP_VERSION}-dev"]
53+
args = {
5454
"IMAGE_VERSION_SUFFIX" = "${IMAGE_VERSION_SUFFIX}"
55+
"PHP_COMPILATION_FLAGS" = "${PHP_COMPILATION_FLAGS}"
5556
}
5657
contexts = {
5758
"bref/${CPU_PREFIX}build-php-${PHP_VERSION}" = "target:build-php"
58-
"bref/${CPU_PREFIX}php-${PHP_VERSION}" = "target:php"
59-
}
60-
platforms = ["${DOCKER_PLATFORM}"]
61-
}
62-
63-
target "console-zip" {
64-
context = "layers/console"
65-
target = "console-zip"
66-
tags = ["bref/console-zip"]
67-
args = {
68-
PHP_VERSION = "${PHP_VERSION}"
69-
CPU_PREFIX = "${CPU_PREFIX}"
70-
}
71-
platforms = ["${DOCKER_PLATFORM}"]
72-
}
73-
74-
target "console" {
75-
context = "layers/console"
76-
target = "console"
77-
tags = ["bref/${CPU_PREFIX}php-${PHP_VERSION}-console"]
78-
args = {
79-
PHP_VERSION = "${PHP_VERSION}"
80-
CPU_PREFIX = "${CPU_PREFIX}"
81-
}
82-
contexts = {
83-
"bref/${CPU_PREFIX}build-php-${PHP_VERSION}" = "target:build-php"
84-
"bref/${CPU_PREFIX}php-${PHP_VERSION}" = "target:php"
85-
}
86-
platforms = ["${DOCKER_PLATFORM}"]
87-
}
88-
89-
target "php-fpm-dev" {
90-
context = "layers/fpm-dev"
91-
tags = ["bref/${CPU_PREFIX}php-${PHP_VERSION}-fpm-dev"]
92-
args = {
93-
PHP_VERSION = "${PHP_VERSION}"
94-
CPU_PREFIX = "${CPU_PREFIX}"
95-
}
96-
contexts = {
97-
"bref/${CPU_PREFIX}build-php-${PHP_VERSION}" = "target:build-php"
98-
"bref/${CPU_PREFIX}php-${PHP_VERSION}" = "target:php"
99-
"bref/${CPU_PREFIX}php-${PHP_VERSION}-fpm" = "target:php-fpm"
100-
"bref/local-api-gateway" = "docker-image://bref/local-api-gateway:latest"
59+
"bref/${CPU_PREFIX}php-${PHP_VERSION}" = "target:php"
60+
"bref/local-api-gateway" = "docker-image://bref/local-api-gateway:latest"
10161
}
10262
platforms = ["${DOCKER_PLATFORM}"]
10363
}

layers/console/Dockerfile

Lines changed: 0 additions & 22 deletions
This file was deleted.

layers/console/README.md

Lines changed: 0 additions & 3 deletions
This file was deleted.

layers/console/bootstrap.sh

Lines changed: 0 additions & 27 deletions
This file was deleted.

layers/fpm-dev/Dockerfile

Lines changed: 0 additions & 45 deletions
This file was deleted.

layers/fpm/bootstrap.sh

Lines changed: 0 additions & 27 deletions
This file was deleted.

layers/fpm/bref.ini

Lines changed: 0 additions & 50 deletions
This file was deleted.

0 commit comments

Comments
 (0)