Skip to content

perf(docker): replace inline SQLite compilation with pre-built image - #20824

Merged
desertaxle merged 25 commits into
mainfrom
feat/sqlite-builder-cache-image
Feb 27, 2026
Merged

perf(docker): replace inline SQLite compilation with pre-built image#20824
desertaxle merged 25 commits into
mainfrom
feat/sqlite-builder-cache-image

Conversation

@desertaxle

@desertaxle desertaxle commented Feb 24, 2026

Copy link
Copy Markdown
Member

This PR replaces the slowest stage in our Docker builds — compiling SQLite from source — with a pre-built image pulled from DockerHub.

How it works

The SQLite compilation only needs to happen once per version, not on every docker build. We now publish a versioned prefecthq/prefect-sqlite:<version> image to DockerHub that both Dockerfile and client/Dockerfile pull as a named stage. The COPY --from=sqlite-builder lines in the final stages are completely unchanged.

To update SQLite in the future:

  1. Bump SQLITE_VERSION in Dockerfile, client/Dockerfile, and Dockerfile.sqlite-builder
  2. Run the sqlite-builder workflow manually via workflow_dispatch to publish the new image
  3. The Docker builds will automatically pick up the new tag

Changes

  • Dockerfile.sqlite-builder — new standalone Dockerfile that builds SQLite from source and installs it to /usr/local; published as prefecthq/prefect-sqlite:<version> on DockerHub for linux/amd64 and linux/arm64
  • .github/workflows/sqlite-builder.yaml — new workflow that builds and pushes prefecthq/prefect-sqlite:<version>; triggered manually via workflow_dispatch with optional version overrides; skips if the tag already exists
  • Dockerfile — removes inline SQLite compile stage, replaces with FROM prefecthq/prefect-sqlite:${SQLITE_VERSION} AS sqlite-builder; removes now-unused SQLITE_YEAR and SQLITE_FILE_VERSION ARGs
  • client/Dockerfile — same changes as above

…mage

The SQLite from-source build was the slowest stage in our Docker builds.
Instead of compiling on every run, this PR publishes a versioned
`ghcr.io/prefecthq/prefect-sqlite:<version>` image once via a dedicated
workflow and pulls it in all subsequent builds.

- Add `Dockerfile.sqlite` — standalone Dockerfile for the builder image
- Add `.github/workflows/sqlite-builder.yaml` — builds and pushes the
  pre-compiled image to GHCR; triggers on `Dockerfile`/`Dockerfile.sqlite`
  changes to main or via `workflow_dispatch`; skips if the tag already exists
- Update `Dockerfile` and `client/Dockerfile` to use
  `FROM ghcr.io/prefecthq/prefect-sqlite:${SQLITE_VERSION} AS sqlite-builder`
  instead of the inline compile stage; remove the now-unused `SQLITE_YEAR`
  and `SQLITE_FILE_VERSION` ARGs

The `COPY --from=sqlite-builder` lines in both final stages are unchanged.
To update SQLite: bump `SQLITE_VERSION` in `Dockerfile`/`client/Dockerfile`
and run the sqlite-builder workflow.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@codspeed-hq

codspeed-hq Bot commented Feb 24, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 2 untouched benchmarks


Comparing feat/sqlite-builder-cache-image (06de3b9) with main (1dd051e)

Open in CodSpeed

desertaxle and others added 11 commits February 24, 2026 13:57
…qlite-builder

- Add ca-certificates to Dockerfile.sqlite-builder so wget can verify
  SSL when downloading the SQLite tarball
- Rename Dockerfile.sqlite to Dockerfile.sqlite-builder to avoid the
  .sqlite extension being misidentified as a SQLite database file
- Update all references in workflow, Dockerfile, and client/Dockerfile

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…uilder image

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Publishes prefecthq/prefect-sqlite to DockerHub using PREFECT_SQLITE_DOCKERHUB_TOKEN
instead of GHCR. Removes the GHCR login from docker-images.yaml since the DockerHub
repo is public and no longer requires a separate registry auth step to pull.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Temporarily adds feat/sqlite-builder-cache-image to the push trigger so
the image is published to DockerHub before the PR is merged.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…LE_VERSION

These args only exist in Dockerfile.sqlite-builder, not Dockerfile, so they
were resolving to empty strings and causing the wget to fail with a 404.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@desertaxle desertaxle added the development Tech debt, refactors, CI, tests, and other related work. label Feb 26, 2026
@desertaxle desertaxle changed the title perf(docker): replace inline SQLite compilation with pre-built GHCR image perf(docker): replace inline SQLite compilation with pre-built image Feb 26, 2026
@desertaxle
desertaxle marked this pull request as ready for review February 26, 2026 21:58

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: aabc9ea0eb

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread client/Dockerfile Outdated
The sqlite-builder workflow publishes to DockerHub (prefecthq/prefect-sqlite),
not GHCR, so the FROM and comment must reference DockerHub to stay consistent.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 003a63699c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread .github/workflows/sqlite-builder.yaml Outdated
…flow_dispatch

