Prisma1: Problems with Travis + Prisma ^1.7.x

Created on 15 May 2018  路  14Comments  路  Source: prisma/prisma1

Bug Report / (potentially just help needed)

tl;dr

  1. Use Travis
  2. docker compose up -d
  3. prisma deploy

Travis is unable to find local cluster. (_You're not logged in and cluster local could not be found locally. Trying to authenticate._ on prisma deploy)

Started occurring when updating from prisma 1.6.3 to 1.7.1 (before that a docker config file wasn't needed, so seems like some changes have been made there)

Reproduction

Travis output

[..]

$ docker-compose -f api/database/docker-compose.yml up -d
Creating network "database_default" with the default driver
Creating volume "database_postgres" with default driver
Pulling prisma (prismagraphql/prisma:1.8)...
1.8: Pulling from prismagraphql/prisma
Digest: sha256:922a533d68d23c02ab248971e6a076c2840d2a98efff21fcfcc3882254661ec8
Status: Downloaded newer image for prismagraphql/prisma:1.8
Pulling postgres (postgres:latest)...
latest: Pulling from library/postgres
Digest: sha256:23c92d48934b254c007c08812638acfd849fe1c179a34b63c752a62100c6524d
Status: Downloaded newer image for postgres:latest
Creating database_prisma_1 ... 
Creating database_postgres_1 ... 
Creating database_postgres_1
Creating database_prisma_1
$ cd api && yarn prisma deploy
yarn run v1.3.2
$ /home/travis/build/[secure]/shop/api/node_modules/.bin/prisma deploy
You're not logged in and cluster local could not be found locally. Trying to authenticate.
Authenticating...
Opening https://app.prisma.io/cli-auth?secret=$2a$08$TWT3BgS415eJCPuWQsGZmO in the browser


Is there something I'm missing in the docker-compose or in the prisma deploy-command to find the local cluster?

As it worked with Prisma on 1.6.x I don't _think_ it's a problem with Travis.

aredocs

Most helpful comment

馃帀

Whoop whoop @divyenduz -- adding endpoint: seemed to have done the trick. It goes past that stage now. It breaks later but whatever is happening it's not because of this issue anymore! I'll do an update when I have a neat setup. 馃帀

Thank you for your help @divyenduz and @marktani !

All 14 comments

I'm pretty sure you're running into #2310, which has been fixed in the latest version.

Thanks for the answer @SpaceK33z. I suspect that as well, but I'm using 1.8.3 which is the latest published on npm. Or do I need to update the image in the docker config or something?

You need to update both the CLI and the Docker image 馃檪

Will do later / tmrw!

I set the docker image to explicit 1.8.3 but it didn't seem to make any difference

Travis output: https://travis-ci.org/KATT/shop/builds/387907606

$ cd api && yarn prisma deploy
yarn run v1.3.2
$ /home/travis/build/[secure]/shop/api/node_modules/.bin/prisma deploy
You're not logged in and cluster local could not be found locally. Trying to authenticate.
Authenticating...
Opening https://app.prisma.io/cli-auth?secret=$2a$08$Z3iQ99b4/NhdZ89nEHVZFO in the browser
Authenticating... !
ERROR: GraphQL Error (Code: 502)

@KATT - I was able to get this to working by using the following configuration:-

Config file used

Passing build with Prisma deploy

It would be awesome if you convert this example to a new Prisma example in a PR

Still happening.. Looks like it should be working but doesn't.. prisma deploy still doesn't pick up on the local container.

$ docker-compose -f api/database/docker-compose.yml up -d
Creating network "database_default" with the default driver
Creating volume "database_mysql" with default driver
Pulling mysql (mysql:5.7)...
5.7: Pulling from library/mysql
Digest: sha256:f030e84582d939d313fe2ef469b5c65ffd0f7dff3b4b98e6ec9ae2dccd83dcdf
Status: Downloaded newer image for mysql:5.7
Pulling prisma (prismagraphql/prisma:1.10)...
1.10: Pulling from prismagraphql/prisma
Digest: sha256:29dd2e76d48385386abc8cba7d15b13bfa583c11491232ca62ea3fb7fe5153f3
Status: Downloaded newer image for prismagraphql/prisma:1.10
Creating database_mysql_1 ... 
Creating database_mysql_1
a_1 ... 
Creating database_prisma_1
install.3

$ docker ps
CONTAINER ID        IMAGE                       COMMAND                  CREATED             STATUS                  PORTS                    NAMES
b8d0c838e8eb        prismagraphql/prisma:1.10   "/bin/sh -c /app/s..."   2 seconds ago       Up Less than a second   0.0.0.0:4466->4466/tcp   database_prisma_1
938582ff2fab        mysql:5.7                   "docker-entrypoint..."   2 seconds ago       Up 1 second             3306/tcp                 database_mysql_1
install.4

$ sleep 20

$ cd api && yarn prisma deploy
yarn run v1.3.2

$ /home/travis/build/[secure]/shop/api/node_modules/.bin/prisma deploy
You're not logged in and cluster local could not be found locally. Trying to authenticate.
Authenticating...
Opening https://app.prisma.io/cli-auth?secret=$2a$08$H44Wku9yyuvSg9q0KzfONu in the browser

@KATT : I think you also need to update your prisma.yml to deploy to localhost. The login step is what block you from running it on travis and login should not be asked for when deploying locally.

i.e. from your travis logs
$ export DEV_PRISMA_ENDPOINT="https://eu1.prisma.sh/kattcorp/shop/dev"

should point to localhost like http://localhost:4466/shop/dev

Added endpoint: in the prisma.yml.. let's see how it goes :)

https://github.com/KATT/shop/pull/93/commits/558d61af46fe97f0d54b7e6ff964c42635e8c798

It should get picked up by .env.. that's how it works locally.

Note: the DEV_-prefixed vars will not affect prisma. They're there to do continuous deployment to now.sh.

馃帀

Whoop whoop @divyenduz -- adding endpoint: seemed to have done the trick. It goes past that stage now. It breaks later but whatever is happening it's not because of this issue anymore! I'll do an update when I have a neat setup. 馃帀

Thank you for your help @divyenduz and @marktani !

I put together a minimal example for a Travis setup here: https://github.com/prismagraphql/prisma/tree/master/examples/travis 馃檪

@divyenduz hey man, from your config files and job log, it looks like you are spinning up fresh set of docker processes. And then seeding them with data.

What about in a CD environment? Wouldn't you just keep one mysql instance and one prisma instance and continuously deploy new schema to existing instance?

Has your team come across this?

@roycclu : Based on your environment/use-case you can modify your docker-compose.yml to make prisma talk to an ever running mysql backend via environment variables or by hard-coding. Does that make sense? Happy to help.

@divyenduz thanks man.

It seems docker-compose is more useful for local environments. Using volume should persist data.

And in a CI/CD environment, would you say it's better to set up the initial prisma service manually and then run a "prisma deploy" script, in CI migration stage, after the node server is built and deployed?

Basically I'm deciding between setting up and running a new prisma server every git push. Or continuously deploy to an initial manually set up prisma server. How are you guys managing this?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

marktani picture marktani  路  3Comments

marktani picture marktani  路  3Comments

notrab picture notrab  路  3Comments

AlessandroAnnini picture AlessandroAnnini  路  3Comments

sorenbs picture sorenbs  路  3Comments