eve*_*der 5 postgresql continuous-integration github-actions
在我的 Django 项目中,我有一个用于运行测试的 CI 工作流程,这需要 Postgres 服务。最近,一个新的应用程序引入了更重的软件包,例如 pandas、matplotlib、pytorch 等,这将run-tests工作时间从 2 分钟增加到了 12 分钟,这是荒谬的。另外,在我的项目中,我有一个带有 Python 的基本 Docker 映像,以及这些较重的包,可以加快映像的构建速度。因此,我考虑在运行步骤时在工作流程中使用相同的图像,因为包已经加载。
不幸的是,一切都很顺利,直到到达实际运行测试的步骤,因为 postgres 服务似乎未与容器连接,并且出现以下错误:
psycopg2.OperationalError: could not connect to server: Connection refused
Is the server running on host "localhost" (127.0.0.1) and accepting
TCP/IP connections on port 5432?
Run Code Online (Sandbox Code Playgroud)
这就是我现在的工作流程。关于我做错了什么有什么想法吗?
psycopg2.OperationalError: could not connect to server: Connection refused
Is the server running on host "localhost" (127.0.0.1) and accepting
TCP/IP connections on port 5432?
Run Code Online (Sandbox Code Playgroud)
事实证明,工作流程现在正在其自己的容器中运行,位于 postgres 容器旁边。因此,映射到运行器虚拟机的端口\xe2\x80\x99不再执行任何操作(因为它影响主机,而不是其上的 Docker 容器)。
\n作业和服务容器连接到同一个 Docker 网络,因此我需要做的就是更改POSTGRES_HOST为postgres(服务容器的名称),而 Docker\xe2\x80\x99s DNS 应该完成其余的工作。
| 归档时间: |
|
| 查看次数: |
3012 次 |
| 最近记录: |