Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Error: Invalid Prisma endpoint provided" when using docker-compose to deploy a server alongside prisma server #247

Open
n2ctech opened this issue Nov 6, 2018 · 5 comments

Comments

@n2ctech
Copy link

n2ctech commented Nov 6, 2018

Describe the bug

When using docker-compose to deploy a server (e.g. Apollo Server or graphql yoga) talking to prisma server, it is not possible to reference the prisma server container by its name because of string validation in prisma-binding module :
/app/node_modules/prisma-binding/dist/Prisma.js:44
throw new Error("Invalid Prisma endpoint provided: " + endpoint);

To Reproduce

Consider a docker-compose file:

version: "3"
services:
  prisma:
    image: prismagraphql/prisma:1.19
    restart: always
    ports:
      - 4466:4466
    environment:
      PRISMA_CONFIG: |
        port: 4466
        managementApiSecret: xxxxx
        databases:
          default:
            connector: postgres
            host: postgres
            port: 5432
            user: postgres
            password: postgres
            migrations: true
  postgres:
    image: postgres:10.5
    restart: always
    environment:
      POSTGRES_USER: postgres
      POSTGRES_PASSWORD: postgres
    volumes:
      - postgres:/var/lib/postgresql/data
  server:
    build:
      dockerfile: Dockerfile.dev
      context: .
    volumes:
      - /app/node_modules
      - ./:/app
    environment:
      - PRISMA_MANAGEMENT_API_SECRET=xxxxx
      - APP_SECRET=xxxxxx
      - PRISMA_URL=prisma
      - PRISMA_SECRET=xxxxx
volumes:
  postgres:

the graphql server running in the server container will try initialise the prisma binding like so :

module.exports = {
  prismaBinding: new Prisma({
    typeDefs,
    endpoint: process.env.PRISMA_URL,
    secret: process.env.PRISMA_SECRET
  })
};

When running docker-compose up this will throw an error when the server image is built and starts running : Error: Invalid Prisma endpoint provided: prisma
This is because it expects the prisma endpoint to start with http://

When deploying to a kubernetes cluster I am experiencing the same issue because the ClusterIP service name for my prisma server pod doesn't start with "http://". Hence the server pod can't talk to prisma server inside the cluster because it crashes with the same error.

Expected behavior
I should be able to take advantage of docker-compose networking tooling with prisma (a container can reference another container's IP address using its name).
Referencing the prisma server from another service by its name (e.g. "prisma") should work.
Idem in k8s when referencing prisma by its service name from another pod.

@maticzav
Copy link
Collaborator

maticzav commented Nov 20, 2018

Hey @n2ctech 👋,

Have you tried using localhost:4466? Also, why was this issue moved here in the first place?
cc @divyenduz

@divyenduz
Copy link
Contributor

@maticzav : Because AFAIK, the issue is in prisma-binding string validation.

@maticzav
Copy link
Collaborator

@divyenduz I suggest we change the error to a warning. Do you think this could brake anything?

@divyenduz
Copy link
Contributor

@maticzav : Most likely no, but if someone relies on this logic for their URL validation, then their application might break. In any case, we should clearly mention this in release notes should we decide to do it.

@ghost
Copy link

ghost commented Aug 24, 2019

Thanks to inlightmedia for his answer on prisma.io

In the end I found that you have to add http:// to the beginning of the service name like so: “http://prisma:4466”

This worked for me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants