最后是在RUN命令中添加临时环境变量解决。 原来的RUN 命令: RUN npx prisma migrate deploy 添加临时变量后的RUN命令: RUN DATABASE_URL=mysql://root:password@云托管MySQL外网地址/mydb?schema=public npx prisma migrate deploy
构建时prisma无法连接云托管MySQL,构建失败?[2024-04-28 15:35:44] Step 9/11 : RUN npx prisma migrate deploy [2024-04-28 15:35:44] ---> Running in 49a6a9d2a38d [2024-04-28 15:35:45] Prisma schema loaded from prisma/schema.prisma [2024-04-28 15:35:45] Datasource "db": MySQL database "mydb" at "10.9.107.39:3306" [2024-04-28 15:35:51] [2024-04-28 15:35:51] Error: P1001: Can't reach database server at `10.9.107.39`:`3306` [2024-04-28 15:35:51] [2024-04-28 15:35:51] Please make sure your database server is running at `10.9.107.39`:`3306`. [2024-04-28 15:35:51] The command '/bin/sh -c npx prisma migrate deploy' returned a non-zero code: 1 [2024-04-28 15:35:51] [Pipeline] } ip和端口正确的: [图片]
05-05