Skip to content

fix(docker): pin postgres image and use named volume#393

Open
CKodidela wants to merge 1 commit intocameri:mainfrom
CKodidela:fix-postgres-docker
Open

fix(docker): pin postgres image and use named volume#393
CKodidela wants to merge 1 commit intocameri:mainfrom
CKodidela:fix-postgres-docker

Conversation

@CKodidela
Copy link
Copy Markdown

Description

This PR updates docker-compose.yml to stabilize the local development environment across different operating systems by preventing two common database crash scenarios:

  1. Pinned PostgreSQL Image (postgres:14): Prevents Docker from pulling newer major versions (like v18), which crash on startup when attempting to read .nostr/data files created by older versions.
  2. Migrated to Named Docker Volume: Switched the local DB file mapping from a bound path (${PWD}/.nostr/data) to a standard named Docker volume (nostream-db-data). This resolves persistent file permission errors (Operation not permitted on initdb) encountered by developers running Docker Desktop via Windows/WSL.

Related Issue

Fixes #387

Motivation and Context

Running ./scripts/start_local can easily result in immediate failure for new contributors or developers returning after a while depending on their OS or caching status. By pinning the DB version and using proper Docker volumes for data mounts, the spin-up process becomes completely deterministic and avoids brittle Linux-to-WSL file system boundaries.

How Has This Been Tested?

  • Verified that deleting existing containers/volumes and running ./scripts/start_local correctly provisions PostgreSQL 14 and initializes the data directory.
  • Confirmed nostream-db container reaches a healthy state, allowing the rest of the application (Redis, migrations, web socket server) to boot without looping/crashing.
  • Tested locally on Windows via WSL to ensure filesystem permission errors are bypassed entirely.

Screenshots (if appropriate):

Types of changes

  • Non-functional change (docs, style, minor refactor)
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my code changes.
  • All new and existing tests passed.

@CKodidela
Copy link
Copy Markdown
Author

Hey! I noticed the 'Files changed' diff shows changes across the entire docker-compose.yml instead of just the 3 lines I edited. It looks like my code editor's auto-formatter ran on save and cleaned up the indentation/quotes globally before I committed. I apologize for the noise in the diff! I've disabled my auto-formatter for this workspace and will be more careful with it off from here out in future commits going forward.

POSTGRES_USER: nostr_ts_relay
POSTGRES_PASSWORD: nostr_ts_relay
volumes:
- nostream-db-data:/var/lib/postgresql/data
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is a breaking change for anyone currently using Nostream. Can you elaborate why you think this is necessary?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(docker): Pin PostgreSQL image version to prevent data volume compatibility crashes

2 participants