dockerprismaprisma-graphqlnexus-prismaprisma-binding

Prisma deploy - authentication error for local deployment


I am trying to run prisma deploy using a local prisma server running on port 4466 but when I run prisma deploy I get this message

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

This is prisma server file

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

this is my prisma.yml file. I am running prisma deploy within another dockerfile.

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

this is my .env file

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

Solution

  • This helped me to run prisma deploy within a Dockerfile

    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"]
    

    entrypoint.sh

    #!/bin/bash
    
    # prisma deploy
    
     cd /prisma 
     prisma deploy
    
    # go into the project...
     cd /app
    
     npm run start
    
    

    docker-compose file

    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
    
    

    Now once I did docker-compose prisma client container was also created.