Anyone using connecting to prisma from docker? I h...
# orm-help
l
Anyone using connecting to prisma from docker? I have trouble runnin
prisma deploy
.. Seems like prisma forces me to use http:// or https:// in prisma.yml endpoint, but with docker I need to use the docker dns hostname
h
can you please paste your docker-compose.yml and prisma.yml here, that will help us debug this issue
l
Sample project
Copy code
# Specifies the HTTP endpoint of your Prisma API.
endpoint: prisma:4466

# Defines your models, each model is mapped to the database as a collection.
datamodel: datamodel.prisma

# Specifies the language and directory for the generated Prisma client.
generate:
  - generator: typescript-client
    output: ../src/generated/prisma-client/

# Ensures Prisma client is re-generated after a datamodel change.
hooks:
  post-deploy:
    - prisma generate

# Seeds initial data into the database by running a script.
seed:
  run: yarn ts-node ./prisma/seed.ts
Copy code
version: "3"
services:
  node:
    build: .
    depends_on:
      - postgres
      - prisma
  prisma:
    image: prismagraphql/prisma:1.28
    restart: always
    ports:
      - "4466:4466"
    environment:
      PRISMA_CONFIG: |
        port: 4466
        # uncomment the next line and provide the env var PRISMA_MANAGEMENT_API_SECRET=my-secret to activate cluster security
        # managementApiSecret: my-secret
        databases:
          default:
            connector: postgres
            host: postgres
            user: prisma
            password: prisma
            rawAccess: true
            port: 5432
            migrations: true
  postgres:
    image: postgres
    restart: always
    environment:
      POSTGRES_USER: prisma
      POSTGRES_PASSWORD: prisma
    volumes:
      - postgres:/var/lib/postgresql/data
volumes:
  postgres:
Copy code
FROM node:10

WORKDIR /usr/src/app

COPY package.json ./
COPY yarn.lock ./yarn

RUN yarn install

COPY . .

EXPOSE 8080

CMD ["npx", "prisma", "deploy"]
h
enpoint should be localhost:4466
not prisma:4466
it is not inside docker
l
localhost is not reachable from the docker container
h
so use
http prefix is important
try this
l
Tried but didnt work.. Will try again..
h
btw localhost should work
your cli is in your machine
cli is NOT inside docker
and the compose file is exposing 4466 to your machine
l
I run npx prisma deploy from the node container
Copy code
FROM node:10

WORKDIR /usr/src/app

COPY package.json ./
COPY yarn.lock ./yarn

RUN yarn install

COPY . .

EXPOSE 8080

CMD ["npx", "prisma", "deploy"]
h
ok got it
then http://prisma:4466 should work
l
Whan i use http:// I get:
Copy code
Authenticating...
Opening <https://app.prisma.io/cli-auth?secret=SECRET> in the browser
h
you need to copy prisma.yml as well
l
Doesnt
COPY . .
copy the whole dir including prisma.yml?
Just checked and it is there..
h
try
l
Same:
Copy code
Opening <https://app.prisma.io/cli-auth?secret=[SECRET]>. 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=[SECRET]>.
h
ok, let me try this locally with your folder
btw any specific reason why are using docker for deploy
l
Right now I get this issue on gitlab-ci. The sample proj is just a minimal reproducible sample..
h
ok, thanks I will try
l
But we are thinking of using docker (maybe kubernetes) when we move to prod.. Is it not recomended?
Thanks for helping me out with this!
h
it is recommended, here is an article for you in this regard https://techblog.commercetools.com/prisma-horizontal-scaling-a-practical-guide-3a05833d4fc3
l
Thanks!
Tried
npx prisma@1.28.3 deploy
and it seems to work..
h
oh ok, then the fix is simple. Just change the network name
l
Change it to localhost?
h
no
change prisma to something else in docker-compose
so that it will not pass this check and will not try to connect to prisma cloud
btw host.docker.internal was also giving the same result?
l
Yeah same result..
I will investigte some more..
I guess I need isPrivate to be false right?
h
yup
easier solution will be to use localhost
using network_mode: host
l
but as it stands now it needs to either containt 'eu1.prisma.sh' or 'us2.prisma.sh', end with 'db.cloud.prisma.sh' or be localhost
h
use network_mode: host
and then use localhost in prisma.yml
in the node image section
l
I cant do that on gitlab-ci.. Its not using docker-compose.
h
you can do that in docker
use
--net=host
with docker run
l
I need to look into that.. Dont know if there is a way i can make gitlab-ci use that arg when running docker..
This is my relevant gitlab-ci setup:
Copy code
E2E Test:
  stage: test
  image: cypress/base:10
  services:
    - postgres:10.3
    - name: larsjk/prisma-wait:1.28
      alias: prisma
  script:
    - cd server
    - npx prisma deploy
    - cd ..
    - yarn test:e2e
prisma-wait is extends prisma and adds a prerun_hook that waits for postgres..
h
ok, we havent tried providing it with a stage name
try this
p
as @Harshit correctly mentioned, the hostname is
prisma
, when http/https just sets the protocol
h
@prilutskiy That is not the issue now, the issue is that cli is somehow triggering the prisma cloud workflow instead of local one
cc @divyendu, Looks like you have written the parser so this belongs to you now
👍 1
l
Thanks for all the help @Harshit 🙌
h
@Lars-Jørgen Kristiansen btw can you confirm that 1.28.3 works, otherwise we need to write a test for the regression that the commit introduced
d
@Harshit: Please create a GH issue with minimal reproduction here: https://github.com/prisma/prisma/issues Thanks! 🙂
👍 1
l
@Harshit @divyendu I can confirm 1.28.3 works. Will create an issue!
h
Thanks, I will test it out locally now using the endpoint
Yup, can confirm. I will create the issue @Lars-Jørgen Kristiansen I have a more minimal repro
l
Thanks 👍
h
Oh great, this problem is related to a much bigger bug that many people are experiencing
l
😃 hope this helps you narrow it down and solve it then. Prisma is awesome btw. Keep up the good work!
h
basically parser is broken rn, if you are logged in you will get
No cluster could be found for workspace '*' and cluster 'default'
. Many people are reporting this and we were unable to repro this till now. Party because I realised that I had the alpha version of the cli installed. Thanks again for reporting
👍 1
m
I can confirm 2 other ppl has run into the same issue: https://prisma.slack.com/archives/CA491RJH0/p1552866923799100
We were both running 1.29-beta and reverting to an earlier version "fixed" the problem.
d
This is fixed in
1.29.1
, please install it using
npm install -g prisma
. These fixes are also back merged into latest
alpha
and
beta
.
👍 1
l
Awesome @divyendu Thanks!