【发布时间】:2018-03-20 05:35:28
【问题描述】:
我在 gitlab 上有一个 Django 应用程序,我正在尝试使用 gitlab-ci 添加 CI/CD。我在 EC2 上启动了一个服务器,并在上面安装了 gitlab-runner。
我在我的项目中添加了.gitlab-ci.yml 文件并推送了最新的更改。我可以看到正在运行的管道和正在安装的依赖项。但是当脚本尝试运行测试时,我收到如下错误:
django.db.utils.OperationalError:无法连接到服务器:连接被拒绝
服务器是否在主机“localhost”(::1) 上运行并接受 端口 5432 上的 TCP/IP 连接?
无法连接到服务器:连接被拒绝
服务器是否在主机“localhost”(127.0.0.1) 上运行并接受 端口 5432 上的 TCP/IP 连接?
下面是我的.gitlab-ci.yaml 脚本:
image: python:3-jessie
services:
- postgres:latest
before_script:
- python -V
- apt-get -y update
- apt-get install -y python-dev python-pip
- pip install --upgrade pip
stages:
- build
build:
type: build
variables:
DATABASE_URL: postgres://postgres:@postgres:5432/opensys_erp
script:
- pip install -r requirements.txt
- python manage.py test
only:
- branches
为什么我的应用程序无法连接到 postgres 服务器?
【问题讨论】:
标签: postgresql docker gitlab-ci