Skip to content

Commit 1e7ac79

Browse files
committed
feat: add Coastfile for local development
Add a Coastfile so developers can use Coasts to run isolated dev environments with the full stack (Next.js, backend worker, zoekt, Postgres, Redis) in parallel for worktree-based workflows. Fixes #1056
1 parent 2fa86ff commit 1e7ac79

File tree

1 file changed

+81
-0
lines changed

1 file changed

+81
-0
lines changed

Coastfile

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
[coast]
2+
name = "sourcebot"
3+
compose = "./docker-compose-dev.yml"
4+
primary_port = "web"
5+
private_paths = ["packages/web/.next"]
6+
worktree_dir = [".worktrees", ".claude/worktrees", "~/.cursor/worktrees/sourcebot", "~/conductor/workspaces/sourcebot"]
7+
8+
[coast.setup]
9+
packages = ["nodejs", "npm", "go", "make", "git", "bash", "ca-certificates", "ctags"]
10+
run = [
11+
"npm install -g corepack",
12+
"corepack enable",
13+
]
14+
15+
# Zoekt code search server (Go binary built by `make`)
16+
[services.zoekt]
17+
install = "cd /workspace && (test -f bin/zoekt-webserver || make zoekt)"
18+
command = "cd /workspace && ./bin/zoekt-webserver -index .sourcebot/index -rpc"
19+
port = 6070
20+
restart = "on-failure"
21+
cache = ["bin"]
22+
23+
# Next.js frontend + API
24+
[services.web]
25+
install = ["cd /workspace && (test -f node_modules/.yarn-state.yml || DATABASE_URL=postgresql://postgres:postgres@host.docker.internal:5432/postgres make yarn)", "cd /workspace && test -f config.json || echo {} > config.json", "cd /workspace && DATABASE_URL=postgresql://postgres:postgres@host.docker.internal:5432/postgres yarn dev:prisma:migrate:dev"]
26+
command = "cd /workspace && AUTH_URL=http://localhost:${WEB_DYNAMIC_PORT:-3000} DATABASE_URL=postgresql://postgres:postgres@host.docker.internal:5432/postgres REDIS_URL=redis://host.docker.internal:6379 yarn dev:web"
27+
port = 3000
28+
restart = "on-failure"
29+
cache = ["node_modules"]
30+
31+
# Background worker
32+
[services.backend]
33+
install = "cd /workspace && (test -f node_modules/.yarn-state.yml || DATABASE_URL=postgresql://postgres:postgres@host.docker.internal:5432/postgres make yarn)"
34+
command = "cd /workspace && DATABASE_URL=postgresql://postgres:postgres@host.docker.internal:5432/postgres REDIS_URL=redis://host.docker.internal:6379 yarn dev:backend"
35+
restart = "on-failure"
36+
cache = ["node_modules"]
37+
38+
# Shared services — run on host Docker so all Coasts share one DB and cache
39+
[shared_services.postgres]
40+
image = "postgres:16-alpine"
41+
ports = [5432]
42+
volumes = ["sourcebot_postgres_data:/var/lib/postgresql/data"]
43+
env = { POSTGRES_DB = "postgres", POSTGRES_USER = "postgres", POSTGRES_PASSWORD = "postgres" }
44+
45+
[shared_services.redis]
46+
image = "redis:7-alpine"
47+
ports = [6379]
48+
volumes = ["sourcebot_redis_data:/data"]
49+
50+
# Override DATABASE_URL to reach shared postgres from bare services
51+
[secrets.database_url]
52+
extractor = "command"
53+
run = "echo postgresql://postgres:postgres@host.docker.internal:5432/postgres"
54+
inject = "env:DATABASE_URL"
55+
56+
# Override REDIS_URL to reach shared redis from bare services
57+
[secrets.redis_url]
58+
extractor = "command"
59+
run = "echo redis://host.docker.internal:6379"
60+
inject = "env:REDIS_URL"
61+
62+
[ports]
63+
web = 3000
64+
postgres = 5432
65+
redis = 6379
66+
zoekt = 6070
67+
68+
69+
[assign]
70+
default = "none"
71+
exclude_paths = ["docs", "schemas", "scripts", "configs", ".github", "ee"]
72+
73+
[assign.services]
74+
web = "hot"
75+
backend = "hot"
76+
zoekt = "none"
77+
78+
[assign.rebuild_triggers]
79+
web = ["package.json", "yarn.lock", "packages/db/prisma/schema.prisma", "packages/db/prisma/migrations"]
80+
backend = ["package.json", "yarn.lock", "packages/db/prisma/schema.prisma", "packages/db/prisma/migrations"]
81+
zoekt = ["vendor/zoekt"]

0 commit comments

Comments
 (0)