mirror of
https://github.com/sergeyyarkov/node-docker-example.git
synced 2026-10-11 18:29:34 +03:00
fix: connection to db for heroku
This commit is contained in:
parent
6caec9beb3
commit
781b5aa157
@ -30,7 +30,7 @@ application.
|
|||||||
|
|
||||||
- 1. Clone this repository `git clone https://github.com/sergeyyarkov/node-docker-example.git .`
|
- 1. Clone this repository `git clone https://github.com/sergeyyarkov/node-docker-example.git .`
|
||||||
- 2. Configure enviroment variables in `docker-compose.yml` for `postgres` and `nodejs` serivces if you need to
|
- 2. Configure enviroment variables in `docker-compose.yml` for `postgres` and `nodejs` serivces if you need to
|
||||||
- 3. Build and run application with `docker compose up --build`
|
- 3. Build and run application with `docker-compose up --build`
|
||||||
|
|
||||||
## Requirements
|
## Requirements
|
||||||
|
|
||||||
|
|||||||
10
db.js
10
db.js
@ -6,12 +6,14 @@ class Database {
|
|||||||
constructor() {
|
constructor() {
|
||||||
this.client = new pg.Client({
|
this.client = new pg.Client({
|
||||||
connectionString:
|
connectionString:
|
||||||
process.env.NODE_ENV === 'production'
|
process.env.NODE_ENV === 'production' && process.env.DATABASE_URL
|
||||||
? process.env.DATABASE_URL
|
? process.env.DATABASE_URL
|
||||||
: connectionString,
|
: connectionString,
|
||||||
ssl: {
|
ssl: process.env.DATABASE_URL
|
||||||
rejectUnauthorized: false,
|
? {
|
||||||
},
|
rejectUnauthorized: false,
|
||||||
|
}
|
||||||
|
: false,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user