Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
"memory-check": "node --run repomix -- --verbose | grep Memory",
"memory-check-one-file": "node --run repomix -- --verbose --include 'package.json' | grep Memory",
"website": "docker compose -f website/compose.yml up --build",
"website-bundle": "docker compose -f website/compose.bundle.yml up --build",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

For a better local testing experience, consider using docker compose run instead of up. The run command with the --rm flag will automatically clean up the container when you stop it (e.g., with Ctrl+C), preventing dangling containers. The --service-ports flag is needed to publish the container's ports to the host.

This approach is particularly well-suited for the testing scenario described in the PR, as it ensures a clean state for each run without requiring a manual docker compose down.

If you apply this change, you might also want to update the example command in the website/compose.bundle.yml file's header comment for consistency.

Suggested change
"website-bundle": "docker compose -f website/compose.bundle.yml up --build",
"website-bundle": "docker compose -f website/compose.bundle.yml run --build --rm --service-ports server",

"website-generate-schema": "tsx website/client/scripts/generateSchema.ts",
"pinact-run": "pinact run",
"pinact-check": "pinact run --check"
Expand Down
30 changes: 30 additions & 0 deletions website/compose.bundle.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Run website with bundled server (production-like build)
# $ docker compose -f website/compose.bundle.yml up --build
#
# This compose file builds and runs the server in bundled mode,
# similar to the production Cloud Run environment.
# Useful for testing esbuild bundling, compile cache, and startup performance locally.

services:
client:
build:
context: ./client
dockerfile: Dockerfile
ports:
- "5173:5173"
volumes:
- ./client:/app
environment:
- NODE_ENV=development
command: sh -c "npm i && npm run docs:dev -- --port 5173 --host"

server:
build:
context: ./server
dockerfile: Dockerfile
ports:
- "8080:8080"
environment:
# Use development mode to avoid Google Cloud Logging authentication errors
- NODE_ENV=development
# No volume mounts - use the bundled files from Docker image
1 change: 1 addition & 0 deletions website/server/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
dist
dist-bundled
node_modules
14 changes: 2 additions & 12 deletions website/server/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,9 @@ COPY package*.json ./
# Install all dependencies (including dev dependencies for build)
RUN npm ci

# Copy source code and build
# Copy source code and bundle
COPY . .
RUN npm run build

# Bundle the server with esbuild for unified worker support
# tiktoken must be external because it loads WASM files from __dirname
RUN npx esbuild dist/index.js --bundle --platform=node --target=node20 \
--format=esm --outfile=dist-bundled/server.mjs --external:tinypool --external:tiktoken \
--banner:js="import { createRequire as _createRequire } from 'module'; const require = _createRequire(import.meta.url); import { fileURLToPath as _fileURLToPath } from 'url'; import { dirname as _dirname } from 'path'; const __filename = _fileURLToPath(import.meta.url); const __dirname = _dirname(__filename);"

# Collect WASM files from wherever they are in node_modules
RUN mkdir -p dist-bundled/wasm && \
find node_modules -name "*.wasm" -path "*tree-sitter-wasms/out/*" -exec cp {} dist-bundled/wasm/ \;
RUN npm run bundle


# ==============================================================================
Expand Down
Loading
Loading