jdecool/scaleway-runtimepublic Fork
⑂ eff7276
Commits
⬇ Clone ▾
git clone https://git.rickub.com/jdecool/scaleway-runtime.git
git clone ssh://git@rickub.com/jdecool/scaleway-runtime.git

Host key fingerprint (ed25519): SHA256:iycHnxEyq0Q7uyVpB7JlznP0G7JrTPXLYRcAU5CSLhc — verify it before your first connect.

Download ZIP

feat(probe): record whether Composer runs its scripts at deploy timeUnverified

Scaleway documents installing the dependencies of a shipped composer.json;
whether it runs scripts (Symfony auto-scripts) and with --no-dev decides
whether shipping vendor/ is safe. Document the risk for the example.
Jérémy DECOOL committed 2026-11-13T22:30:50+01:00 Browse files
eff7276 parent: 38787d3
modified example/README.md +3 -0
@@ -32,6 +32,9 @@ APP_ENV=prod APP_SECRET=local php /tmp/function/vendor/bin/scaleway-serve
3232 ## Deploy it
3333
3434 The Terraform code is unvalidated: it was written against the `scaleway/scaleway` provider v2.92 documentation and never applied.
35+Scaleway documents that it installs the dependencies of a shipped `composer.json` at deploy time.
36+If it does so over the shipped `vendor/`, deploying this example likely fails: its `composer.lock` installs the runtime from `..`, which is not in the zip.
37+The [probe](../probe) settles whether and how Composer runs.
3538
3639 ```sh
3740 cd example
@@ -32,6 +32,9 @@ APP_ENV=prod APP_SECRET=local php /tmp/function/vendor/bin/scaleway-serve
32 ## Deploy it32 ## Deploy it
33 33
34 The Terraform code is unvalidated: it was written against the `scaleway/scaleway` provider v2.92 documentation and never applied.34 The Terraform code is unvalidated: it was written against the `scaleway/scaleway` provider v2.92 documentation and never applied.
35+Scaleway documents that it installs the dependencies of a shipped `composer.json` at deploy time.
36+If it does so over the shipped `vendor/`, deploying this example likely fails: its `composer.lock` installs the runtime from `..`, which is not in the zip.
37+The [probe](../probe) settles whether and how Composer runs.
35 38
36 ```sh39 ```sh
37 cd example40 cd example
modified probe/README.md +2 -2
@@ -16,7 +16,7 @@ terraform -chdir=probe/terraform apply
1616 export PROBE_URL=$(terraform -chdir=probe/terraform output -raw endpoint)
1717 ```
1818
19-To probe the PHP 8.4 runtime too, run `terraform -chdir=probe/terraform apply -var runtime=php84` afterwards and repeat the checks.
19+To probe the PHP 8.4 runtime too, run `terraform -chdir=probe/terraform apply -var runtime=php84` afterwards: it replaces the function, so export `PROBE_URL` again and repeat the checks in a separate results directory.
2020
2121 ## Run the checks
2222
@@ -90,7 +90,7 @@ The answers the files settle:
9090 | Body encoding (base64 or not), size limit | `06-*` |
9191 | `$_SERVER`, `argv`, `SCRIPT_FILENAME`, superglobals | `01-facts.json` `globals` |
9292 | Read-only code dir, writable `/tmp`, free space | `01-facts.json` `filesystem` |
93-| Shipped `vendor/` kept, Composer run at deploy | `01-facts.json` `vendorMarkerKept`, `composerLockPresent`, `vendorListing` |
93+| Shipped `vendor/` kept, Composer run at deploy (scripts, `--no-dev`) | `01-facts.json` `vendorMarkerKept`, `composerLockPresent`, `composerRun`, `vendorListing` |
9494 | stdout, uncaught exceptions | `07-*.txt`, logs |
9595
9696 ## Clean up
@@ -16,7 +16,7 @@ terraform -chdir=probe/terraform apply
16 export PROBE_URL=$(terraform -chdir=probe/terraform output -raw endpoint)16 export PROBE_URL=$(terraform -chdir=probe/terraform output -raw endpoint)
17 ```17 ```
18 18
19-To probe the PHP 8.4 runtime too, run `terraform -chdir=probe/terraform apply -var runtime=php84` afterwards and repeat the checks.19+To probe the PHP 8.4 runtime too, run `terraform -chdir=probe/terraform apply -var runtime=php84` afterwards: it replaces the function, so export `PROBE_URL` again and repeat the checks in a separate results directory.
20 20
21 ## Run the checks21 ## Run the checks
22 22
@@ -90,7 +90,7 @@ The answers the files settle:
90 | Body encoding (base64 or not), size limit | `06-*` |90 | Body encoding (base64 or not), size limit | `06-*` |
91 | `$_SERVER`, `argv`, `SCRIPT_FILENAME`, superglobals | `01-facts.json` `globals` |91 | `$_SERVER`, `argv`, `SCRIPT_FILENAME`, superglobals | `01-facts.json` `globals` |
92 | Read-only code dir, writable `/tmp`, free space | `01-facts.json` `filesystem` |92 | Read-only code dir, writable `/tmp`, free space | `01-facts.json` `filesystem` |
93-| Shipped `vendor/` kept, Composer run at deploy | `01-facts.json` `vendorMarkerKept`, `composerLockPresent`, `vendorListing` |93+| Shipped `vendor/` kept, Composer run at deploy (scripts, `--no-dev`) | `01-facts.json` `vendorMarkerKept`, `composerLockPresent`, `composerRun`, `vendorListing` |
94 | stdout, uncaught exceptions | `07-*.txt`, logs |94 | stdout, uncaught exceptions | `07-*.txt`, logs |
95 95
96 ## Clean up96 ## Clean up
modified probe/function/composer.json +6 -1
@@ -1,5 +1,10 @@
11 {
22 "name": "jdecool/scaleway-runtime-probe",
33 "description": "Ships vendor/ to find out whether Scaleway runs Composer over it at deploy time",
4- "require": {}
4+ "require": {},
5+ "scripts": {
6+ "record-composer-run": "@php -r \"file_put_contents('composer-run.json', json_encode(['devMode' => getenv('COMPOSER_DEV_MODE'), 'cwd' => getcwd(), 'at' => date(DATE_ATOM)]));\"",
7+ "post-install-cmd": "@record-composer-run",
8+ "post-update-cmd": "@record-composer-run"
9+ }
510 }
@@ -1,5 +1,10 @@
1 {1 {
2 "name": "jdecool/scaleway-runtime-probe",2 "name": "jdecool/scaleway-runtime-probe",
3 "description": "Ships vendor/ to find out whether Scaleway runs Composer over it at deploy time",3 "description": "Ships vendor/ to find out whether Scaleway runs Composer over it at deploy time",
4- "require": {}4+ "require": {},
5+ "scripts": {
6+ "record-composer-run": "@php -r \"file_put_contents('composer-run.json', json_encode(['devMode' => getenv('COMPOSER_DEV_MODE'), 'cwd' => getcwd(), 'at' => date(DATE_ATOM)]));\"",
7+ "post-install-cmd": "@record-composer-run",
8+ "post-update-cmd": "@record-composer-run"
9+ }
5 }10 }
modified probe/function/handler.php +2 -0
@@ -112,6 +112,8 @@ function facts($event, $context, int $invocations, string $firstInvocationAt): a
112112 'vendorListing' => @scandir(__DIR__.'/vendor'),
113113 'vendorMarkerKept' => defined('PROBE_VENDOR_MARKER'),
114114 'composerLockPresent' => is_file(__DIR__.'/composer.lock'),
115+ // Written by the composer.json scripts: tells whether Composer ran its scripts, and with --no-dev or not.
116+ 'composerRun' => json_decode((string) @file_get_contents(__DIR__.'/composer-run.json'), true),
115117 'tmpWritable' => is_writable('/tmp'),
116118 'tmpWriteWorks' => false !== @file_put_contents($tmpProbe, 'x') && @unlink($tmpProbe),
117119 'tmpFreeBytes' => @disk_free_space('/tmp'),
@@ -112,6 +112,8 @@ function facts($event, $context, int $invocations, string $firstInvocationAt): a
112 'vendorListing' => @scandir(__DIR__.'/vendor'),112 'vendorListing' => @scandir(__DIR__.'/vendor'),
113 'vendorMarkerKept' => defined('PROBE_VENDOR_MARKER'),113 'vendorMarkerKept' => defined('PROBE_VENDOR_MARKER'),
114 'composerLockPresent' => is_file(__DIR__.'/composer.lock'),114 'composerLockPresent' => is_file(__DIR__.'/composer.lock'),
115+ // Written by the composer.json scripts: tells whether Composer ran its scripts, and with --no-dev or not.
116+ 'composerRun' => json_decode((string) @file_get_contents(__DIR__.'/composer-run.json'), true),
115 'tmpWritable' => is_writable('/tmp'),117 'tmpWritable' => is_writable('/tmp'),
116 'tmpWriteWorks' => false !== @file_put_contents($tmpProbe, 'x') && @unlink($tmpProbe),118 'tmpWriteWorks' => false !== @file_put_contents($tmpProbe, 'x') && @unlink($tmpProbe),
117 'tmpFreeBytes' => @disk_free_space('/tmp'),119 'tmpFreeBytes' => @disk_free_space('/tmp'),