@ts-cloud/core 0.4.0 → 0.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +22 -14
- package/dist/serverless-php/dockerfile.d.ts +7 -7
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -45909,6 +45909,7 @@ function composeServerlessAppTemplate(opts) {
|
|
|
45909
45909
|
var PHP_LAYER_EXTENSIONS = [
|
|
45910
45910
|
"cli",
|
|
45911
45911
|
"fpm",
|
|
45912
|
+
"curl",
|
|
45912
45913
|
"mbstring",
|
|
45913
45914
|
"xml",
|
|
45914
45915
|
"pdo",
|
|
@@ -45931,13 +45932,18 @@ function phpLayerBuildStage(phpVersion, asName) {
|
|
|
45931
45932
|
const scl = `php${phpVersion.replace(".", "")}`;
|
|
45932
45933
|
const packages = phpLayerPackages(phpVersion).join(" \\\n ");
|
|
45933
45934
|
const sclRoot = `/opt/remi/${scl}/root`;
|
|
45934
|
-
const
|
|
45935
|
+
const sclEtc = `/etc/opt/remi/${scl}`;
|
|
45936
|
+
const from = asName ? `FROM almalinux:9 AS ${asName}` : "FROM almalinux:9";
|
|
45935
45937
|
return `${from}
|
|
45936
45938
|
|
|
45937
|
-
# Remi
|
|
45938
|
-
|
|
45939
|
+
# Build PHP on AlmaLinux 9 (where Remi's version-isolated SCL packages install
|
|
45940
|
+
# cleanly — Remi's release RPM rejects Amazon Linux 2023). AlmaLinux 9 shares
|
|
45941
|
+
# glibc 2.34 with the provided.al2023 Lambda runtime, and the relocation step
|
|
45942
|
+
# below bundles every non-glibc shared lib under /opt/php/lib, so the resulting
|
|
45943
|
+
# /opt tree runs on Lambda's provided.al2023.
|
|
45944
|
+
RUN dnf -y install epel-release dnf-plugins-core 'dnf-command(config-manager)' && \\
|
|
45945
|
+
dnf config-manager --set-enabled crb && \\
|
|
45939
45946
|
dnf -y install https://rpms.remirepo.net/enterprise/remi-release-9.rpm && \\
|
|
45940
|
-
dnf -y update && \\
|
|
45941
45947
|
dnf -y install \\
|
|
45942
45948
|
${packages} \\
|
|
45943
45949
|
findutils tar gzip && \\
|
|
@@ -45950,7 +45956,10 @@ RUN set -eux; \\
|
|
|
45950
45956
|
cp ${sclRoot}/usr/sbin/php-fpm /opt/php/sbin/php-fpm; \\
|
|
45951
45957
|
EXT_DIR="$(${sclRoot}/usr/bin/php -r 'echo ini_get("extension_dir");')"; \\
|
|
45952
45958
|
cp -a "$EXT_DIR"/*.so /opt/php/lib/php/modules/ || true; \\
|
|
45953
|
-
cp -a ${
|
|
45959
|
+
cp -a ${sclEtc}/php.d/*.ini /opt/php/etc/php.d/ 2>/dev/null || true; \\
|
|
45960
|
+
# Rewrite any absolute extension/zend_extension paths to bare names so they
|
|
45961
|
+
# resolve against the relocated extension_dir.
|
|
45962
|
+
sed -i -E "s#(zend_)?extension *= *.*/([^/]+\\.so)#\\1extension=\\2#" /opt/php/etc/php.d/*.ini 2>/dev/null || true; \\
|
|
45954
45963
|
# Copy shared-library dependencies of php, php-fpm, and the extension modules.
|
|
45955
45964
|
for bin in /opt/php/bin/php /opt/php/sbin/php-fpm /opt/php/lib/php/modules/*.so; do \\
|
|
45956
45965
|
ldd "$bin" 2>/dev/null | awk '/=>/{print $3}/ld-linux/{print $1}' | sort -u | while read -r lib; do \\
|
|
@@ -45958,10 +45967,9 @@ RUN set -eux; \\
|
|
|
45958
45967
|
done; \\
|
|
45959
45968
|
done
|
|
45960
45969
|
|
|
45961
|
-
#
|
|
45970
|
+
# Build the relocated main php.ini: extension_dir + every per-extension directive.
|
|
45962
45971
|
RUN printf 'extension_dir=/opt/php/lib/php/modules\\n' > /opt/php/etc/php.ini && \\
|
|
45963
45972
|
cat /opt/php/etc/php.d/*.ini >> /opt/php/etc/php.ini 2>/dev/null || true
|
|
45964
|
-
ENV PHP_INI_SCAN_DIR=/opt/php/etc/php.d
|
|
45965
45973
|
|
|
45966
45974
|
# Runtime assets (bootstrap, runtime loops, fpm config) are added by the build
|
|
45967
45975
|
# orchestrator after the image is produced. Export /opt as the layer payload.
|
|
@@ -46052,8 +46060,7 @@ function buildBunRuntimeLayerZip(options) {
|
|
|
46052
46060
|
const step = options.onStep ?? (() => {});
|
|
46053
46061
|
const stage = mkdtempSync2(join7(tmpdir2(), "tscloud-bun-layer-"));
|
|
46054
46062
|
try {
|
|
46055
|
-
const
|
|
46056
|
-
const url = `https://github.com/oven-sh/bun/releases/download/${tag}/${bunArch}.zip`;
|
|
46063
|
+
const url = version ? `https://github.com/oven-sh/bun/releases/download/bun-v${version}/${bunArch}.zip` : `https://github.com/oven-sh/bun/releases/latest/download/${bunArch}.zip`;
|
|
46057
46064
|
step(`downloading Bun ${version || "latest"} (${architecture})`);
|
|
46058
46065
|
const zipPath = join7(stage, "bun.zip");
|
|
46059
46066
|
fetchToFile(url, zipPath);
|
|
@@ -46279,7 +46286,7 @@ var LARAVEL_SERVERLESS_BUILD_STEPS = [
|
|
|
46279
46286
|
];
|
|
46280
46287
|
// src/serverless-php/layer-build.ts
|
|
46281
46288
|
import { execFileSync as execFileSync2 } from "node:child_process";
|
|
46282
|
-
import { existsSync as existsSync5, mkdtempSync as mkdtempSync3, readdirSync as readdirSync5, readFileSync as readFileSync6, rmSync as rmSync3, statSync as statSync3, writeFileSync as writeFileSync5 } from "node:fs";
|
|
46289
|
+
import { existsSync as existsSync5, mkdirSync as mkdirSync2, mkdtempSync as mkdtempSync3, readdirSync as readdirSync5, readFileSync as readFileSync6, rmSync as rmSync3, statSync as statSync3, writeFileSync as writeFileSync5 } from "node:fs";
|
|
46283
46290
|
import { tmpdir as tmpdir3 } from "node:os";
|
|
46284
46291
|
import { join as join9, relative as relative2 } from "node:path";
|
|
46285
46292
|
function* walk(dir) {
|
|
@@ -46301,16 +46308,17 @@ function buildPhpRuntimeLayerZip(options = {}) {
|
|
|
46301
46308
|
writeFileSync5(join9(stage, "Dockerfile"), generatePhpLayerDockerfile(options));
|
|
46302
46309
|
step("Building PHP runtime image (docker)");
|
|
46303
46310
|
execFileSync2("docker", ["build", "--platform", platform, "-t", imageTag, stage], { stdio: "inherit" });
|
|
46304
|
-
step("Extracting /opt from image");
|
|
46311
|
+
step("Extracting /opt/php from image");
|
|
46305
46312
|
const cid = execFileSync2("docker", ["create", "--platform", platform, imageTag], { encoding: "utf-8" }).trim();
|
|
46306
46313
|
const optDir = join9(stage, "opt");
|
|
46314
|
+
mkdirSync2(optDir, { recursive: true });
|
|
46307
46315
|
try {
|
|
46308
|
-
execFileSync2("docker", ["cp", `${cid}:/opt
|
|
46316
|
+
execFileSync2("docker", ["cp", `${cid}:/opt/php`, join9(optDir, "php")], { stdio: "inherit" });
|
|
46309
46317
|
} finally {
|
|
46310
46318
|
execFileSync2("docker", ["rm", cid], { stdio: "ignore" });
|
|
46311
46319
|
}
|
|
46312
|
-
if (!existsSync5(optDir))
|
|
46313
|
-
throw new Error("layer build produced no /opt
|
|
46320
|
+
if (!existsSync5(join9(optDir, "php", "bin", "php")))
|
|
46321
|
+
throw new Error("layer build produced no /opt/php/bin/php");
|
|
46314
46322
|
const entries = [];
|
|
46315
46323
|
for (const file of walk(optDir)) {
|
|
46316
46324
|
const rel = relative2(optDir, file).replace(/\\/g, "/");
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Generates the Dockerfile that builds the ts-cloud PHP runtime layer for AWS
|
|
3
|
-
* Lambda (`provided.al2023`). Built
|
|
4
|
-
*
|
|
3
|
+
* Lambda (`provided.al2023`). Built on AlmaLinux 9 — it shares glibc 2.34 with
|
|
4
|
+
* the Lambda runtime, and (unlike Amazon Linux 2023) the Remi repository's
|
|
5
|
+
* release RPM installs there, giving version-isolated PHP SCL packages
|
|
6
|
+
* (`php83-php-*` under `/opt/remi/php83/`) so the same recipe builds PHP 8.1–8.4.
|
|
5
7
|
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* binary, php-fpm, extensions, and their shared-library dependencies are then
|
|
10
|
-
* relocated under `/opt` so the archive works as a Lambda layer.
|
|
8
|
+
* The PHP binary, php-fpm, extensions, and all their non-glibc shared-library
|
|
9
|
+
* dependencies are relocated + bundled under `/opt` so the archive runs as a
|
|
10
|
+
* provided.al2023 Lambda layer.
|
|
11
11
|
*
|
|
12
12
|
* Build it in CI (Docker required) — see {@link buildPhpRuntimeLayerZip}. The
|
|
13
13
|
* resulting /opt tree is published as a Lambda layer.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ts-cloud/core",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Core CloudFormation generation library for ts-cloud",
|
|
6
6
|
"author": "Chris Breuer <chris@stacksjs.com>",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"typecheck": "tsc --noEmit"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@ts-cloud/aws-types": "0.4.
|
|
34
|
+
"@ts-cloud/aws-types": "0.4.2"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
37
|
"typescript": "^5.9.3"
|