Previously only sqlite_version was overridable, so a manual dispatch with a
new version would still build from the old tarball coordinates. All three args
now follow the same pattern: use the input if provided, otherwise read from
Dockerfile.sqlite-builder.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5d8d725acb

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread .github/workflows/sqlite-builder.yaml Outdated
…ersion sync

Adds client/Dockerfile to the push paths so a SQLite version bump there
triggers the publish workflow. Also fails the build if SQLITE_VERSION differs
between Dockerfile and client/Dockerfile, enforcing a single source of truth.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3e197c6cc0

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread .github/workflows/sqlite-builder.yaml Outdated
Without this, a PR bumping SQLITE_VERSION references a DockerHub tag that
doesn't exist until after merge, deadlocking CI. Adding the pull_request
trigger with the same paths filter publishes the image during the PR so
subsequent Docker build jobs can pull it successfully.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 26d8f75ec4

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread .github/workflows/sqlite-builder.yaml
…f tag exists

The existence check now only short-circuits on pull_request events so that a
push to main (after merge) always rebuilds and retags, ensuring the published
image reflects the final merged source rather than an earlier PR commit.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 32c6d32259

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread .github/workflows/sqlite-builder.yaml
Fork pull_requests don't have access to repository secrets, so the DockerHub
login would fail for any new version tag. Detect this case early and skip the
build — the push-to-main event after merge will do the actual publish.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: bf93afeafb

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread .github/workflows/sqlite-builder.yaml Outdated
Fork PRs can't publish to DockerHub, so a new SQLITE_VERSION tag doesn't
exist until after merge. This adds a sqlite-from-source build stage to both
Dockerfiles (selected via --build-arg SQLITE_SOURCE=from-source) that compiles
SQLite inline, bypassing the DockerHub dependency. python-tests.yaml now
detects fork PRs and passes SQLITE_SOURCE=from-source automatically, so their
CI Docker builds pass without requiring a pre-published image.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: abfb8625e8

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread .github/workflows/python-tests.yaml Outdated
Comment thread Dockerfile Outdated
… PRs

The benchmark workflow builds Dockerfile on pull_request but had no fallback
for fork PRs bumping SQLITE_VERSION to an unpublished tag. Add the same fork
detection logic used in python-tests.yaml.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8bfc96759c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread .github/workflows/time-docker-build.yaml Outdated
Comment thread .github/workflows/sqlite-builder.yaml Outdated
…atch

The previous existence check meant subsequent commits on a same-repo PR
would skip rebuilding, leaving CI validating against a stale image. Now
only fork PRs (which lack secrets) skip the build; all other triggers
always rebuild to ensure the published tag reflects the current branch.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d4af171eac

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread .github/workflows/sqlite-builder.yaml Outdated
Comment thread .github/workflows/python-tests.yaml Outdated
…mage

The DockerHub image is public so no credentials are needed to pull it.
Fork PRs can pull the image just fine; they just can't push new tags.
Remove the SQLITE_SOURCE build arg and from-source fallback stages from
Dockerfile and client/Dockerfile, revert python-tests.yaml and
time-docker-build.yaml to their original build-args, and clean up the
duplicate comment in sqlite-builder.yaml.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1e85f48aa2

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread .github/workflows/sqlite-builder.yaml Outdated
desertaxle and others added 2 commits February 27, 2026 08:34
Removes push and pull_request triggers. The image is published manually
when the SQLite version needs to be bumped.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 133ddead9a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread Dockerfile.sqlite-builder
Prevents publishing a mislabeled image by checking that SQLITE_VERSION
matches across Dockerfile, client/Dockerfile, and Dockerfile.sqlite-builder
before the build runs. A bump that updates the tag but not the build args
(SQLITE_YEAR/SQLITE_FILE_VERSION) will be caught here.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 06de3b964a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread .github/workflows/sqlite-builder.yaml

@chrisguidry chrisguidry left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Love it!

@zzstoatzz zzstoatzz left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wow, is all the comments just codex getting invoked on commit?

@desertaxle

Copy link
Copy Markdown
Member Author

wow, is all the comments just codex getting invoked on commit?

Yeah, I might've marked this as ready to review too soon.

@desertaxle
desertaxle merged commit cb7337b into main Feb 27, 2026
65 checks passed
@desertaxle
desertaxle deleted the feat/sqlite-builder-cache-image branch February 27, 2026 15:20
devin-ai-integration Bot added a commit that referenced this pull request Feb 27, 2026
Add 7 newly merged PRs to the release notes:
- #20869: ProcessPoolTaskRunner subprocess message processors
- #20876: Fix silently lost subprocess events
- #20824: Pre-built SQLite Docker image
- #20870-#20873: UI bug fixes (breadcrumbs, null indicators, locale formatting)

Co-authored-by: bot_apk <apk@cognition.ai>
br413 pushed a commit to br413/prefect that referenced this pull request Jul 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

development Tech debt, refactors, CI, tests, and other related work.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants