错误:在Gitlab CI上连接ECONNREFUSED 127.0.0.1:5432

时间:2020-11-04 16:42:41

标签: node.js postgresql docker sequelize.js gitlab-ci

我目前正在一个项目上,我对Gitlab的CI有很大的疑问。 docker-compose有两个容器构建,一个是API,另一个是PostgreSQL数据库。

这是我的gitlab-ci.yml:

image: node:lastest

variables:
  POSTGRES_DB: test
  POSTGRES_USER: user
  POSTGRES_PASSWORD: pass
  POSTGRES_HOST: postgres
  POSTGRES_PORT: 5432
  POSTGRES_HOST_AUTH_METHOD: trust
  NODE_ENV: test

services:
  - postgres:12.2-alpine


stages:
   - test

eslint:
  stage: test
  image: node:12.18.2-alpine3.9
  before_script:
    - npm install
  script:
    - npm run linter
  except:
    - develop

audit:
  stage: test
  image: node:12.18.2-alpine3.9
  before_script:
    - npm install
    - npm install -g sequelize-cli
    - npx sequelize-cli db:create
  script:
    - npm test
  allow_failure: false
  except:
    - develop

所以,我得到了这个错误:

$ npx sequelize-cli db:create
Sequelize CLI [Node: 12.18.2, CLI: 6.2.0, ORM: 6.3.5]
Loaded configuration file "config/database.js".
Using environment "development".
ERROR: connect ECONNREFUSED 127.0.0.1:5432
Cleaning up file based variables
00:01
ERROR: Job failed: exit code 1

我想念什么?

谢谢!

2 个答案:

答案 0 :(得分:1)

主要问题应该在您的config/database.js文件中。

检查此文件中的主机是否为postgres而不是127.0.0.1

答案 1 :(得分:0)

似乎您的npm命令未在变量部分中使用POSTGRES_HOST。而是在连接到postgres时使用127.0.0.1,但由于您的服务未在本地运行而失败。解决该问题,它应该在Circle() .trim(from: 0.0, to: CGFloat(min(self.progress, 1.0))) .stroke(gradient ,style: StrokeStyle(lineWidth: 25.0, lineCap: .round, lineJoin: .round)) .rotationEffect(Angle(degrees: 270.0)) .animation(.linear, value: progress) // << here !! 上可用。