Skip to content

feat(relay): add docker support and publish workflow [Closes #352] - #356

Merged
jo-duchan merged 3 commits into
jo-duchan:mainfrom
nneelabh02:feat/docker-deployment-issue-352
Jul 2, 2026
Merged

jo-duchan merged 3 commits into
jo-duchan:mainfrom
nneelabh02:feat/docker-deployment-issue-352

Conversation

@nneelabh02

@nneelabh02 nneelabh02 commented Jul 2, 2026 •

Copy link
Copy Markdown
Contributor

Resolves #352

This PR introduces production-ready Docker deployment support for the @tapflowio/relay package along with an automated GitHub Action workflow to publish the image to Docker Hub.

Changes Included

  • Multi-stage Dockerfile: Built specifically from the monorepo root to properly resolve local workspace dependencies (like @tapflowio/agent-core). Uses pnpm deploy to prune development dependencies and correctly package the relay service into a minimal runtime image.
  • Security & Optimization: The runtime container operates as a non-root node user on a lightweight node:20-alpine base image.
  • Optimized Build Context: Added a strict .dockerignore to prevent sending unneeded files (such as .git, .github (via ignore), and .changeset) to the Docker daemon.
  • Docker Publish Workflow: A new GitHub Action (.github/workflows/docker-publish.yml) that automatically builds and pushes the image to Docker Hub on pushes to main or upon creating a release tag. It securely uses repository secrets DOCKER_USERNAME and DOCKER_TOKEN and leverages GitHub Actions caching for faster builds.

Summary by CodeRabbit

  • New Features

    • Added automated, multi-architecture Docker image publishing on main and version tags.
  • Bug Fixes

    • Improved Docker build context handling to exclude unnecessary files while preserving required package entry points.
    • Made the root prepare step tolerant to lefthook install failures.
  • Improved Packaging

    • Refactored the Docker build into a two-stage monorepo flow producing a production deploy output.
    • Run the container as a non-root user, added a dedicated writable data volume, and set an explicit startup command.

@vercel

vercel Bot commented Jul 2, 2026

Copy link
Copy Markdown

@nneelabh02 is attempting to deploy a commit to the jo-duchan's projects Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai

coderabbitai Bot commented Jul 2, 2026 •

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

This PR updates Docker packaging and publishing: it filters the build context, refactors the Dockerfile into pnpm-based builder/runtime stages, and adds a GitHub Actions workflow to build and publish a multi-architecture image.

Changes

Docker build and publish pipeline

Layer / File(s) Summary
Dockerignore updates
.dockerignore
Reorders ignore rules, adds dot/config exclusions, and adds explicit allowlist entries for selected playground and docs files.
Builder stage and workspace install
Dockerfile, package.json
Changes the builder base image and pnpm version, expands workspace inputs, switches to a monorepo-wide frozen install, keeps the scoped package builds, and makes lefthook install non-fatal in prepare.
Runtime stage and deployed payload
Dockerfile
Switches the runtime stage to alpine, runs as the node user, copies the deployed relay payload, creates the data volume, and sets the production command and port.
Docker Publish workflow
.github/workflows/docker-publish.yml
Adds a GitHub Actions workflow that triggers on main and version tag pushes plus pull requests, sets up QEMU and Buildx, generates image tags and labels, and builds or publishes a multi-architecture Docker image with cache.

Estimated code review effort: 3 (Moderate) | ~20 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Linked Issues check ⚠️ Warning The workflow and Dockerfile are in scope, but the PR does not show the required Docker Hub README, docs, or secrets setup guide for #352. Add the Docker Hub image README, EN/KO Docker Compose docs in guide/self-hosting.md, and a secrets setup guide for DOCKERHUB_USERNAME and DOCKERHUB_TOKEN.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly matches the main change: Docker support and a publish workflow for relay.
Description check ✅ Passed The description covers the main Docker and publish changes, but omits the checklist and .work/ docs sections from the template.
Out of Scope Changes check ✅ Passed The Dockerfile, workflow, .dockerignore, and prepare-script tweak all support the relay Docker publish goal and look in scope.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai 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.

Actionable comments posted: 4

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.github/workflows/docker-publish.yml:
- Around line 20-21: The Docker publish workflow is missing the
multi-architecture platform list, so the image is not built for both requested
targets. Update the build/publish configuration in the docker-publish workflow,
specifically around the `docker/setup-buildx-action` and the downstream build
step, to include `linux/amd64` and `linux/arm64` as `platforms` so the published
image is built for both architectures.
- Around line 23-33: The Docker publish workflow is using the wrong secret names
and image repository for the publish contract. Update the docker/login-action@v3
and docker/metadata-action@v5 configuration to use DOCKERHUB_USERNAME and
DOCKERHUB_TOKEN, and change the image target from the current relay repository
path to tapflow/tapflow so the publish steps align with the expected Docker Hub
setup.

In `@Dockerfile`:
- Around line 10-16: The Docker build context is missing some workspace
manifests before pnpm install, so the monorepo graph in the image does not match
the repo graph. Update the Dockerfile near the COPY and pnpm install steps to
include the top-level playground and docs manifests (as referenced by
pnpm-workspace.yaml and .dockerignore) alongside packages before running pnpm
install, so workspace resolution includes all declared projects.
- Around line 6-7: The Dockerfile currently installs pnpm without respecting the
repo’s pinned version, which can make the build pick up a newer incompatible
release. Update the pnpm installation step to use the exact version pinned by
the project, preferably via Corepack or an explicit [email protected] install, so the
build behavior matches the packageManager setting and stays stable.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: f602c2b7-6305-4a54-b018-455f673b7902

📥 Commits

Reviewing files that changed from the base of the PR and between 471fadd and e3de82d.

📒 Files selected for processing (3)
  • .dockerignore
  • .github/workflows/docker-publish.yml
  • Dockerfile

Comment thread .github/workflows/docker-publish.yml Resolved
Comment thread .github/workflows/docker-publish.yml Resolved
Comment thread Dockerfile Resolved
Comment thread Dockerfile Resolved
- Pin pnpm version to 9.15.1 in Dockerfile
- Include playground and docs package.json files for complete workspace resolution
- Add QEMU setup and configure linux/amd64,linux/arm64 multi-platform builds
- Use DOCKERHUB_USERNAME / DOCKERHUB_TOKEN to match issue contract
- Adjust Docker image target to tapflow/tapflow
@jo-duchan

Copy link
Copy Markdown
Owner

Thanks for the follow-up commit — pinning [email protected], adding the multi-arch platforms, and copying the playground/docs manifests all look good. 🙏

I actually built the image locally (colima + buildx, PR HEAD f1b34da) rather than reasoning about it, and the build does not currently succeed. Sharing the reproduction so it's actionable:

1. node:20-alpine can't install better-sqlite3 (blocks the build).

[builder] RUN pnpm install --frozen-lockfile
better-sqlite3 install: gyp ERR! find Python — Could not find any Python installation to use
node -v v20.20.2  →  ERROR: process "pnpm install --frozen-lockfile" exit code: 1

[email protected] ships no prebuilt binary for Node 20 (its lowest prebuild ABI is node-v127 = Node 22), so on Node 20 it falls back to a source build via node-gyp, and node:20-alpine has no python3/make/g++.

2. Once Node is bumped, the root prepare hook fails (second blocker).

. prepare$ lefthook install
Error: exec: "git": executable file not found in $PATH
# and, with git added: fatal: not a git repository (or any of the parent directories): .git

The build context excludes .git and only copies selected files, so /app is not a git repo and lefthook install (run by the root prepare script) errors during both pnpm install and pnpm deploy.

3. Heads-up: --ignore-scripts "fixes" the build but breaks runtime.
Skipping scripts to dodge prepare makes the build pass (exit 0) but the container then crashes on boot:

Error: Could not locate the bindings file … better_sqlite3.node

because better-sqlite3's own install script (which fetches the native binary into the deployed output) is skipped too. So --ignore-scripts alone is not a viable workaround.

Verified working configuration (built + booted successfully — tapflow relay running on port 4000, HTTP 200):

  • Base image node:20-alpine → node:22-alpine (satisfies engines and gets the musl prebuild, no toolchain needed).
  • Make the root prepare hook safe outside a git repo. Cleanest is at the repo level: "prepare": "lefthook install || true". A Dockerfile-only alternative that also works is RUN apk add --no-cache git && git init -q in the builder (keeps the native install scripts running, unlike --ignore-scripts).

One more suggestion: since docker-publish.yml only triggers on push to main/tags, the image is never built on PRs — a broken build would only surface after merge. A pull_request-triggered build-only job (push: false) would have caught all of the above before merge.

Really nice direction overall (multi-stage + pnpm deploy + non-root) — just needs the base-image bump and the prepare guard to actually build and run. Happy to help if any of this is unclear.

- Bump base image to node:22-alpine in Dockerfile to satisfy native deps like better-sqlite3 without a toolchain
- Safe-guard the prepare hook with 'lefthook install || true' in package.json to prevent errors when building outside a git repo
- Add pull_request trigger in docker-publish.yml to catch build errors early on PRs
- Make Docker Hub login and pushing conditional on push events only
@nneelabh02

Copy link
Copy Markdown
Contributor Author

@jo-duchan The feedbad has been implemented, kindly check the PR. Thank you

@coderabbitai coderabbitai 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.

🧹 Nitpick comments (1)
package.json (1)

16-16: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Consider gating on .git presence instead of blanket suppression.

|| true masks all lefthook install failures, including legitimate ones in normal (non-Docker) git clones — not just the "no .git dir" case this was meant to fix. A developer with a broken lefthook install would silently get no git hooks with no signal.

♻️ Suggested refactor
-    "prepare": "lefthook install || true",
+    "prepare": "[ -d .git ] && lefthook install || true",
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@package.json` at line 16, The prepare script currently suppresses every
lefthook install failure by using the package.json "prepare" hook with a blanket
fallback. Update the script to only skip installation when there is no .git
directory, and let real lefthook failures surface normally. Use the existing
"prepare" entry in package.json and gate the lefthook install command on .git
presence instead of relying on || true.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@package.json`:
- Line 16: The prepare script currently suppresses every lefthook install
failure by using the package.json "prepare" hook with a blanket fallback. Update
the script to only skip installation when there is no .git directory, and let
real lefthook failures surface normally. Use the existing "prepare" entry in
package.json and gate the lefthook install command on .git presence instead of
relying on || true.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 513e1903-5576-4d40-b5f7-1ff1f9bfa5dd

📥 Commits

Reviewing files that changed from the base of the PR and between f1b34da and 10c7728.

📒 Files selected for processing (3)
  • .github/workflows/docker-publish.yml
  • Dockerfile
  • package.json
🚧 Files skipped from review as they are similar to previous changes (2)
  • .github/workflows/docker-publish.yml
  • Dockerfile

@nneelabh02

Copy link
Copy Markdown
Contributor Author
image

Please check the vercel deploy. @jo-duchan

@jo-duchan

Copy link
Copy Markdown
Owner

Thanks @nneelabh02 — everything checks out. ✅

  • The Docker build workflow ran green on CI, and I also built the image locally and booted it end-to-end: the relay comes up (tapflow relay running on port 4000) and serves HTTP 200, with better-sqlite3's native binding loading correctly on the musl base. All three earlier blockers (Node version, the prepare hook, PR-time build validation) are resolved.
  • No need to worry about the Vercel check — that failure is an authorization issue with our Vercel integration for fork PRs (it can't deploy without our credentials), not anything in your change. It's unrelated to this PR.

I'm going to merge this now. Really appreciate the thorough, well-structured contribution — the multi-stage build, pnpm deploy, non-root runtime, and multi-arch publish are all nicely done. 🙌

If tapflow has been useful to you, a ⭐️ on the repo would mean a lot and helps others discover the project: https://github.com/jo-duchan/tapflow

@jo-duchan
jo-duchan merged commit c7ad063 into jo-duchan:main Jul 2, 2026
2 checks passed
@coderabbitai coderabbitai Bot mentioned this pull request Aug 15, 2026
4 tasks done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Publish relay as a Docker image (Docker Hub) + document Docker deployment

2 participants