Skip to content

Commit 2670d44

Browse files
committed
Revert #65
1 parent 8308bf1 commit 2670d44

File tree

6 files changed

+45
-39
lines changed

6 files changed

+45
-39
lines changed

Makefile

+10-10
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ layer-console:
5151
# This rule matches with a wildcard, for example `layer-php-80`.
5252
# The `$*` variable will contained the matched part, in this case `php-80`.
5353
layer-%:
54-
./utils/docker-zip-dir.sh bref/$* ${CPU_PREFIX}$*
54+
./utils/docker-zip-dir.sh bref/${CPU_PREFIX}$* ${CPU_PREFIX}$*
5555

5656

5757
# Upload the layers to AWS Lambda
@@ -74,8 +74,8 @@ upload-to-docker-hub: upload-to-docker-hub-php-80 upload-to-docker-hub-php-81 up
7474
upload-to-docker-hub-php-%:
7575
# While in beta we tag and push the `:2` version, later we'll push `:latest` as well
7676
for image in \
77-
"bref/php-$*" "bref/php-$*-fpm" "bref/php-$*-console" \
78-
"bref/build-php-$*" "bref/php-$*-fpm-dev"; \
77+
"bref/${CPU_PREFIX}php-$*" "bref/${CPU_PREFIX}php-$*-fpm" "bref/${CPU_PREFIX}php-$*-console" \
78+
"bref/${CPU_PREFIX}build-php-$*" "bref/${CPU_PREFIX}php-$*-fpm-dev"; \
7979
do \
8080
docker tag $$image $$image:2 ; \
8181
docker push $$image:2 ; \
@@ -96,10 +96,10 @@ clean: clean-80 clean-81 clean-82
9696
rm -f output/${CPU_PREFIX}*.zip
9797
clean-%:
9898
# Clean Docker images to force rebuilding them
99-
docker image rm --force bref/build-php-$* \
100-
bref/php-$* \
101-
bref/php-$*-zip \
102-
bref/php-$*-fpm \
103-
bref/php-$*-fpm-zip \
104-
bref/php-$*-fpm-dev \
105-
bref/php-$*-console
99+
docker image rm --force bref/${CPU_PREFIX}build-php-$* \
100+
bref/${CPU_PREFIX}php-$* \
101+
bref/${CPU_PREFIX}php-$*-zip \
102+
bref/${CPU_PREFIX}php-$*-fpm \
103+
bref/${CPU_PREFIX}php-$*-fpm-zip \
104+
bref/${CPU_PREFIX}php-$*-fpm-dev \
105+
bref/${CPU_PREFIX}php-$*-console

docker-bake.hcl

+20-15
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ group "default" {
55
variable "CPU" {
66
default = "x86"
77
}
8+
variable "CPU_PREFIX" {
9+
default = ""
10+
}
811
variable "PHP_VERSION" {
912
default = "80"
1013
}
@@ -18,7 +21,7 @@ variable "DOCKER_PLATFORM" {
1821
target "build-php" {
1922
dockerfile = "php-${PHP_VERSION}/Dockerfile"
2023
target = "build-environment"
21-
tags = ["bref/build-php-${PHP_VERSION}"]
24+
tags = ["bref/${CPU_PREFIX}build-php-${PHP_VERSION}"]
2225
args = {
2326
"IMAGE_VERSION_SUFFIX" = "${IMAGE_VERSION_SUFFIX}"
2427
}
@@ -28,26 +31,26 @@ target "build-php" {
2831
target "php" {
2932
dockerfile = "php-${PHP_VERSION}/Dockerfile"
3033
target = "function"
31-
tags = ["bref/php-${PHP_VERSION}"]
34+
tags = ["bref/${CPU_PREFIX}php-${PHP_VERSION}"]
3235
args = {
3336
"IMAGE_VERSION_SUFFIX" = "${IMAGE_VERSION_SUFFIX}"
3437
}
3538
contexts = {
36-
"bref/build-php-${PHP_VERSION}" = "target:build-php"
39+
"bref/${CPU_PREFIX}build-php-${PHP_VERSION}" = "target:build-php"
3740
}
3841
platforms = ["${DOCKER_PLATFORM}"]
3942
}
4043

4144
target "php-fpm" {
4245
dockerfile = "php-${PHP_VERSION}/Dockerfile"
4346
target = "fpm"
44-
tags = ["bref/php-${PHP_VERSION}-fpm"]
47+
tags = ["bref/${CPU_PREFIX}php-${PHP_VERSION}-fpm"]
4548
args = {
4649
"IMAGE_VERSION_SUFFIX" = "${IMAGE_VERSION_SUFFIX}"
4750
}
4851
contexts = {
49-
"bref/build-php-${PHP_VERSION}" = "target:build-php"
50-
"bref/php-${PHP_VERSION}" = "target:php"
52+
"bref/${CPU_PREFIX}build-php-${PHP_VERSION}" = "target:build-php"
53+
"bref/${CPU_PREFIX}php-${PHP_VERSION}" = "target:php"
5154
}
5255
platforms = ["${DOCKER_PLATFORM}"]
5356
}
@@ -58,36 +61,38 @@ target "console-zip" {
5861
tags = ["bref/console-zip"]
5962
args = {
6063
PHP_VERSION = "${PHP_VERSION}"
64+
CPU_PREFIX = "${CPU_PREFIX}"
6165
}
6266
platforms = ["${DOCKER_PLATFORM}"]
6367
}
6468

6569
target "console" {
6670
context = "layers/console"
6771
target = "console"
68-
tags = ["bref/php-${PHP_VERSION}-console"]
72+
tags = ["bref/${CPU_PREFIX}php-${PHP_VERSION}-console"]
6973
args = {
7074
PHP_VERSION = "${PHP_VERSION}"
75+
CPU_PREFIX = "${CPU_PREFIX}"
7176
}
7277
contexts = {
73-
"bref/build-php-${PHP_VERSION}" = "target:build-php"
74-
"bref/php-${PHP_VERSION}" = "target:php"
78+
"bref/${CPU_PREFIX}build-php-${PHP_VERSION}" = "target:build-php"
79+
"bref/${CPU_PREFIX}php-${PHP_VERSION}" = "target:php"
7580
}
7681
platforms = ["${DOCKER_PLATFORM}"]
7782
}
7883

7984
target "php-fpm-dev" {
8085
context = "layers/fpm-dev"
81-
tags = ["bref/php-${PHP_VERSION}-fpm-dev"]
86+
tags = ["bref/${CPU_PREFIX}php-${PHP_VERSION}-fpm-dev"]
8287
args = {
8388
PHP_VERSION = "${PHP_VERSION}"
84-
"CPU" = "${CPU}"
89+
CPU_PREFIX = "${CPU_PREFIX}"
8590
}
8691
contexts = {
87-
"bref/build-php-${PHP_VERSION}" = "target:build-php"
88-
"bref/php-${PHP_VERSION}" = "target:php"
89-
"bref/php-${PHP_VERSION}-fpm" = "target:php-fpm"
90-
"bref/local-api-gateway" = "docker-image://bref/local-api-gateway:latest"
92+
"bref/${CPU_PREFIX}build-php-${PHP_VERSION}" = "target:build-php"
93+
"bref/${CPU_PREFIX}php-${PHP_VERSION}" = "target:php"
94+
"bref/${CPU_PREFIX}php-${PHP_VERSION}-fpm" = "target:php-fpm"
95+
"bref/local-api-gateway" = "docker-image://bref/local-api-gateway:latest"
9196
}
9297
platforms = ["${DOCKER_PLATFORM}"]
9398
}

layers/console/Dockerfile

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# syntax = docker/dockerfile:1.4
22
ARG PHP_VERSION
3+
ARG CPU_PREFIX
34

45

56
# This image only contains what's going in the layer zip file,
@@ -14,7 +15,7 @@ COPY --link bootstrap.sh /var/runtime/bootstrap
1415

1516

1617
# This image is published to Docker Hub and replicates Lambda
17-
FROM bref/php-$PHP_VERSION as console
18+
FROM bref/${CPU_PREFIX}php-$PHP_VERSION as console
1819

1920
# Copy the console layer into /opt
2021
COPY --link --from=console-zip /opt /opt

layers/fpm-dev/Dockerfile

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
# syntax = docker/dockerfile:1.4
2-
ARG CPU
2+
ARG CPU_PREFIX
33
ARG PHP_VERSION
44

55

6-
FROM bref/build-php-$PHP_VERSION as build_extensions
6+
FROM bref/${CPU_PREFIX}build-php-$PHP_VERSION as build_extensions
77

88
ARG PHP_VERSION
99

@@ -16,11 +16,11 @@ RUN cp $(php -r "echo ini_get('extension_dir');")/xdebug.so /opt/bref/extensions
1616
# Install Blackfire
1717
# https://blackfire.io/docs/up-and-running/installation?action=install&mode=full&version=latest&mode=full&location=server&os=manual&language=php#install-the-php-probe
1818
ARG BLACKFIRE_VERSION=1.86.1
19-
RUN if [[ $CPU == "x86" ]]; then curl -A "Docker" -o /opt/bref/extensions/blackfire.so -L -s "https://packages.blackfire.io/binaries/blackfire-php/$BLACKFIRE_VERSION/blackfire-php-linux_amd64-php-"$PHP_VERSION".so"; fi
20-
RUN if [[ $CPU == "arm" ]]; then curl -A "Docker" -o /opt/bref/extensions/blackfire.so -L -s "https://packages.blackfire.io/binaries/blackfire-php/$BLACKFIRE_VERSION/blackfire-php-linux_arm64-php-"$PHP_VERSION".so"; fi
19+
RUN if [[ $CPU_PREFIX == "" ]]; then curl -A "Docker" -o /opt/bref/extensions/blackfire.so -L -s "https://packages.blackfire.io/binaries/blackfire-php/$BLACKFIRE_VERSION/blackfire-php-linux_amd64-php-"$PHP_VERSION".so"; fi
20+
RUN if [[ $CPU_PREFIX == "arm-" ]]; then curl -A "Docker" -o /opt/bref/extensions/blackfire.so -L -s "https://packages.blackfire.io/binaries/blackfire-php/$BLACKFIRE_VERSION/blackfire-php-linux_arm64-php-"$PHP_VERSION".so"; fi
2121

2222

23-
FROM bref/php-${PHP_VERSION}-fpm
23+
FROM bref/${CPU_PREFIX}php-${PHP_VERSION}-fpm
2424

2525
COPY --link --from=build_extensions /opt /opt
2626
COPY --link bref-entrypoint.sh /

tests/Makefile

+7-7
Original file line numberDiff line numberDiff line change
@@ -5,36 +5,36 @@ test: test-80 test-81 test-82
55
# This rule matches with a wildcard, for example `test-80`.
66
# The `$*` variable will contained the matched part, in this case `80`.
77
test-%: vendor
8-
docker run --platform=${DOCKER_PLATFORM} --rm -v=$(PWD):/var/task:ro --entrypoint=php bref/php-$* \
8+
docker run --platform=${DOCKER_PLATFORM} --rm -v=$(PWD):/var/task:ro --entrypoint=php bref/${CPU_PREFIX}php-$* \
99
test_1_binary.php $*
1010

11-
docker run --platform=${DOCKER_PLATFORM} --rm -v=$(PWD):/var/task:ro --entrypoint=php bref/php-$* \
11+
docker run --platform=${DOCKER_PLATFORM} --rm -v=$(PWD):/var/task:ro --entrypoint=php bref/${CPU_PREFIX}php-$* \
1212
test_2_extensions.php
1313

1414
docker run --platform=${DOCKER_PLATFORM} --rm -v=$(PWD):/var/task:ro --entrypoint=php \
15-
-e PHP_INI_SCAN_DIR="/opt/bref/etc/php/conf.d/:/var/task/" bref/php-$* \
15+
-e PHP_INI_SCAN_DIR="/opt/bref/etc/php/conf.d/:/var/task/" bref/${CPU_PREFIX}php-$* \
1616
test_3_manual_enabling_extensions.php
1717

1818
# Test function handler
1919
docker stop test-${CPU_PREFIX}php-$* 2> /dev/null || true # silence errors
2020
docker run --platform=${DOCKER_PLATFORM} --rm --detach -v=$(PWD):/var/task:ro --name test-${CPU_PREFIX}php-$* \
21-
bref/php-$* test_4_function_handler.php
21+
bref/${CPU_PREFIX}php-$* test_4_function_handler.php
2222
docker exec test-${CPU_PREFIX}php-$* php test_4_function_invocation.php \
2323
|| (docker logs test-${CPU_PREFIX}php-$* && exit 1)
2424
docker stop test-${CPU_PREFIX}php-$*
2525

2626
# Test FPM handler
2727
docker stop test-${CPU_PREFIX}php-$*-fpm 2> /dev/null || true # silence errors
2828
docker run --platform=${DOCKER_PLATFORM} --rm --detach -v=$(PWD):/var/task:ro --name test-${CPU_PREFIX}php-$*-fpm \
29-
bref/php-$*-fpm test_5_fpm_handler.php
29+
bref/${CPU_PREFIX}php-$*-fpm test_5_fpm_handler.php
3030
docker exec test-${CPU_PREFIX}php-$*-fpm php test_5_fpm_invocation.php \
3131
|| (docker logs test-${CPU_PREFIX}php-$*-fpm && exit 1) # print logs in case of failure
3232
docker stop test-${CPU_PREFIX}php-$*-fpm
3333

3434
# Test console handler
3535
docker stop test-${CPU_PREFIX}php-$*-console 2> /dev/null || true # silence errors
3636
docker run --platform=${DOCKER_PLATFORM} --rm --detach -v=$(PWD):/var/task:ro --name test-${CPU_PREFIX}php-$*-console \
37-
bref/php-$*-console test_6_console_handler.php
37+
bref/${CPU_PREFIX}php-$*-console test_6_console_handler.php
3838
docker exec test-${CPU_PREFIX}php-$*-console php test_6_console_invocation.php \
3939
|| (docker logs test-${CPU_PREFIX}php-$*-console && exit 1) # print logs in case of failure
4040
docker stop test-${CPU_PREFIX}php-$*-console
@@ -43,7 +43,7 @@ test-%: vendor
4343
docker stop test-${CPU_PREFIX}php-$*-test7 2> /dev/null || true # silence errors
4444
docker run --platform=${DOCKER_PLATFORM} --rm --detach -v=$(PWD):/var/task:ro --name test-${CPU_PREFIX}php-$*-test7 \
4545
-e PHP_INI_SCAN_DIR="/opt/bref/etc/php/conf.d/:/var/task/" \
46-
bref/php-$* test_4_function_handler.php
46+
bref/${CPU_PREFIX}php-$* test_4_function_handler.php
4747
docker exec test-${CPU_PREFIX}php-$*-test7 php test_7_custom_ini_scan_dir.php \
4848
|| (docker logs test-${CPU_PREFIX}php-$*-test7 && exit 1) # print logs in case of failure
4949
docker stop test-${CPU_PREFIX}php-$*-test7

utils/docker-zip-dir.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ mkdir "output/$LAYER_NAME"
1313
# Remove any previously failed container if it exists
1414
docker rm -f bref-export-zip 2>/dev/null || true
1515

16-
docker create --name bref-export-zip --platform "$DOCKER_PLATFORM" "$IMAGE_NAME"
16+
docker create --name bref-export-zip "$IMAGE_NAME"
1717

1818
docker cp bref-export-zip:/opt/. "output/$LAYER_NAME"
1919

0 commit comments

Comments
 (0)