Does anyone know how prisma + mysql container hand...
# orm-help
r
Does anyone know how prisma + mysql container handle ensuring the mysql container is spun up and mysql is running before prisma container is spun up? From my investigation it doesn’t which results in things breaking when you run docker-compose (if prisma spins up before mysql is running)
j
I would separate the containers.
r
?
They are separate already
e.g.
Copy code
version: '3'
services:
  database:
    image: prismagraphql/prisma:1.8
    restart: always
    ports:
    - "4467:4467"
    depends_on:
      - "mysql"
    environment:
      PRISMA_CONFIG: |
        port: 4467
        # 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: mysql
            host: mysql
            port: 3306
            user: root
            password: prisma
            migrations: true
  mysql:
    image: mysql:5.7
    restart: always
    environment:
      MYSQL_ROOT_PASSWORD: prisma
    volumes:
      - mysql:/var/lib/mysql
volumes:
  mysql:
this is what is generated from
prisma init
yet it does not guarantee that your db will be running before your prisma container
j
Right, what do you plan to do with production? What I did was ran my database in AWS. I didn't use docker for my database.
r
and it seems like the prisma server does not retry if it starts up prior to web server
it would be nice if the default way in the docs worked?
I will most likely move to something on the cloud, but for now just playign around locally
I have looked at using https://github.com/vishnubob/wait-for-it but I am not sure what the CMD/Entrypoint for the prisma dockerfile is
since the dockerfile is generated programmatically
and I can’t find it
j
No clue then.
r
😞
I don’t get how other people don’t run into this problem
n
@ryannealmes I've never run into this problem myself, but indeed I do see reports about it frequently. Might this be an issue with the Docker version? Note that in a typical setup, you would connect your Prisma container to a remote DB using HTTP, not to a local DB set up in your local Docker.
You might find this Dockerfile and scripts useful: https://github.com/dpetrick/prisma-heroku
r
Thanks I checked it out. Not sure on a couple of things in it. Hopefully the maintainer gets back to me.
I am almost 100% sure it’s an issue
the only way you can spin containers up in a specific order and ensure any required process (mysql) is up and running before you spin up the next container (prisma) is to modify the how/when prisma connects to the db - https://docs.docker.com/compose/startup-order/
I am surprised prisma is not leveraging some mechanism like this as docker-compose is in the getting started tutorial
anyway … there are work arounds and this functionality is to die for!