Would someone confirm that this is not expected be...
# orm-help
j
Would someone confirm that this is not expected behavior? I don't think it is but the last two days of searching have me feeling gaslit. My issue is that the the basic
prisma init
Docker example built into the Prisma CLI doesn't work. Here's the standard boilerplate setup in an empty dir:
Copy code
Jonathans-Air:prismaex lirum$ ls
Jonathans-Air:prismaex lirum$ prisma init
? Set up a new Prisma server or deploy to an existing server? Create new database
? What kind of database do you want to deploy to? MySQL
? Select the programming language for the generated Prisma client Prisma JavaScript Client

Created 3 new files:

  prisma.yml           Prisma service definition
  datamodel.prisma    GraphQL SDL-based datamodel (foundation for database)
  docker-compose.yml   Docker configuration file

Next steps:

  1. Start your Prisma server: docker-compose up -d
  2. Deploy your Prisma service: prisma deploy
  3. Read more about Prisma server:
     <http://bit.ly/prisma-server-overview>

Generating schema... 25ms
Saving Prisma Client (JavaScript) at /Users/lirum/Documents/programming/projects/learndocker/ex5/prismaex/generated/prisma-client/



   ╭──────────────────────────────────────╮
   │                                      │
   │   Update available 1.32.0 → 1.32.2   │
   │    Run npm i -g prisma to update     │
   │                                      │
   ╰──────────────────────────────────────╯

Jonathans-Air:prismaex lirum$ ls
datamodel.prisma        docker-compose.yml      generated               prisma.yml
Jonathans-Air:prismaex lirum$ docker-compose up -d
Creating network "prismaex_default" with the default driver
Creating prismaex_mysql_1  ... done
Creating prismaex_prisma_1 ... done
Jonathans-Air:prismaex lirum$
Cool, so they're running and I can check with `docker ps`:
Copy code
Jonathans-Air:prismaex lirum$ docker ps
CONTAINER ID        IMAGE                       COMMAND                  CREATED             STATUS              PORTS                    NAMES
3421e8b8f214        prismagraphql/prisma:1.32   "/bin/sh -c /app/sta…"   4 minutes ago       Up 4 minutes        0.0.0.0:4466->4466/tcp   prismaex_prisma_1
dba528e010a4        mysql:5.7                   "docker-entrypoint.s…"   4 minutes ago       Up 4 minutes        3306/tcp, 33060/tcp      prismaex_mysql_1
Jonathans-Air:prismaex lirum$
But when I checkout the playground at localhost:4466 in my browser, I'm show a "Server cannot be reached" error message (attached). This is not what I should be seeing, right? I should be able to inspect the schema from this Playground?
And yes, it looks like both Prisma and DB are up and open for connection when I view the logs:
Copy code
Jonathans-Air:prismaex lirum$ docker-compose logs
Attaching to prismaex_prisma_1, prismaex_mysql_1
prisma_1  | No log level set, defaulting to INFO.
prisma_1  | [INFO] {} - Started.
prisma_1  | [INFO] {} - Started.
prisma_1  | [INFO] {} - Close initiated...
prisma_1  | [INFO] {} - Closed.
prisma_1  | [INFO] Initializing workers...
prisma_1  | [INFO] Obtaining exclusive agent lock...
prisma_1  | [INFO] Obtaining exclusive agent lock... Successful.
prisma_1  | [INFO] Successfully started 1 workers.
prisma_1  | [INFO] Deployment worker initialization complete.
prisma_1  | Server running on :4466
mysql_1   | 2019-05-11T19:40:36.312944Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
mysql_1   | 2019-05-11T19:40:36.316582Z 0 [Note] mysqld (mysqld 5.7.26) starting as process 1 ...
mysql_1   | 2019-05-11T19:40:36.322954Z 0 [Note] InnoDB: PUNCH HOLE support available
mysql_1   | 

--- snipping lots of initialization code ---

2019-05-11T19:40:36.644296Z 0 [Note] mysqld: ready for connections.
mysql_1   | Version: '5.7.26'  socket: '/var/run/mysqld/mysqld.sock'  port: 3306  MySQL Community Server (GPL)
Things I've tried so far: Maybe playground isn't working correctly because NODE_ENV isn't set inside the Prisma container? Nope. I altered docker-compose to have
Copy code
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: mysql
            host: mysql
            user: root
            password: prisma
            rawAccess: true
            port: 3306
            migrations: true
      NODE_ENV: "development"
Still receiving a "cannot find server" error from the Playground.
Solved (I think?) I had never run `prisma deploy`; doing so allows me to use/inspect/run queries in Playground. But I also didn't think I needed to run deploy to view the playground. What is
prisma deploy
doing
, and why does it show "Server cannot be reached" if the server is most definitely online? Why not something like "Schema cannot be found"?
👍 1
s
Yeah, I think this message is misleading too.
j
You should use http when working with localhost
prisma deploy set ups the databases for you. Look into your browser and make sure it is http and not https