Prisma deploy - 本地部署的身份验证错误

Posted

技术标签:

【中文标题】Prisma deploy - 本地部署的身份验证错误【英文标题】:Prisma deploy - authentication error for local deployment 【发布时间】:2020-06-17 18:38:47 【问题描述】:

我正在尝试使用在端口 4466 上运行的本地 prisma 服务器运行 prisma deploy,但是当我运行 prisma deploy 时收到此消息

Authenticating...
Opening https://app.prisma.io/cli-auth?secret=$2a$08$u3VSbu6GSxSV8l86BFs24O in the browser

Could not open the authentication link, maybe this is an environment without a browser. Please open this url in your browser to authenticate: https://app.prisma.io/cli-auth?secret=$2a$08$u3VSbu6GSxSV8l86BFs24O

这是 prisma 服务器文件

mongodb:
   image: mongo:4.2
   container_name: mongodb
   volumes:
     - ./mongo-volume:/data/db
   ports:
     - "27017:27017"   

  prisma-server:
   image: prismagraphql/prisma:1.34.10
   container_name: prisma-server
   restart: always
   ports:
     - "4466:4466"
   environment:
     PRISMA_CONFIG: |
       port: 4466
       managementApiSecret: password@123
       databases:
         default:
           connector: mongo
           uri: mongodb://mongodb

这是我的 prisma.yml 文件。我在另一个 dockerfile 中运行 prisma deploy。

endpoint: $env:PRISMA_ENDPOINT
datamodel: datamodel.prisma
secret: $env:PRISMA_SECRET
databaseType: document
generate:
  - generator: javascript-client
    output: ./src/generated/prisma-client
hooks:
 post-deploy:
  - prisma generate
  - npx nexus-prisma-generate --client ./src/generated/prisma-client --output ./src/generated/nexus-prisma

这是我的 .env 文件

PRISMA_SECRET=password@123
PRISMA_ENDPOINT=http://prisma-server:4466/app/dev
API_SECRET=password@123

【问题讨论】:

【参考方案1】:

这帮助我在 Dockerfile 中运行 prisma deploy

FROM node:9-alpine

WORKDIR /app

COPY . .

# To handle 'not get uid/gid' error in alpine linux set unsafe-perm true
RUN apk update && apk upgrade && apk add bash \
    && npm config set unsafe-perm true \
    && chmod +x ./docker-scripts/entrypoint.sh \     
    && yarn install \
    && yarn global add prisma

EXPOSE 4000

CMD ["./docker-scripts/entrypoint.sh"]

入口点.sh

#!/bin/bash

# prisma deploy

 cd /prisma 
 prisma deploy

# go into the project...
 cd /app

 npm run start

码头工人撰写文件

services:
  prisma-client:
    image: image-name-here 
    container_name: prisma-client
    restart: always
    ports:
     - "4000:4000"
    environment:     
     PRISMA_ENDPOINT: http://prisma-server:4466      
    networks:
     - prisma

现在,一旦我做了 docker-compose prisma 客户端容器也被创建了。

【讨论】:

以上是关于Prisma deploy - 本地部署的身份验证错误的主要内容,如果未能解决你的问题,请参考以下文章

docker swarm deploy 上的 Prisma 配置错误

在 prisma deploy 上出现内部服务器错误

Google Cloud Functions Deploy“允许未经身份验证的调用......”

Prisma 无法使用本地 Mongodb 部署

Prisma deploy 报错 GraphQL Tutorial

Prismy deploy 命令抛出 Invalid Version 错误