Repository navigation
fix(node): store Postgres data in a named volume - #565
Merged
Merged
Conversation
A bind-mounted data directory on Docker Desktop is owned by the host user, so Postgres init exits before it creates database bcn. A named volume is owned by the image user on every host. The db healthcheck now requires that database and the Output table, and bcn and sync wait until the db container is healthy. npm run clean removes every bcn-db-<chain>-<network> volume.
The install note still said Postgres data lives under chain-setup. Blockchain data stays in that folder. The database is the bcn-db-<chain>-<network> volume.
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
bcn-db-<chain>-<network>instead of bind-mountingchain-setup/<chain>/<network>/db-data.npm run cleanremoves those volumes for every chain and network, and it succeeds when none exist.$POSTGRES_DBexists and"Output"is present, and only once pid 1 ispostgres.bcnandsyncwait for that check. They still wait fornodeto start.Workspace issue: Bitcoin-Computer-Secrets/workspace#261
Why
On Docker Desktop, a fresh bind-mounted data directory is owned by the host user. Postgres init writes
PG_VERSION, then the temporary server exits because the directory is not owned by the image user. The next start skips initialization, so databasebcnanddb/db_schema.sqlnever run. The node and sync containers restart, and the regtest wallet is never created.A named volume is owned by the image user on Docker Desktop, root Docker, and rootless Docker, so each chain and network keeps its own database.
Tests
On macOS Docker Desktop (arm64), from
packages/nodewith the LTC regtest env:docker compose configresolves the volume tobcn-db-LTC-regtest.npm run upcreated databasebcn, loaded the schema, and createddefaultwallet.POST /v1/LTC/regtest/rpcgetwalletinforeturned that wallet.bcnmadenode-db-1unhealthy.docker compose up -d bcn syncexited withcontainer node-db-1 is unhealthy, andbcnandsyncstayed stopped.npm run cleanremovedbcn-db-LTC-regtest.Not run here: Linux with Docker as root, rootless Docker, an Intel Mac, and EC2.