Skip to content

Commit 4652d00

Browse files
authored
fix(docker): pin postgres image and use named volume (#393)
* fix(docker): pin postgres image and use named volume * fix(docker): restore bind-mount for postgres data, add windows override - Revert nostream-db data volume from named volume back to bind-mount (\C:\Users\ckodi\Desktop\nostream/.nostr/data) to avoid breaking existing installations - Keep postgres:15 image pin from previous commit (non-breaking improvement) - Add docker-compose.windows.yml override for Windows/WSL2 users where bind-mounts cause PostgreSQL permission errors; uses named volume nostream-db-data instead - Windows users can run: docker compose -f docker-compose.yml -f docker-compose.windows.yml up --build or set COMPOSE_FILE in .env: COMPOSE_FILE=docker-compose.yml:docker-compose.windows.yml * docs: add Windows/WSL2 setup instructions to README
1 parent e9e0847 commit 4652d00

3 files changed

Lines changed: 185 additions & 147 deletions

File tree

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,16 @@ Start:
210210
./scripts/start_with_tor
211211
```
212212
213+
**Windows / WSL2 users:** Docker bind-mounts can cause PostgreSQL permission errors on Windows. Use the dedicated override file instead:
214+
```
215+
docker compose -f docker-compose.yml -f docker-compose.windows.yml up --build
216+
```
217+
Or add this to your `.env` file so you don't have to type it every time:
218+
```
219+
COMPOSE_FILE=docker-compose.yml:docker-compose.windows.yml
220+
```
221+
> **Note:** If you previously ran Nostream on Linux/Mac and are switching to Windows, your existing data lives at `.nostr/data/` on the host. You'll need to copy it into the Docker named volume manually or it won't be visible to the new setup.
222+
213223
Stop the server with:
214224
```
215225
./scripts/stop

docker-compose.windows.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# docker-compose.windows.yml
2+
#
3+
# Windows / WSL2 override for Nostream.
4+
#
5+
# On Windows (including WSL2), Docker bind-mounts to host paths can cause
6+
# PostgreSQL permission errors. This override replaces the bind-mount for
7+
# PostgreSQL data with a named Docker volume, which is managed entirely
8+
# by the Docker engine and avoids those issues.
9+
#
10+
# Usage:
11+
# docker compose -f docker-compose.yml -f docker-compose.windows.yml up --build
12+
#
13+
# Or set COMPOSE_FILE in your .env:
14+
# COMPOSE_FILE=docker-compose.yml:docker-compose.windows.yml
15+
#
16+
# WARNING: If you previously ran Nostream with the default docker-compose.yml
17+
# your data is in .nostr/data/ on the host. Before switching to this file,
18+
# migrate your data or it will not be accessible from the named volume.
19+
20+
services:
21+
nostream-db:
22+
volumes:
23+
- nostream-db-data:/var/lib/postgresql/data
24+
- ${PWD}/.nostr/db-logs:/var/log/postgresql
25+
- ${PWD}/postgresql.conf:/postgresql.conf
26+
27+
volumes:
28+
nostream-db-data:

docker-compose.yml

Lines changed: 147 additions & 147 deletions
Original file line numberDiff line numberDiff line change
@@ -1,147 +1,147 @@
1-
services:
2-
nostream:
3-
build: .
4-
container_name: nostream
5-
environment:
6-
SECRET: ${SECRET}
7-
RELAY_PORT: 8008
8-
# Master
9-
NOSTR_CONFIG_DIR: /home/node/.nostr
10-
DB_HOST: nostream-db
11-
DB_PORT: 5432
12-
DB_USER: nostr_ts_relay
13-
DB_PASSWORD: nostr_ts_relay
14-
DB_NAME: nostr_ts_relay
15-
DB_MIN_POOL_SIZE: 16
16-
DB_MAX_POOL_SIZE: 64
17-
DB_ACQUIRE_CONNECTION_TIMEOUT: 60000
18-
# Read Replica
19-
READ_REPLICAS: 2
20-
READ_REPLICA_ENABLED: 'false'
21-
# Read Replica No. 1
22-
RR0_DB_HOST: db
23-
RR0_DB_PORT: 5432
24-
RR0_DB_USER: nostr_ts_relay
25-
RR0_DB_PASSWORD: nostr_ts_relay
26-
RR0_DB_NAME: nostr_ts_relay
27-
RR0_DB_MIN_POOL_SIZE: 16
28-
RR0_DB_MAX_POOL_SIZE: 64
29-
RR0_DB_ACQUIRE_CONNECTION_TIMEOUT: 10000
30-
# Read Replica No. 2
31-
RR1_DB_HOST: db
32-
RR1_DB_PORT: 5432
33-
RR1_DB_USER: nostr_ts_relay
34-
RR1_DB_PASSWORD: nostr_ts_relay
35-
RR1_DB_NAME: nostr_ts_relay
36-
RR1_DB_MIN_POOL_SIZE: 16
37-
RR1_DB_MAX_POOL_SIZE: 64
38-
RR1_DB_ACQUIRE_CONNECTION_TIMEOUT: 10000
39-
# Add RR2, RR3, etc. to configure more read replicas
40-
# Redis
41-
REDIS_HOST: nostream-cache
42-
REDIS_PORT: 6379
43-
REDIS_USER: default
44-
REDIS_PASSWORD: nostr_ts_relay
45-
TOR_HOST: tor_proxy
46-
TOR_CONTROL_PORT: 9051
47-
TOR_PASSWORD: nostr_ts_relay
48-
HIDDEN_SERVICE_PORT: 80
49-
# Payments Processors
50-
# Zebedee
51-
ZEBEDEE_API_KEY: ${ZEBEDEE_API_KEY}
52-
# Nodeless.io
53-
NODELESS_API_KEY: ${NODELESS_API_KEY}
54-
NODELESS_WEBHOOK_SECRET: ${NODELESS_WEBHOOK_SECRET}
55-
# OpenNode
56-
OPENNODE_API_KEY: ${OPENNODE_API_KEY}
57-
# Lnbits
58-
LNBITS_API_KEY: ${LNBITS_API_KEY}
59-
# Enable DEBUG for troubleshooting. Examples:
60-
# DEBUG: "primary:*"
61-
# DEBUG: "worker:*"
62-
# DEBUG: "knex:query"
63-
user: node:node
64-
volumes:
65-
- ${PWD}/.nostr:/home/node/.nostr
66-
ports:
67-
- 127.0.0.1:8008:8008
68-
depends_on:
69-
nostream-cache:
70-
condition: service_healthy
71-
nostream-db:
72-
condition: service_healthy
73-
nostream-migrate:
74-
condition: service_completed_successfully
75-
restart: on-failure
76-
networks:
77-
default:
78-
79-
nostream-db:
80-
image: postgres
81-
container_name: nostream-db
82-
environment:
83-
POSTGRES_DB: nostr_ts_relay
84-
POSTGRES_USER: nostr_ts_relay
85-
POSTGRES_PASSWORD: nostr_ts_relay
86-
volumes:
87-
- ${PWD}/.nostr/data:/var/lib/postgresql/data
88-
- ${PWD}/.nostr/db-logs:/var/log/postgresql
89-
- ${PWD}/postgresql.conf:/postgresql.conf
90-
networks:
91-
default:
92-
command: postgres -c 'config_file=/postgresql.conf'
93-
restart: always
94-
healthcheck:
95-
test: ["CMD-SHELL", "pg_isready -U nostr_ts_relay"]
96-
interval: 5s
97-
timeout: 5s
98-
retries: 5
99-
start_period: 360s
100-
101-
nostream-cache:
102-
image: redis:7.0.5-alpine3.16
103-
container_name: nostream-cache
104-
volumes:
105-
- cache:/data
106-
command: redis-server --loglevel warning --requirepass nostr_ts_relay
107-
networks:
108-
default:
109-
restart: always
110-
healthcheck:
111-
test: [ "CMD", "redis-cli", "ping", "|", "grep", "PONG" ]
112-
interval: 1s
113-
timeout: 5s
114-
retries: 5
115-
116-
nostream-migrate:
117-
image: node:18-alpine3.16
118-
container_name: nostream-migrate
119-
environment:
120-
DB_HOST: nostream-db
121-
DB_PORT: 5432
122-
DB_USER: nostr_ts_relay
123-
DB_PASSWORD: nostr_ts_relay
124-
DB_NAME: nostr_ts_relay
125-
entrypoint:
126-
- sh
127-
- -c
128-
- 'cd code && npm install --no-save --quiet knex@2.4.0 pg@8.8.0 && npx knex migrate:latest'
129-
volumes:
130-
- ./migrations:/code/migrations
131-
- ./knexfile.js:/code/knexfile.js
132-
depends_on:
133-
nostream-db:
134-
condition: service_healthy
135-
networks:
136-
default:
137-
138-
networks:
139-
default:
140-
name: nostream
141-
ipam:
142-
driver: default
143-
config:
144-
- subnet: 10.10.10.0/24
145-
146-
volumes:
147-
cache:
1+
services:
2+
nostream:
3+
build: .
4+
container_name: nostream
5+
environment:
6+
SECRET: ${SECRET}
7+
RELAY_PORT: 8008
8+
# Master
9+
NOSTR_CONFIG_DIR: /home/node/.nostr
10+
DB_HOST: nostream-db
11+
DB_PORT: 5432
12+
DB_USER: nostr_ts_relay
13+
DB_PASSWORD: nostr_ts_relay
14+
DB_NAME: nostr_ts_relay
15+
DB_MIN_POOL_SIZE: 16
16+
DB_MAX_POOL_SIZE: 64
17+
DB_ACQUIRE_CONNECTION_TIMEOUT: 60000
18+
# Read Replica
19+
READ_REPLICAS: 2
20+
READ_REPLICA_ENABLED: 'false'
21+
# Read Replica No. 1
22+
RR0_DB_HOST: db
23+
RR0_DB_PORT: 5432
24+
RR0_DB_USER: nostr_ts_relay
25+
RR0_DB_PASSWORD: nostr_ts_relay
26+
RR0_DB_NAME: nostr_ts_relay
27+
RR0_DB_MIN_POOL_SIZE: 16
28+
RR0_DB_MAX_POOL_SIZE: 64
29+
RR0_DB_ACQUIRE_CONNECTION_TIMEOUT: 10000
30+
# Read Replica No. 2
31+
RR1_DB_HOST: db
32+
RR1_DB_PORT: 5432
33+
RR1_DB_USER: nostr_ts_relay
34+
RR1_DB_PASSWORD: nostr_ts_relay
35+
RR1_DB_NAME: nostr_ts_relay
36+
RR1_DB_MIN_POOL_SIZE: 16
37+
RR1_DB_MAX_POOL_SIZE: 64
38+
RR1_DB_ACQUIRE_CONNECTION_TIMEOUT: 10000
39+
# Add RR2, RR3, etc. to configure more read replicas
40+
# Redis
41+
REDIS_HOST: nostream-cache
42+
REDIS_PORT: 6379
43+
REDIS_USER: default
44+
REDIS_PASSWORD: nostr_ts_relay
45+
TOR_HOST: tor_proxy
46+
TOR_CONTROL_PORT: 9051
47+
TOR_PASSWORD: nostr_ts_relay
48+
HIDDEN_SERVICE_PORT: 80
49+
# Payments Processors
50+
# Zebedee
51+
ZEBEDEE_API_KEY: ${ZEBEDEE_API_KEY}
52+
# Nodeless.io
53+
NODELESS_API_KEY: ${NODELESS_API_KEY}
54+
NODELESS_WEBHOOK_SECRET: ${NODELESS_WEBHOOK_SECRET}
55+
# OpenNode
56+
OPENNODE_API_KEY: ${OPENNODE_API_KEY}
57+
# Lnbits
58+
LNBITS_API_KEY: ${LNBITS_API_KEY}
59+
# Enable DEBUG for troubleshooting. Examples:
60+
# DEBUG: "primary:*"
61+
# DEBUG: "worker:*"
62+
# DEBUG: "knex:query"
63+
user: node:node
64+
volumes:
65+
- ${PWD}/.nostr:/home/node/.nostr
66+
ports:
67+
- 127.0.0.1:8008:8008
68+
depends_on:
69+
nostream-cache:
70+
condition: service_healthy
71+
nostream-db:
72+
condition: service_healthy
73+
nostream-migrate:
74+
condition: service_completed_successfully
75+
restart: on-failure
76+
networks:
77+
default:
78+
79+
nostream-db:
80+
image: postgres:15
81+
container_name: nostream-db
82+
environment:
83+
POSTGRES_DB: nostr_ts_relay
84+
POSTGRES_USER: nostr_ts_relay
85+
POSTGRES_PASSWORD: nostr_ts_relay
86+
volumes:
87+
- ${PWD}/.nostr/data:/var/lib/postgresql/data
88+
- ${PWD}/.nostr/db-logs:/var/log/postgresql
89+
- ${PWD}/postgresql.conf:/postgresql.conf
90+
networks:
91+
default:
92+
command: postgres -c 'config_file=/postgresql.conf'
93+
restart: always
94+
healthcheck:
95+
test: ["CMD-SHELL", "pg_isready -U nostr_ts_relay"]
96+
interval: 5s
97+
timeout: 5s
98+
retries: 5
99+
start_period: 360s
100+
101+
nostream-cache:
102+
image: redis:7.0.5-alpine3.16
103+
container_name: nostream-cache
104+
volumes:
105+
- cache:/data
106+
command: redis-server --loglevel warning --requirepass nostr_ts_relay
107+
networks:
108+
default:
109+
restart: always
110+
healthcheck:
111+
test: [ "CMD", "redis-cli", "ping", "|", "grep", "PONG" ]
112+
interval: 1s
113+
timeout: 5s
114+
retries: 5
115+
116+
nostream-migrate:
117+
image: node:18-alpine3.16
118+
container_name: nostream-migrate
119+
environment:
120+
DB_HOST: nostream-db
121+
DB_PORT: 5432
122+
DB_USER: nostr_ts_relay
123+
DB_PASSWORD: nostr_ts_relay
124+
DB_NAME: nostr_ts_relay
125+
entrypoint:
126+
- sh
127+
- -c
128+
- 'cd code && npm install --no-save --quiet knex@2.4.0 pg@8.8.0 && npx knex migrate:latest'
129+
volumes:
130+
- ./migrations:/code/migrations
131+
- ./knexfile.js:/code/knexfile.js
132+
depends_on:
133+
nostream-db:
134+
condition: service_healthy
135+
networks:
136+
default:
137+
138+
networks:
139+
default:
140+
name: nostream
141+
ipam:
142+
driver: default
143+
config:
144+
- subnet: 10.10.10.0/24
145+
146+
volumes:
147+
cache:

0 commit comments

Comments
 (0)