Skip to content

Commit 4f34627

Browse files
authored
Merge pull request #137 from cephie-studios/canary
Add postgres to allowed hosts in getSSLConfig
2 parents 2b6ef9e + b5a5cc8 commit 4f34627

File tree

5 files changed

+34
-48
lines changed

5 files changed

+34
-48
lines changed

docker-compose.canary.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
version: '3.8'
1+
version: "3.8"
22

33
services:
44
pfcontrol:
55
build:
66
context: .
77
dockerfile: Dockerfile
88
ports:
9-
- '9902:9902'
9+
- "9902:9902"
1010
environment:
1111
- NODE_ENV=production
1212
env_file:

docker-compose.dev.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
version: '3.8'
1+
version: "3.8"
22

33
services:
44
postgres:
55
image: postgres:16-alpine
66
container_name: pfcontrol-postgres-dev
77
ports:
8-
- '5432:5432'
8+
- "5432:5432"
99
environment:
1010
POSTGRES_USER: pfcontrol
1111
POSTGRES_PASSWORD: pfcontrol
@@ -16,7 +16,7 @@ services:
1616
networks:
1717
- pfcontrol-network
1818
healthcheck:
19-
test: ['CMD-SHELL', 'pg_isready -U pfcontrol']
19+
test: ["CMD-SHELL", "pg_isready -U pfcontrol"]
2020
interval: 10s
2121
timeout: 5s
2222
retries: 5
@@ -25,14 +25,14 @@ services:
2525
image: redis:7-alpine
2626
container_name: pfcontrol-redis-dev
2727
ports:
28-
- '6379:6379'
28+
- "6379:6379"
2929
volumes:
3030
- redis_data:/data
3131
restart: unless-stopped
3232
networks:
3333
- pfcontrol-network
3434
healthcheck:
35-
test: ['CMD', 'redis-cli', 'ping']
35+
test: ["CMD", "redis-cli", "ping"]
3636
interval: 10s
3737
timeout: 3s
3838
retries: 5
@@ -42,8 +42,8 @@ services:
4242
context: .
4343
dockerfile: Dockerfile.dev
4444
ports:
45-
- '9901:9901'
46-
- '5173:5173'
45+
- "9901:9901"
46+
- "5173:5173"
4747
environment:
4848
- NODE_ENV=development
4949
env_file:

docker-compose.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
version: '3.8'
1+
version: "3.8"
22

33
services:
44
pfcontrol:
55
build:
66
context: .
77
dockerfile: Dockerfile
88
ports:
9-
- '9900:9900'
9+
- "9900:9900"
1010
environment:
1111
- NODE_ENV=production
1212
env_file:

package-lock.json

Lines changed: 15 additions & 35 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

server/db/connection.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,10 @@ async function ensureDatabasesExist() {
2525
const url = new URL(mainDbUrl);
2626
const baseConnectionString = `postgresql://${url.username}:${url.password}@${url.host}/postgres`;
2727

28-
const isLocalhost = url.hostname === 'localhost' || url.hostname === '127.0.0.1';
28+
const isLocalhost =
29+
url.hostname === 'localhost' ||
30+
url.hostname === '127.0.0.1' ||
31+
url.hostname === 'postgres';
2932

3033
const client = new pg.Client({
3134
connectionString: baseConnectionString,
@@ -66,7 +69,10 @@ await ensureDatabasesExist();
6669

6770
function getSSLConfig(connectionString: string) {
6871
const url = new URL(connectionString);
69-
const isLocalhost = url.hostname === 'localhost' || url.hostname === '127.0.0.1';
72+
const isLocalhost =
73+
url.hostname === 'localhost' ||
74+
url.hostname === '127.0.0.1' ||
75+
url.hostname === 'postgres';
7076
return isLocalhost ? false : { rejectUnauthorized: false };
7177
}
7278

0 commit comments

Comments
 (0)