M1相关! - Prisma:无法访问位于“数据库”的数据库服务器:“5432”
M1 Related! - Prisma: Can't reach database server at `database`:`5432`
自从我迁移到新的 Apple Silicon 架构后,我的 docker 与 nextjs 和 postgres 的设置不再有效。我正在使用 prisma 的 nextjs 服务器无法找到 docker 中的数据库。
prisma 客户端无法访问端口 5432 上的 postgres 数据库。
Can't reach database server at test-postgres
:5432
迁移也不起作用,returns 出现与上面相同的错误。
docker-compose run --publish 5555:5555 next npx prisma migrate dev
docker-compose.yml
postgres:
container_name: 'test-postgres'
restart: unless-stopped
image: 'postgres:13'
ports:
- '15432:5432'
volumes:
- 'pgdata:/var/lib/postgresql/data/'
environment:
POSTGRES_PASSWORD: postgres
.env
DATABASE_URL="postgres://postgres:postgres@localhost:15432/postgres"
我还将 arm 二进制目标添加到 schema.prisma
schema.prisma
generator client {
provider = "prisma-client-js"
binaryTargets = ["native", "debian-openssl-1.1.x", "linux-arm-openssl-1.1.x", "linux-musl"]
previewFeatures = ["orderByRelation", "selectRelationCount"]
}
postgres 容器实际上是 运行,我可以通过 Docker 桌面仪表板看到它。我在 postgres 容器中注意到的一件事是这个错误:
2021-07-21 12:52:58.927 UTC [76] ERROR: relation "_prisma_migrations" does not exist at character 126
有没有人遇到过并找到解决办法?
[编辑]
如何重现
克隆 repo,遵循 README.md 并查看 M1 Apple Silicon Machine 上的预期行为:https://github.com/baristikir/prisma-postgres-M1
在数据库的连接字符串中添加 ?connect_timeout=300
就成功了。
DATABASE_URL="postgres://postgres:postgres@localhost:15432/postgres?connect_timeout=300"
自从我迁移到新的 Apple Silicon 架构后,我的 docker 与 nextjs 和 postgres 的设置不再有效。我正在使用 prisma 的 nextjs 服务器无法找到 docker 中的数据库。
prisma 客户端无法访问端口 5432 上的 postgres 数据库。
Can't reach database server at
test-postgres
:5432
迁移也不起作用,returns 出现与上面相同的错误。
docker-compose run --publish 5555:5555 next npx prisma migrate dev
docker-compose.yml
postgres:
container_name: 'test-postgres'
restart: unless-stopped
image: 'postgres:13'
ports:
- '15432:5432'
volumes:
- 'pgdata:/var/lib/postgresql/data/'
environment:
POSTGRES_PASSWORD: postgres
.env
DATABASE_URL="postgres://postgres:postgres@localhost:15432/postgres"
我还将 arm 二进制目标添加到 schema.prisma schema.prisma
generator client {
provider = "prisma-client-js"
binaryTargets = ["native", "debian-openssl-1.1.x", "linux-arm-openssl-1.1.x", "linux-musl"]
previewFeatures = ["orderByRelation", "selectRelationCount"]
}
postgres 容器实际上是 运行,我可以通过 Docker 桌面仪表板看到它。我在 postgres 容器中注意到的一件事是这个错误:
2021-07-21 12:52:58.927 UTC [76] ERROR: relation "_prisma_migrations" does not exist at character 126
有没有人遇到过并找到解决办法?
[编辑]
如何重现
克隆 repo,遵循 README.md 并查看 M1 Apple Silicon Machine 上的预期行为:https://github.com/baristikir/prisma-postgres-M1
在数据库的连接字符串中添加 ?connect_timeout=300
就成功了。
DATABASE_URL="postgres://postgres:postgres@localhost:15432/postgres?connect_timeout=300"