Closed BatuhanW closed 4 years ago
@BatuhanW Definitely should be possible as per: http://dokku.viewdocs.io/dokku~v0.13.4/deployment/methods/dockerfiles/
If you get something working and can put up a set of instructions here we'd love to merge it add it to our docs!
This is what I get when I try to run it in Dokku:
Counting objects: 225, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (112/112), done.
Writing objects: 100% (225/225), 530.12 KiB | 22.09 MiB/s, done.
Total 225 (delta 111), reused 225 (delta 111)
-----> Cleaning up...
-----> Building hasura from dockerfile...
-----> Setting config vars
DOKKU_DOCKERFILE_CMD: CMD graphql-engine \
remote: build context to Docker daemon 585.7kB
Step 1/3 : FROM hasura/graphql-engine:v1.0.0-alpha39
---> 19acce70289d
Step 2/3 : ENV HASURA_GRAPHQL_ENABLE_CONSOLE true
---> Running in f2e99a424597
---> 2d33211ad3c1
Removing intermediate container f2e99a424597
Step 3/3 : CMD graphql-engine --database-url $DATABASE_URL serve --server-port $PORT
---> Running in 662f1360bfde
---> 8fc56b2abfa6
Removing intermediate container 662f1360bfde
Successfully built 8fc56b2abfa6
Successfully tagged dokku/hasura:latest
-----> Releasing hasura (dokku/hasura:latest)...
-----> Deploying hasura (dokku/hasura:latest)...
-----> Attempting to run scripts.dokku.predeploy from app.json (if defined)
-----> No Procfile found in app image
-----> DOKKU_SCALE file not found in app image. Generating one based on Procfile...
-----> New DOKKU_SCALE file generated
=====> web=1
-----> Attempting pre-flight checks
For more efficient zero downtime deployments, create a file CHECKS.
See http://dokku.viewdocs.io/dokku/deployment/zero-downtime-deploys/ for examples
CHECKS file not found in container: Running simple container check...
-----> Waiting for 10 seconds ...
-----> Default container check successful!
-----> Running post-deploy
=====> renaming container (d27b7deb8d79) dreamy_spence to hasura.web.1
-----> Configuring hasura.myapidomain.com...(using built-in template)
-----> Creating http nginx.conf
-----> Running nginx-pre-reload
remote: /tmp/bashenv.164516393: line 135: syntax error near unexpected token `('
remote: /tmp/bashenv.164516393: line 135: ` eval "$1() { '
remote: /home/dokku/.basher/bash: main: command not found
To myapidomain:hasura
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'dokku@myapidomain:hasura'
Although I just got it working following this: https://github.com/dokku/dokku/blob/master/docs/deployment/methods/images.md#deploying-from-a-docker-registry
@m0ngr31 That's neat :) We'll add it to our docs. Do the ports get mapped automatically heroku style?
So far it seems like the steps are:
DATABASE_URL
and optionally: HASURA_GRAPHQL_ADMIN_SECRET
and so on.This is essentially what I did:
dokku apps:create hasura
dokku domains:add hasura "hasura.myapidomain.com"
dokku postgres:create hasura-db
dokku postgres:link hasura-db hasura
dokku config:set hasura HASURA_GRAPHQL_DATABASE_URL="<info from above command>" HASURA_GRAPHQL_ADMIN_SECRET="blahblah" HASURA_GRAPHQL_ENABLE_CONSOLE="true" DOKKU_PROXY_PORT_MAP="http:80:8080"
docker pull hasura/graphql-engine
docker tag hasura/graphql-engine dokku/hasura
dokku tags:deploy hasura
The only caveat so far is that the Dokku Postgres plugin will output something like this:
Waiting for container to be ready
Creating container database
Securing connection to database
=====> Postgres container created: hasura-db
=====> Container Information
Config dir: /var/lib/dokku/services/postgres/hasura-db/config
Data dir: /var/lib/dokku/services/postgres/hasura-db/data
Dsn: postgres://postgres:randomlygeneratedpassword@dokku-postgres-hasura-db:5432/hasura_db
Exposed ports: -
Id: 95c7e0db4246a3472e71363822ca2e0491c8316e0fc675685a53ff6b3574896c
Internal ip: 172.17.0.5
Links: -
Service root: /var/lib/dokku/services/postgres/hasura-db
Status: running
Version: postgres:9.6.4
And Hasura will not be able to connect to the Dsn. It doesn't like the hostname, so I just had to add in the internal IP instead. I'm not sure it'll keep the same IP if I reboot the server or not, but it's working so far.
How did this all work out in the end? Dokku and Hasura would be a match made in heaven!!
It "works", but I can't get websockets working with Dokku, so I can't do subscriptions.
Thanks Monger! I ended up pivoting to CapRover and very chuffed must say, though it's possible they too will have websocket limitations.
I ended up following what @m0ngr31 said, though the DSN worked for me just fine.
@LeviSchuck and the subscription also works?
Subscriptions not working (with a AppoloGraphql client ) nor Dokku nor Caprover :/ (except on Chrome with CapRover, not working with Firefox). Seems like a Nginx reverse proxy with Websockt issue. I'ts a real struggle
Thank you very much for your config @m0ngr31
Here is the process that worked for me to deploy hasura on dokku with custom domain and https!
dokku apps:create hasura
dokku domains:add hasura hasura.my.domain.com
dokku postgres:create hasura-db
dokku postgres:link hasura-db hasura
dokku config:set hasura HASURA_GRAPHQL_DATABASE_URL="<info from above command>" HASURA_GRAPHQL_ADMIN_SECRET="blahblah" HASURA_GRAPHQL_ENABLE_CONSOLE="true"
dokku proxy:ports-set hasura http:80:8080
docker pull hasura/graphql-engine
docker tag hasura/graphql-engine dokku/hasura
dokku tags:deploy hasura
dokku letsencrypt hasura
For some reason, I had to run the letsencrypt
instruction as the last one.
Thanks to @josegonzalez for the very helpful support
Subscription in graphiql works 🎉
@clementvp It is working in chrome and firefox for me
In the console it's work good. But with a Graphql client (Apollo Graphql with wsLink in a Create React App, in my case), Chrome can connect to Hasura for subscriptions (websockets), but not Firefox. @abumalick Have you tried subscriptions with a client like Appolo GraphQl or just a playground Graphql like this?
Got Hasura running with dokku as well.
Just a note on @abumalick's steps, if you're using a Dockerfile
, dokku defaults its apps to port 5000, so you'll want:
dokku proxy:ports-set hasura http:80:5000
@clementvp Not seeing issues between Chrome and Firefox with subscriptions and Apollo.
Well, the hasura docker container does not accept requests from 5000 because it does not support the Port env variable. It accepts requests from 8080
@abumalick Ah, my mistake. I'm using a Dockerfile
with hasura/graphql-engine:v1.2.0-beta.3.cli-migrations
.
The dokku commands above can be greatly simplified with the newest version of dokku (0.24.x). Instead of using docker tags, you can simply docker pull hasura/graphql-engine && dokku git:from-image hasura/graphql-engine
(after creating the app, associating with the DB, etc). It's much easier!
https://dokku.com/docs/deployment/methods/git/#initializing-an-app-repository-from-a-docker-image
@xrd Thanks for pointing out that we can use the new 0.24 feature for exactly this use case!
Just a minor correction there - dokku git:from-image <appname> hasura/graphql-engine
It would be interesting to know if it's possible to deploy hasura gql engine to my dokku server.