自从我转移到新的Apple Silicon架构后,我的带有nextjs和postgres的docker设置不再工作。Docker中的数据库无法被nextjs服务器找到,我正在使用prisma。
Prisma客户端无法访问5432端口上的Postgres数据库。
不能在
test-postgres
:5432
处连接到数据库服务器
迁移也不起作用,返回与上述相同的错误。
docker-compose run --publish 5555:5555 next npx prisma migrate dev
docker-compose.yml
:Docker Compose 配置文件。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模式中。
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 Desktop仪表板看到它。在postgres容器内部我注意到了这个错误:
2021-07-21 12:52:58.927 UTC [76] ERROR: relation "_prisma_migrations" does not exist at character 126
有人以前遇到过这个问题并找到了解决方案吗?
[编辑]
如何复现
克隆仓库,按照 README.md 的说明,在一台 M1 苹果芯片机器上看到预期的行为:https://github.com/baristikir/prisma-postgres-M1