Skip to content

Commit ab50384

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. Update AUTH_URL in .env.development to support dynamic port assignment for multi-instance setups. Fixes #1056
1 parent 70484e8 commit ab50384

File tree

2 files changed

+82
-1
lines changed

2 files changed

+82
-1
lines changed

.env.development

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ CTAGS_COMMAND=ctags
1212
# openssl rand -base64 33
1313
# @see: https://authjs.dev/getting-started/deployment#auth_secret
1414
AUTH_SECRET="00000000000000000000000000000000000000000000"
15-
AUTH_URL="http://localhost:3000"
15+
AUTH_URL="http://localhost:${WEB_DYNAMIC_PORT:-3000}"
1616
# AUTH_CREDENTIALS_LOGIN_ENABLED=true
1717

1818
DATA_CACHE_DIR=${PWD}/.sourcebot # Path to the sourcebot cache dir (ex. ~/sourcebot/.sourcebot)

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 && 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"]
80+
backend = ["package.json", "yarn.lock"]
81+
zoekt = ["vendor/zoekt"]

0 commit comments

Comments
 (0)