Вот мой docker-compose
version: '2'
services:
weather-cities:
build:
context: .
volumes:
- .:/usr/app
- /usr/app/node_modules/
ports:
- "8080:8080"
# Set environment variables from this file
# env_file:
# - .env
# Overwrite any env var defined in .env file (if required)
environment:
- DB_NAME=test
- DB_PORT=5432
- DB_HOST=postgres
- DB_USERNAME=test
- DB_PASSWORD=challenge
- APP_PORT=8080
links:
- postgres
postgres:
image: "postgres:9.4.11"
ports:
- "5432:5432"
environment:
- POSTGRES_USER=test
- POSTGRES_PASSWORD=challenge
Запуск этого сценария миграции
"db:migrate": "./node_modules/.bin/sequelize --migrations-path=migrations --models-path=models --config=config/config.js db:migrate"
А вот и мой Dockerfile
FROM node:8.10.0
WORKDIR /usr/app
COPY package.json .
RUN npm install --quiet
COPY . .
RUN npm run db:migrate
RUN npm run db:seed
EXPOSE 8080
CMD ["npm", "start"]
Выход:
Загружен файл конфигурации "config / config.js". Использование среды
"Развитие".
ОШИБКА: подключить ECONNREFUSED 127.0.0.1:5432
config.js
let config = {
"development": {
"username": process.env.DB_USERNAME,
"password": process.env.DB_PASSWORD,
"database": process.env.DB_NAME,
"host": process.env.DB_HOST,
"dialect": "postgres",
"port": process.env.DB_PORT
}
};
module.exports = config;