Add reproducible static PHP 8.2 build for the Lambda binary - #165
Conversation
Replaces the undocumented pre-8.x php in s3://hm-linter/bin with a fully-static PHP 8.2 built via static-php-cli. Static linking removes the libcrypt.so dependency and runs on any Lambda runtime OS.
wisyhambolu
left a comment
There was a problem hiding this comment.
The approach itself looks right to me, I'm happy to approve once these are in.
|
|
||
| WORKDIR /build | ||
|
|
||
| RUN curl -fsSL https://dl.static-php.dev/static-php-cli/spc-bin/nightly/spc-linux-x86_64 \ |
There was a problem hiding this comment.
From what I can see, the spc toolchain is currently an unpinned nightly with no integrity check.
curl -fsSL https://dl.static-php.dev/static-php-cli/spc-bin/nightly/spc-linux-x86_64
That means that two rebuilds a week apart can produce different binaries, and nothing verifies what we downloaded. This opens the door for a potential supply-chain issue.
It's not just theoretical drift in this case, that path is also the old unversioned location. Upstream's docs now point at /v3/spc-bin/nightly/, and the two currently serve different builds, so we're already getting a different toolchain than the docs describe.
dl.static-php.dev has no versioned directories or checksums to pin against, but GitHub Releases does, tagged assets with published sha256 digests. I verified 2.8.5 downloads clean and contains a single spc executable:
ARG SPC_VERSION=2.8.5
ARG SPC_SHA256=523ba4279c54c7a377156c0dd3a36adf92ee64b01e9a7f5e9e2ec084b8e458e5
RUN curl -fsSL "https://github.com/crazywhalecc/static-php-cli/releases/download/${SPC_VERSION}/spc-linux-x86_64.tar.gz" -o /tmp/spc.tar.gz \
&& echo "${SPC_SHA256} /tmp/spc.tar.gz" | sha256sum -c - \
&& tar -xzf /tmp/spc.tar.gz -C /usr/local/bin spc \
&& chmod +x /usr/local/bin/spc \
&& rm /tmp/spc.tar.gz
I'll suggest we pin the SPC version from the GitHub release and validate via the SHA.
| # runtime-OS-independent (AL1/AL2/AL2023). Build via scripts/build-php.sh. | ||
| FROM --platform=linux/amd64 debian:bookworm AS build | ||
|
|
||
| ARG PHP_VERSION=8.2 |
There was a problem hiding this comment.
Similar pinning issue here, PHP_VERSION=8.2 is a minor-version pin
spc resolves that to whatever the current 8.2 patch release is, so rebuilds silently pick up a different PHP and we can't tell from the repo what's actually deployed. I think it is worth pinning to the full patch version (8.2.29 or whichever you validated against) so the Dockerfile records what we shipped.
There was a problem hiding this comment.
I would typically agree, but given this is just for running phpcs I think it might be easier to just stick to minor, else it's going to be a lot of effort to always keep the version up to date. I am easy either way though.
Replaces the undocumented pre-8.x
phpins3://hm-linter/binwith a fully-static PHP 8.2 built via static-php-cli. Static linking removes thelibcrypt.sodependency and runs on any Lambda runtime OS.Dockerfile.php— compiles static PHP 8.2 with the extensions phpcs/WPCS/VIP needscripts/build-php.sh— builds./bin/php;--uploadsyncs to S3Build + publish (run per bucket, then redeploy both bots):
Note:
build:lib/deploy:checkstill pulllibcrypt.so; harmless with a static binary, safe to drop as a follow-up once the new binary is live.Bref's PHP layer was tested on a real Lambda (Node 22/AL2023) and failed:
libreadline.so.6: cannot open shared object file. The static binary has no dynamic dependencies and is not affected.Validated: runs on real Lambda, and lints correctly via the
phpcsmodule using theHM-Minimumstandard (v2.5.0).Part of https://github.com/humanmade/product-dev/issues/1665