【发布时间】:2021-09-29 05:26:16
【问题描述】:
自从我迁移到新的 Apple Silicon 架构后,我使用 nextjs 和 postgres 设置的 docker 不再工作了。我使用 prisma 的 nextjs 服务器找不到 docker 内的数据库。
prisma 客户端无法访问端口 5432 上的 postgres 数据库。
无法访问
test-postgres:5432的数据库服务器
迁移也不起作用并返回与上述相同的错误。
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
【问题讨论】:
标签: node.js postgresql docker prisma apple-m1