【发布时间】:2020-08-17 22:30:53
【问题描述】:
我正在尝试为我正在处理的 FastAPI 样板设置管道。到目前为止我失败了,我不知道为什么。这是我所拥有的:
bitbucket-pipelines.yml
image: python:3.7.4-slim-buster
options:
max-time: 5
definitions:
steps:
- step: &test
name: test
script:
- >-
docker build -f {{cookiecutter.app_name}}/{{cookiecutter.service_name}}/tests.dockerfile
-t boilerplate ./{{cookiecutter.app_name}}/{{cookiecutter.service_name}}
- >-
docker run --env POSTGRES_HOST=host.docker.internal
--add-host host.docker.internal:$BITBUCKET_DOCKER_HOST_INTERNAL boilerplate
/bin/bash -c /run-tests.sh
services:
- docker
- postgres
caches:
- docker
services:
postgres:
image: postgres
environment:
POSTGRES_HOST_AUTH_METHOD: trust
pipelines:
pull-requests:
'**':
- step: *test
我正在连接到我的数据库:
DATABASE_URL = os.getenv('DATABASE_URL', 'postgresql://postgres@localhost/postgres')
这是我在运行管道时遇到的错误:
E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) could not connect to server: Connection refused
E Is the server running on host "localhost" (127.0.0.1) and acceptingE TCP/IP connections on port 5432?
E
E (Background on this error at: http://sqlalche.me/e/13/e3q8)
我添加了postgresql://postgres@localhost/postgres,因为这就是 BitBucket 为默认用户设置 postgresql 的方式。我做错了什么?
【问题讨论】:
标签: python-3.x postgresql bitbucket-pipelines fastapi