-
Notifications
You must be signed in to change notification settings - Fork 306
feat: add Helm chart and Dockerfile for deploying Latitude to Kubernetes #2434
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+4,017
−80
Merged
Changes from all commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
4742308
feat: add Helm chart and Dockerfile for deploying Latitude to Kubernetes
claude 0881d91
build: add build scripts to all packages for Docker bundling
geclos 1ec067b
build: add tsup bundling for api, ingest, and workers apps
geclos 486128c
fix: handle import.meta.url for CJS bundles in server entry points
geclos b385015
fix: use LAT_ prefixed env vars for ClickHouse client
geclos 666ee74
build: update Dockerfile for production bundling with tsup
geclos 0ab2819
chore: update pnpm-lock.yaml with tsup dependency
geclos f37e790
build: pin curl version in Dockerfile for hadolint compliance
geclos 50211a8
build: add SHELL directive with pipefail for hadolint compliance
geclos af256a0
chore: update ClickHouse env vars to use LAT_ prefix in .env.example
geclos 47a0671
chore: add both CLICKHOUSE_* and LAT_CLICKHOUSE_* env vars in .env.ex…
geclos 071fcdb
chore: reorganize ClickHouse env vars in .env.example
geclos a39d3ac
fix: ch env vars prefixing
geclos 5020aae
docs: add README for kind local testing environment
geclos 37b82fd
fix: use /api/health endpoint for web service health checks
geclos 13f7a7c
fix: use custom server entry for web app instead of Nitro
geclos bf2cf3d
feat: replaced custom server with nitro for production web build
geclos 68fa231
fix: simplify docker images and align migration env config
geclos 8d0249f
feat: add bundle analyzer and split output build in vendor chunks for…
geclos e13fa53
ci: enforce web bundle size limit on main PRs
geclos 3b649f3
remove slate json
geclos 6d9d74c
fix typo
geclos 7060793
chore: add missing tsc build scripts to shared packages
geclos 5e4f3a3
fix: run web bundle size check with production env
geclos 25157fb
fix: address PR review findings
cursoragent ca838e0
fix: add @platform/env dependency to workers app
cursoragent File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,13 +1,17 @@ | ||
| **/.git/ | ||
| **/.next/ | ||
| **/dist/ | ||
| .git/ | ||
| .github/ | ||
| .husky/ | ||
| .cursor/ | ||
| .turbo/ | ||
| .pnpm-store/ | ||
| **/node_modules/ | ||
| **/docker/ | ||
| **/dist/ | ||
| **/coverage/ | ||
| **/.turbo/ | ||
| **/.next/ | ||
| docker/ | ||
| charts/ | ||
| *.md | ||
| .git | ||
| .pnpm-store | ||
| Dockerfile | ||
| docker | ||
| node_modules | ||
| npm-debug.log | ||
| out | ||
| .env* | ||
| !.env.example |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| name: Web Bundle Size | ||
|
|
||
| on: | ||
| pull_request: | ||
| branches: | ||
| - main | ||
|
|
||
| jobs: | ||
| web-bundle-size: | ||
| runs-on: ubuntu-latest | ||
|
|
||
| env: | ||
| NODE_ENV: production | ||
|
|
||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v5 | ||
|
|
||
| - name: Setup Node.js | ||
| uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: 25.x | ||
|
|
||
| - name: Install pnpm | ||
| uses: pnpm/action-setup@v4 | ||
|
|
||
| - name: Install dependencies | ||
| run: pnpm install --frozen-lockfile | ||
|
|
||
| - name: Create .env.production from example | ||
| run: cp .env.example .env.production | ||
|
|
||
| - name: Build web app | ||
| run: pnpm --filter @app/web build | ||
|
|
||
| - name: Enforce client bundle size limit | ||
| run: pnpm --filter @app/web check:bundle-size |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -129,3 +129,4 @@ PRD.md | |
| progress.txt | ||
|
|
||
| packages/cli/prompts | ||
| .output | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,224 @@ | ||
| # syntax=docker/dockerfile:1 | ||
|
|
||
| # --------------------------------------------------------------------------- | ||
| # Base image — shared by all stages | ||
| # --------------------------------------------------------------------------- | ||
| FROM node:25-slim AS base | ||
|
|
||
| # Install pnpm using npm (corepack was removed from Node.js 25) | ||
| RUN apt-get update && apt-get install -y --no-install-recommends ca-certificates=202* && \ | ||
| npm install -g pnpm@10.30.3 && \ | ||
| rm -rf /var/lib/apt/lists/* | ||
|
|
||
| WORKDIR /app | ||
|
|
||
| # Enable pipefail for proper error handling in piped commands | ||
| SHELL ["/bin/bash", "-o", "pipefail", "-c"] | ||
|
|
||
| # --------------------------------------------------------------------------- | ||
| # Prefetch dependencies into pnpm store (cache-friendly) | ||
| # --------------------------------------------------------------------------- | ||
| FROM base AS deps | ||
|
|
||
| COPY pnpm-lock.yaml pnpm-workspace.yaml package.json ./ | ||
|
|
||
| # Populate pnpm store from lockfile only for better cache reuse | ||
| RUN --mount=type=cache,id=pnpm,target=/root/.local/share/pnpm/store \ | ||
| pnpm fetch --frozen-lockfile --ignore-scripts | ||
|
|
||
| # --------------------------------------------------------------------------- | ||
| # Source — full repo with deps installed | ||
| # --------------------------------------------------------------------------- | ||
| FROM deps AS source | ||
|
|
||
| COPY . . | ||
|
|
||
| # Skip postinstall scripts (chdb and other dev-only native deps) | ||
| RUN --mount=type=cache,id=pnpm,target=/root/.local/share/pnpm/store \ | ||
| pnpm install --frozen-lockfile --ignore-scripts --offline | ||
|
|
||
| # --------------------------------------------------------------------------- | ||
| # Build api — compile api app (turbo builds dependencies automatically) | ||
| # --------------------------------------------------------------------------- | ||
| FROM source AS build-api | ||
|
|
||
| RUN pnpm --filter @app/api build | ||
|
|
||
| # --------------------------------------------------------------------------- | ||
| # Build ingest — compile ingest app (turbo builds dependencies automatically) | ||
| # --------------------------------------------------------------------------- | ||
| FROM source AS build-ingest | ||
|
|
||
| RUN pnpm --filter @app/ingest build | ||
|
|
||
| # --------------------------------------------------------------------------- | ||
| # Build workers — compile workers app (turbo builds dependencies automatically) | ||
| # --------------------------------------------------------------------------- | ||
| FROM source AS build-workers | ||
|
|
||
| RUN pnpm --filter @app/workers build | ||
|
|
||
| # --------------------------------------------------------------------------- | ||
| # Build web — compile web app (turbo builds dependencies automatically) | ||
| # --------------------------------------------------------------------------- | ||
| FROM source AS build-web | ||
|
|
||
| ARG VITE_LAT_API_URL | ||
| ARG VITE_LAT_WEB_URL | ||
|
|
||
| RUN pnpm --filter @app/web build | ||
|
|
||
| # --------------------------------------------------------------------------- | ||
| # Build migrations — compile packages needed for migrations | ||
| # --------------------------------------------------------------------------- | ||
| FROM source AS build-migrations | ||
|
|
||
| RUN pnpm --filter @platform/db-postgres build && \ | ||
| pnpm --filter @platform/db-clickhouse build && \ | ||
| pnpm --filter @platform/db-weaviate build | ||
|
|
||
| # --------------------------------------------------------------------------- | ||
| # Runtime base — shared runtime settings and cleanup helper | ||
| # --------------------------------------------------------------------------- | ||
| FROM base AS runtime | ||
|
|
||
| ENV NODE_ENV=production | ||
|
|
||
| RUN groupadd -r latitude && useradd -r -g latitude -d /app -s /sbin/nologin latitude && \ | ||
| chown -R latitude:latitude /app | ||
|
|
||
| RUN cat <<'EOF' > /usr/local/bin/prune-workspace && chmod +x /usr/local/bin/prune-workspace | ||
| #!/bin/bash | ||
| set -euo pipefail | ||
|
|
||
| find packages -name "src" -type d -exec rm -rf {} + 2>/dev/null || true | ||
| find packages -name "*.ts" -not -path "*/node_modules/*" -not -name "*.d.ts" -delete | ||
| find packages -name "tsconfig.json" -delete | ||
| find . -name "*.test.ts" -delete | ||
| find . -name "*.spec.ts" -delete | ||
| EOF | ||
|
|
||
| RUN cat <<'EOF' > /usr/local/bin/install-prod-deps && chmod +x /usr/local/bin/install-prod-deps | ||
| #!/bin/bash | ||
| set -euo pipefail | ||
|
|
||
| pnpm install --frozen-lockfile --ignore-scripts --production | ||
| EOF | ||
|
|
||
| # --------------------------------------------------------------------------- | ||
| # Target: api — minimal image with only api app | ||
| # --------------------------------------------------------------------------- | ||
| FROM runtime AS api | ||
|
|
||
| COPY --from=build-api /app/apps/api/dist ./apps/api/dist | ||
| COPY --from=build-api /app/apps/api/package.json ./apps/api/package.json | ||
| COPY --from=build-api /app/package.json ./package.json | ||
| COPY --from=build-api /app/pnpm-lock.yaml ./pnpm-lock.yaml | ||
| COPY --from=build-api /app/pnpm-workspace.yaml ./pnpm-workspace.yaml | ||
| COPY --from=build-api /app/packages ./packages | ||
|
|
||
| RUN --mount=type=cache,id=pnpm,target=/root/.local/share/pnpm/store \ | ||
| install-prod-deps | ||
|
|
||
| RUN prune-workspace | ||
| USER latitude | ||
| EXPOSE 3001 | ||
|
|
||
| CMD ["node", "apps/api/dist/server.cjs"] | ||
|
|
||
| # --------------------------------------------------------------------------- | ||
| # Target: ingest — minimal image with only ingest app | ||
| # --------------------------------------------------------------------------- | ||
| FROM runtime AS ingest | ||
|
|
||
| COPY --from=build-ingest /app/apps/ingest/dist ./apps/ingest/dist | ||
| COPY --from=build-ingest /app/apps/ingest/package.json ./apps/ingest/package.json | ||
| COPY --from=build-ingest /app/package.json ./package.json | ||
| COPY --from=build-ingest /app/pnpm-lock.yaml ./pnpm-lock.yaml | ||
| COPY --from=build-ingest /app/pnpm-workspace.yaml ./pnpm-workspace.yaml | ||
| COPY --from=build-ingest /app/packages ./packages | ||
|
|
||
| RUN --mount=type=cache,id=pnpm,target=/root/.local/share/pnpm/store \ | ||
| install-prod-deps | ||
|
|
||
| RUN prune-workspace | ||
| USER latitude | ||
| EXPOSE 3002 | ||
|
|
||
| CMD ["node", "apps/ingest/dist/server.cjs"] | ||
|
|
||
| # --------------------------------------------------------------------------- | ||
| # Target: workers — minimal image with only workers app | ||
| # --------------------------------------------------------------------------- | ||
| FROM runtime AS workers | ||
|
|
||
| COPY --from=build-workers /app/apps/workers/dist ./apps/workers/dist | ||
| COPY --from=build-workers /app/apps/workers/package.json ./apps/workers/package.json | ||
| COPY --from=build-workers /app/package.json ./package.json | ||
| COPY --from=build-workers /app/pnpm-lock.yaml ./pnpm-lock.yaml | ||
| COPY --from=build-workers /app/pnpm-workspace.yaml ./pnpm-workspace.yaml | ||
| COPY --from=build-workers /app/packages ./packages | ||
|
|
||
| RUN --mount=type=cache,id=pnpm,target=/root/.local/share/pnpm/store \ | ||
| install-prod-deps | ||
|
|
||
| RUN prune-workspace | ||
| USER latitude | ||
| EXPOSE 9090 | ||
|
|
||
| CMD ["node", "apps/workers/dist/server.cjs"] | ||
|
|
||
| # --------------------------------------------------------------------------- | ||
| # Target: web — minimal image with only web app (TanStack Start SSR with Nitro) | ||
| # --------------------------------------------------------------------------- | ||
| FROM runtime AS web | ||
|
|
||
| COPY --from=build-web /app/apps/web/.output ./apps/web/.output | ||
| COPY --from=build-web /app/apps/web/package.json ./apps/web/package.json | ||
| COPY --from=build-web /app/package.json ./package.json | ||
| COPY --from=build-web /app/pnpm-lock.yaml ./pnpm-lock.yaml | ||
| COPY --from=build-web /app/pnpm-workspace.yaml ./pnpm-workspace.yaml | ||
| COPY --from=build-web /app/packages ./packages | ||
|
|
||
| RUN --mount=type=cache,id=pnpm,target=/root/.local/share/pnpm/store \ | ||
| install-prod-deps | ||
|
|
||
| RUN prune-workspace | ||
| USER latitude | ||
| EXPOSE 3000 | ||
|
|
||
| CMD ["node", "apps/web/.output/server/index.mjs"] | ||
|
|
||
| # --------------------------------------------------------------------------- | ||
| # Target: migrations — minimal image with migration tools | ||
| # --------------------------------------------------------------------------- | ||
| FROM runtime AS migrations | ||
|
|
||
| # Install curl and goose for ClickHouse migrations | ||
| # hadolint ignore=DL3008 | ||
| RUN apt-get update && \ | ||
| apt-get install -y --no-install-recommends curl && \ | ||
| GOOSE_VERSION=3.24.1 && \ | ||
| ARCH=$(dpkg --print-architecture) && \ | ||
| case "$ARCH" in \ | ||
| amd64) GOOSE_ARCH="x86_64" ;; \ | ||
| arm64) GOOSE_ARCH="aarch64" ;; \ | ||
| *) GOOSE_ARCH="$ARCH" ;; \ | ||
| esac && \ | ||
| curl -fsSL "https://github.com/pressly/goose/releases/download/v${GOOSE_VERSION}/goose_linux_${GOOSE_ARCH}" \ | ||
| -o /usr/local/bin/goose && \ | ||
| chmod +x /usr/local/bin/goose && \ | ||
| apt-get purge -y curl && apt-get autoremove -y && rm -rf /var/lib/apt/lists/* | ||
|
|
||
| COPY --from=build-migrations /app/packages ./packages | ||
| COPY --from=build-migrations /app/apps/workflows ./apps/workflows | ||
| COPY --from=build-migrations /app/package.json ./package.json | ||
| COPY --from=build-migrations /app/pnpm-lock.yaml ./pnpm-lock.yaml | ||
| COPY --from=build-migrations /app/pnpm-workspace.yaml ./pnpm-workspace.yaml | ||
|
|
||
| RUN --mount=type=cache,id=pnpm,target=/root/.local/share/pnpm/store \ | ||
| pnpm install --frozen-lockfile --ignore-scripts | ||
|
|
||
| USER latitude | ||
|
|
||
| CMD ["sh", "-c", "pnpm --filter @platform/db-postgres pg:migrate && pnpm --filter @platform/db-clickhouse ch:up && pnpm --filter @platform/db-weaviate wv:migrate"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.