feat: add dev container with sibling Postgres#62
Merged
Merged
Conversation
Adds a dev container so the app can be developed in a sandbox without a local Node/Postgres setup. The existing docker/docker-compose.yml Postgres runs as a sibling container; the workspace connects over the Compose network by service name. The workspace has no Docker daemon and no host Docker socket — it cannot create or control containers. Generated from ghcr.io/rocicorp/devcontainer-templates/sibling-services. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
"Dev Containers: Clone Repository in Container Volume" mounts the cloned repo volume at /workspaces; a ..:/workspaces/hello-zero host bind breaks that flow on a machine with no host checkout (mounts denied). Rely on the injected volume instead. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Bake the Postgres init scripts into the image instead of bind-mounting the repo's docker/ folder. "Clone Repository in Container Volume" has no host checkout, so the bind mount of ./ -> /docker-entrypoint-initdb.d from the repo's docker/docker-compose.yml can't resolve. The override builds zstart_postgres from .devcontainer/Dockerfile.postgres and uses !override to drop the init bind, keeping only zstart_pgdata. The repo's canonical docker/docker-compose.yml is untouched, so normal `docker compose up` users keep their host bind mount. Also migrate the agents feature to 2.0.0 and forward GITHUB_TOKEN from the host so gh authenticates from the token instead of a persisted login.
The previous attempt overrode zstart_postgres in .devcontainer/docker-compose.yml, but Docker Compose 2.27 (Docker Desktop) rejects redefining a service that came in via include: with "services.zstart_postgres conflicts with imported resource". (Newer Compose allows it, which masked the problem in validation.) Instead, move the seed into the canonical docker/docker-compose.yml: build zstart_postgres from docker/Dockerfile.postgres, which COPYs seed.sql into /docker-entrypoint-initdb.d, and drop the ./ bind mount. A bind mount needs a shared host path, which doesn't exist under "Clone Repository in Container Volume" (the checkout lives in a Docker named volume). Baking the seed makes both `pnpm dev:db-up` and the dev container start identically, with no include-override conflict.
…27 conflict
The devcontainer CLI generates a temporary compose override to wire up the
workspace volume and networking. On Compose 2.27, any service in that
generated override file conflicts with the same service brought in via
include: ("services.zstart_postgres conflicts with imported resource").
Multiple -f files allow the CLI's generated override to freely merge
services; include: does not.
Switch dockerComposeFile to ["../docker/docker-compose.yml",
"docker-compose.yml"] and remove the include: from docker-compose.yml.
Relative paths in docker/docker-compose.yml (build context: .) still
resolve against docker/ because Docker Compose resolves each -f file's
paths relative to that file's own directory.
By default Vite listens on 127.0.0.1, which VS Code can't reach from outside the container network. server.host: true binds to 0.0.0.0 so VS Code auto-forwards the port without needing --host on the CLI.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What
Adds a dev container so hello-zero can be developed in a sandbox (VS Code / GitHub Codespaces "Reopen in Container") with no local Node or Postgres setup.
How
The existing
docker/docker-compose.ymlPostgres runs as a sibling container; the workspace connects to it over the Compose network by service name (zstart_postgres:5432).ZERO_UPSTREAM_DBis preset in the container to override the127.0.0.1:5430value from.env(container env beats dotenv).The workspace has no Docker daemon and no host Docker socket — it cannot create or control containers, which keeps it a meaningful sandbox for development and AI-agent work.
Generated from
ghcr.io/rocicorp/devcontainer-templates/sibling-services.Verified
Booted the full stack: Postgres comes up healthy,
seed.sqlruns (9 users, 4 mediums), and the workspace reaches the db by service name. Nodb-upneeded inside the container — Postgres is already running as a sibling.🤖 Generated with Claude Code