Enable Supabase migrations from inside Docker container#7
Open
dylanonelson wants to merge 3 commits into
Open
Conversation
The agent container could not run `supabase migration up` or `db push` because (1) the Supabase CLI was not installed and (2) the CLI defaults to localhost:54322 which, inside the container, is the container itself rather than the host running Supabase. - Install `supabase` CLI globally in claude.Dockerfile - Inject SUPABASE_DB_URL env var (host.docker.internal:54322) via run-claude-in-docker.sh so every shell has it - Log available migration commands in init.sh Docker mode Usage from inside the container: supabase migration up --db-url "$SUPABASE_DB_URL" supabase db push --db-url "$SUPABASE_DB_URL" Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Deploying timer with
|
| Latest commit: |
9e84097
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://2b112559.timer-cx7.pages.dev |
| Branch Preview URL: | https://fix-docker-supabase-migratio.timer-cx7.pages.dev |
The `supabase` npm package blocks global installs. Switch to downloading the pre-built binary from GitHub releases, which also auto-detects the architecture (amd64/arm64) via dpkg. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Instead of requiring agents to remember `--db-url "$SUPABASE_DB_URL"` on every migration command, install a wrapper script as the `supabase` command that automatically appends --db-url for subcommands that accept it (db push, db pull, db diff, migration up, etc.) when SUPABASE_DB_URL is set. The real binary lives at supabase-bin. Agents can now just run `supabase db push` and it works transparently in both local and Docker environments. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.
Summary
claude.Dockerfileso the agent can run migration commandsSUPABASE_DB_URLenv var viarun-claude-in-docker.sh, pointing tohost.docker.internal:54322so the CLI reaches the host's Postgres instead of the container's own localhostinit.shDocker mode so the agent knows how to use itContext
The agent container could reach the Supabase API (port 54321) for the web app via
host.docker.internal, but the Supabase CLI was not installed and had no way to reach the Postgres database (port 54322) for running migrations. This adds the CLI and wires up the connection.Usage from inside the container:
Test plan
scripts/build-claude-in-docker.shscripts/run-claude-in-docker.shwith local Supabase running on the hostsupabase --versionworksecho $SUPABASE_DB_URLprints the correct connection stringsupabase migration up --db-url "$SUPABASE_DB_URL"and confirm migrations apply successfully🤖 Generated with Claude Code