From 559de0b14b76d7ac6fd8b0c53ee377fb5fb51147 Mon Sep 17 00:00:00 2001 From: Ophir LOJKINE Date: Sun, 2 Aug 2026 18:41:56 +0200 Subject: [PATCH 1/2] Update AWS Lambda runtime to Amazon Linux 2023 --- .github/workflows/release.yml | 1 + CHANGELOG.md | 1 + README.md | 2 +- lambda.Dockerfile | 2 +- 4 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 979dffba..487e8bb9 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -108,6 +108,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v6 + - run: docker build -t sqlpage-lambda . -f lambda.Dockerfile --target runner - run: docker build -t sqlpage-lambda-builder . -f lambda.Dockerfile --target builder - run: docker run sqlpage-lambda-builder cat deploy.zip > sqlpage-aws-lambda.zip - uses: actions/upload-artifact@v7 diff --git a/CHANGELOG.md b/CHANGELOG.md index b7b9126b..bb0ab83d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## unreleased + - AWS Lambda builds and documentation now use the supported Amazon Linux 2023 custom runtime instead of the end-of-life Amazon Linux 2 runtime. - `sqlpage.send_mail` now supports rich email bodies. Use `body_html` for a caller-provided HTML alternative, or `body_md` to render Markdown as HTML. Messages retain a plain-text alternative; `body` may be omitted when `body_md` is used, and `body_md` and `body_html` cannot be combined. - Form `options_source` URLs now preserve existing query parameters when adding the dynamic `search` parameter. diff --git a/README.md b/README.md index 8cd2c952..0b70cdef 100644 --- a/README.md +++ b/README.md @@ -280,7 +280,7 @@ An easy way to do so is using the provided docker image: You can then just add your own SQL files to `sqlpage-aws-lambda.zip`, and [upload it to AWS Lambda](https://docs.aws.amazon.com/lambda/latest/dg/gettingstarted-package.html#gettingstarted-package-zip), -selecting *Custom runtime on Amazon Linux 2* as a runtime. +selecting *Custom runtime on Amazon Linux 2023* (`provided.al2023`) as the runtime. ### Hosting sql files directly inside the database diff --git a/lambda.Dockerfile b/lambda.Dockerfile index da5c5020..c8103183 100644 --- a/lambda.Dockerfile +++ b/lambda.Dockerfile @@ -12,7 +12,7 @@ RUN mv target/release/sqlpage bootstrap && \ size bootstrap && \ zip -9 -r deploy.zip bootstrap index.sql -FROM public.ecr.aws/lambda/provided:al2 AS runner +FROM public.ecr.aws/lambda/provided:al2023 AS runner COPY --from=builder /usr/src/sqlpage/bootstrap /main COPY --from=builder /usr/src/sqlpage/index.sql ./index.sql ENTRYPOINT ["/main"] From a3f128c9bb5c47e6a1ad81875e9312c573ddf3de Mon Sep 17 00:00:00 2001 From: lovasoa Date: Sun, 2 Aug 2026 19:33:16 +0200 Subject: [PATCH 2/2] Fix AWS Lambda release packaging --- CHANGELOG.md | 2 +- README.md | 4 ++++ configuration.md | 3 +++ lambda.Dockerfile | 6 ++++-- 4 files changed, 12 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bb0ab83d..8262b613 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ ## unreleased - - AWS Lambda builds and documentation now use the supported Amazon Linux 2023 custom runtime instead of the end-of-life Amazon Linux 2 runtime. + - AWS Lambda builds and documentation now use the supported Amazon Linux 2023 custom runtime instead of the end-of-life Amazon Linux 2 runtime. Release artifacts include the configuration directory required on Lambda's read-only filesystem. - `sqlpage.send_mail` now supports rich email bodies. Use `body_html` for a caller-provided HTML alternative, or `body_md` to render Markdown as HTML. Messages retain a plain-text alternative; `body` may be omitted when `body_md` is used, and `body_md` and `body_html` cannot be combined. - Form `options_source` URLs now preserve existing query parameters when adding the dynamic `search` parameter. diff --git a/README.md b/README.md index 0b70cdef..8248495f 100644 --- a/README.md +++ b/README.md @@ -282,6 +282,10 @@ You can then just add your own SQL files to `sqlpage-aws-lambda.zip`, and [upload it to AWS Lambda](https://docs.aws.amazon.com/lambda/latest/dg/gettingstarted-package.html#gettingstarted-package-zip), selecting *Custom runtime on Amazon Linux 2023* (`provided.al2023`) as the runtime. +The provided archive includes the empty `sqlpage` configuration directory required at startup. +You can add a `sqlpage.json` file, custom templates, or migrations to it. Keep the directory in the +archive because Lambda function packages are read-only and SQLPage cannot create it there. + ### Hosting sql files directly inside the database When running serverless, you can include the SQL files directly in the image that you are deploying. diff --git a/configuration.md b/configuration.md index 546a4bb6..2d5c3450 100644 --- a/configuration.md +++ b/configuration.md @@ -215,6 +215,9 @@ The configuration directory is the `./sqlpage/` folder by default. In the [official docker image](https://hub.docker.com/r/lovasoa/sqlpage), it is located in `/etc/sqlpage/`. It can be configured using the `--config-dir` command-line argument, or the `SQLPAGE_CONFIGURATION_DIRECTORY` environment variable. +At startup, SQLPage creates the configuration directory when it is absent and rejects the path when it is not a directory. +AWS Lambda release artifacts include an empty `./sqlpage` directory because deployed function packages are read-only. + It can contain - the [`sqlpage.json`](#configuring-sqlpage) configuration file, diff --git a/lambda.Dockerfile b/lambda.Dockerfile index c8103183..e7ea6349 100644 --- a/lambda.Dockerfile +++ b/lambda.Dockerfile @@ -10,9 +10,11 @@ RUN cargo build --release --features lambda-web RUN mv target/release/sqlpage bootstrap && \ strip --strip-all bootstrap && \ size bootstrap && \ - zip -9 -r deploy.zip bootstrap index.sql + zip -9 -j deploy.zip bootstrap src/index.sql && \ + zip -9 deploy.zip sqlpage/ FROM public.ecr.aws/lambda/provided:al2023 AS runner COPY --from=builder /usr/src/sqlpage/bootstrap /main -COPY --from=builder /usr/src/sqlpage/index.sql ./index.sql +COPY --from=builder /usr/src/sqlpage/src/index.sql ./index.sql +RUN mkdir -p ./sqlpage ENTRYPOINT ["/main"]