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
9 changes: 9 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
.git
.github
**/node_modules
apps/web/build
apps/web/.svelte-kit
.env
.env.*
!.env.example
docs
32 changes: 32 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: ci

on:
pull_request:
branches: [master]
push:
branches: [master]

jobs:
build:
name: install, test, build (Bun)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
# The version comes from packageManager in package.json, the same Bun the
# image (Dockerfile) pins.
- uses: oven-sh/setup-bun@v2
with:
bun-version-file: package.json
- run: bun install --frozen-lockfile
- run: bun run test
- run: bun run build
# The SvelteKit server must boot under Bun and answer.
- name: Web server answers under Bun
run: |
(cd apps/web && PORT=3000 HOST=127.0.0.1 ORIGIN=http://127.0.0.1:3000 bun build/index.js > /tmp/web.log 2>&1 &)
for i in $(seq 1 30); do
code=$(curl -s -o /dev/null -w '%{http_code}' http://127.0.0.1:3000/ || true)
case "$code" in 2*|3*) echo "/ -> $code"; exit 0;; esac
sleep 1
done
cat /tmp/web.log; exit 1
37 changes: 30 additions & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,33 @@
# meshhook on dev2: a plain image because nixpacks' pinned nixpkgs ships Node 22.11
# while pnpm 11.18 needs >= 22.13 and has no nodejs_24. Same commands railway.toml ran.
FROM node:24-bookworm-slim
# syntax=docker/dockerfile:1
#
# meshhook.com on dev2, run on Bun. dev2's compose stack builds this file
# (/home/anthony/www/meshhook.com/docker-compose.app.yml, `dockerfile: Dockerfile`).
#
# One container, the same two processes as before: server.mjs supervises the
# SvelteKit web app (adapter-node build) and the queue orchestrator. It spawns
# both with process.execPath, so under Bun they run on Bun too.
#
# Contract with dev2, unchanged from the Node image: listens on 3000 (compose maps
# 127.0.0.1:APP_PORT), answers / for the deploy health check, reads DATABASE_URL,
# ORIGIN and the rest from app.env at run time.
FROM oven/bun:1.4.0-slim
WORKDIR /app
RUN corepack enable && corepack prepare pnpm@11.18.0 --activate
COPY . .
RUN pnpm install --frozen-lockfile && pnpm --filter @meshhook/web run build
RUN chown bun:bun /app
USER bun
# The workspace manifests first, so a source-only change keeps the install layer.
COPY --chown=bun:bun package.json bun.lock ./
COPY --chown=bun:bun apps/web/package.json apps/web/
COPY --chown=bun:bun workers/package.json workers/
COPY --chown=bun:bun packages/shared/package.json packages/shared/
COPY --chown=bun:bun packages/cli/package.json packages/cli/
COPY --chown=bun:bun scripts/socket-patch.mjs scripts/
RUN bun install --frozen-lockfile
COPY --chown=bun:bun . .
# `bun --bun vite build`: the SvelteKit build runs on Bun, not Node.
RUN bun run build
ENV NODE_ENV=production
EXPOSE 3000
CMD ["node", "server.mjs"]
# 127.0.0.1, not localhost: localhost can resolve ::1 first.
HEALTHCHECK --interval=30s --timeout=5s --start-period=30s --retries=3 \
CMD bun -e "fetch('http://127.0.0.1:'+(process.env.PORT||3000)+'/').then(r=>process.exit(r.status<500?0:1)).catch(()=>process.exit(1))"
CMD ["bun", "server.mjs"]
30 changes: 15 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,12 @@

1. **Install dependencies**
```bash
pnpm install
bun install
```

2. **Setup environment** (interactive)
```bash
pnpm run setup
bun run setup
```
Select "Local Development" when prompted. This creates `.env.local` pointing at a
local SQLite file (`file:./meshhook.db`) and generates a secrets encryption key.
Expand All @@ -55,52 +55,52 @@

3. **Run migrations**
```bash
pnpm run db:migrate
bun run db:migrate
```

4. **Start the orchestrator**
```bash
pnpm run start
bun run start
```
Runs on port 8080 (configurable via PORT environment variable)

### Production / Staging

1. **Install dependencies**
```bash
pnpm install
bun install
```

2. **Setup environment** (interactive)
```bash
pnpm run setup
bun run setup
```
Select "Production" or "Staging" and enter your Postgres URL
(`postgres://user:pass@host:5432/meshhook`). Anything else is refused.


3. **Run migrations**
```bash
pnpm run db:migrate
bun run db:migrate
```
Applies any pending migrations from `migrations/` and records them in
`schema_migrations`. Re-running is a no-op.

4. **Start the server**
```bash
pnpm run start
bun run start
```
Runs on port 8080 by default. Configure your reverse proxy to forward traffic to this port.

## Available Commands

- `pnpm run setup` - Interactive environment configuration (local/staging/production)
- `pnpm run db:migrate` - Apply pending database migrations
- `pnpm run db:status` - Show applied and pending migrations
- `pnpm run db:verify` - Verify the schema matches what the app expects
- `pnpm test` - Run the test suite
- `pnpm run start` - Start the orchestrator worker (production)
- `pnpm mh --help` - CLI help
- `bun run setup` - Interactive environment configuration (local/staging/production)
- `bun run db:migrate` - Apply pending database migrations
- `bun run db:status` - Show applied and pending migrations
- `bun run db:verify` - Verify the schema matches what the app expects
- `bun run test` - Run the test suite
- `bun run start` - Start the orchestrator worker (production)
- `bun run mh --help` - CLI help

## Environment Files

Expand Down
Loading
Loading