Hi! I am trying to run prisma on Heroku. I’ve crea...
# orm-help
m
Hi! I am trying to run prisma on Heroku. I’ve created a
Dockerfile
pointing to the
prismagraphql/prisma:1.8
image. But Heroku gives me an error when I try to upload it:
Your Docker image must specify a 'CMD' instruction.
Does anybody knows how to go around this?
Hi @nilan, do you have any toughts on this?
n
@marano have a look at https://github.com/dpetrick/prisma-heroku 🙂
m
awesome, sure I will, thank you!
I’ve managed to get the image running, I’m almost there. The only issue I’m seeing now is that prisma seems to try to connect to “postgres” database, even if the configuration points to another database name. I get:
Copy code
FATAL: permission denied for database "postgres"
And I know that my database is being properly passed to prisma because if I use a database name that doesn’t exist, I get a proper error saying that the informed database is not there. But when I use the correct one I get this error.
s
@nilan I’ve spent several hours trying to get a Postgres instance to work, and this heroku repo is SO helpful. Worthy of its own writeup in the deployment section. Particularly (with a quick edit of the config) because I can do
heroku addons:create heroku-postgresql:hobby-dev
and have a Postgres database working immediately.
💯 1
m
@Stef Did you happen to run into connection pool limit issues?
s
@marano not managed to get very much further with it because I’m having trouble getting the node example boilerplate to work. If you’re hitting pool limits then you probably want to add the Heroku buildpack for pgbouncer?
m
I was hopping I could configure prisma number of workers/pool size
I will take a look into that, thanks
s
@marano ah I’ve just looked and yes, it’s not clearing connections - now getting 503 FATAL: too many connections for role
m
I see, I was also getting
FATAL: permission denied for database "postgres"
errors on server start up
yea 😄
s
Yes - I forked this example to allow you to specify the database name
m
I did exactly the same on my local configuration
s
There’s a PR on the original repo fromme.
m
I saw it, nice!
I was able to run
prisma deploy
against my server, and run a few queries in the meantime between the database errors
my server also broke because of memory allocation a few times
so unless I use pay for a bigger dyno and bigger database it doesn’t seem to be possible to run it on heroku
I was even considering to use RDS just for the database because heroku postgres connection pool only increase at the $50 plan
s
Ah - you can’t use buildpacks with heroku container
😓 1
The pgbouncer buildpack essential gives you ‘virtual’ connections. It holds the maximum number it can of real postgres connections, then you connect to it and it waits for a connection to become available from that pool.
So you don’t need to upgrade…
m
so the solution could be something like a proxy dyno running the pgbouncer pool?
ho, I see it needs to connect locally
s
Exactly what I just got to.
Oh really?
m
it says you need to call your commands followed by
bin/start-pgbouncer-stunnel
let me know how far you can get with this approach 🙂
s
Ah I see.
Found this in another repo: SQL_CLIENT_CONNECTION_LIMIT=30 SQL_INTERNAL_CONNECTION_LIMIT=30
m
awesome! did you give it a go?
s
I’ve done that and I’ve also set up a database using compose.io instead of Heroku Postgres. Then created a “graphcool” database there just in case. That part seems to be going okay now.
But now I’ve got
Copy code
prisma deploy
Creating stage default for service default !

ERROR: Authentication token is invalid: Token can’t be decoded: Expected token [null] to be composed of 2 or 3 parts separated by dots.

{
  “data”: {
    “addProject”: null
  },
  “errors”: [
    {
      “locations”: [
        {
          “line”: 2,
          “column”: 9
        }
      ],
      “path”: [
        “addProject”
      ],
      “code”: 3015,
      “message”: “Authentication token is invalid: Token can’t be decoded: Expected token [null] to be composed of 2 or 3 parts separated by dots.“,
      “requestId”: “local:management:cjiad3m13000j0745tel754h4"
    }
  ],
  “status”: 200
Any ideas?!
Oh I had to delete the service and the cluster, then try again. For some reason it comes up as “default/default” - can’t see docs on how to rename it.
But otherwise - looks like I’m in business!
Ah - you’re right. It’s over memory for the standard instance size for heroku. Immediately getting Memory quota exceeded
😓 1
I’ve flipped onto 2x dynos and it seems to all be okay now.
m
I was getting that on the hobby dyno with 500mb, 2x I think should be fine
s
Copy code
Exception in thread "main" org.postgresql.util.PSQLException: ERROR: permission denied for database db_ltr_stg
Even i am getting the permission denied error i am using the latest prisma release 1.10
m
@sweekar Is
db_ltr_stg
your actual database name?
I was getting
FATAL: permission denied for database "postgres"
, but there was no reference to a
postgres
named database in my config