it's my first time working with docker-compose. I have this file:
db:
image: postgres
ports:
- "3600:5432"
environment:
- POSTGRES_HOST=127.0.0.1
- POSTGRES_DB=db
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=postgres1
api:
build: .
ports:
- "4500:4500"
links:
- db
And now I have to translate it to version 3:
version: "3"
services:
db:
image: postgres
ports:
- "3600:5432"
environment:
POSTGRES_HOST: "127.0.0.1"
POSTGRES_DB: "db"
POSTGRES_USER: "postgres"
POSTGRES_PASSWORD: "postgres1"
api:
build: .
ports:
- "4500:4500"
links:
- db
It's a node app with postgres linked, and when I'm reading how to connect to the database, I do it like this:
var fs = require('fs');
var config = JSON.parse(fs.readFileSync('./config/prod.json', 'utf8'));
config.database = {
host: (process.env.TRAVELOOCAPI_DB_1_PORT_5432_TCP_ADDR || "localhost"),
port: (process.env.TRAVELOOCAPI_DB_1_PORT_5432_TCP_PORT || "5432"),
db: (process.env.TRAVELOOCAPI_DB_1_ENV_POSTGRES_DB || 'myapp'),
dialect: 'postgres',
user: (process.env.TRAVELOOCAPI_DB_1_ENV_POSTGRES_USER || 'pg'),
pass: (process.env.TRAVELOOCAPI_DB_1_ENV_POSTGRES_PASSWORD || 'password'),
};
It works with first version but it doesn't with second version. There's nothing in process.env related to postgres.
What am I doing wrong?
Thanks!
via Javier Manzano
No comments:
Post a Comment