2020-01-14 15:57:45 +03:00
|
|
|
|
.. meta::
|
|
|
|
|
:description: Deploy Hasura GraphQL engine One-click App on DigitalOcean Marketplace
|
|
|
|
|
:keywords: hasura, docs, guide, deployment, digital ocean, marketplace
|
|
|
|
|
|
2020-03-11 22:42:36 +03:00
|
|
|
|
.. _deploy_do_marketplace:
|
|
|
|
|
|
2019-09-11 10:17:14 +03:00
|
|
|
|
Hasura GraphQL engine One-click App on DigitalOcean Marketplace
|
2019-03-07 10:10:16 +03:00
|
|
|
|
===============================================================
|
2018-10-20 18:41:08 +03:00
|
|
|
|
|
2018-12-03 15:12:24 +03:00
|
|
|
|
.. contents:: Table of contents
|
|
|
|
|
:backlinks: none
|
|
|
|
|
:depth: 1
|
|
|
|
|
:local:
|
|
|
|
|
|
2020-07-23 15:34:17 +03:00
|
|
|
|
Introduction
|
|
|
|
|
------------
|
|
|
|
|
|
2019-09-11 10:17:14 +03:00
|
|
|
|
The Hasura GraphQL engine is available as a One-click app on the DigitalOcean
|
2019-03-07 10:10:16 +03:00
|
|
|
|
Marketplace. It is packed with a `Postgres <https://www.postgresql.org/>`__
|
|
|
|
|
database and `Caddy <https://caddyserver.com/>`__ webserver for easy and
|
|
|
|
|
automatic HTTPS using `Let's Encrypt <https://letsencrypt.org/>`__.
|
2018-10-20 18:41:08 +03:00
|
|
|
|
|
2020-07-23 15:34:17 +03:00
|
|
|
|
Deploying Hasura on Digital Ocean
|
|
|
|
|
---------------------------------
|
2018-10-20 18:41:08 +03:00
|
|
|
|
|
2020-07-23 15:34:17 +03:00
|
|
|
|
Step 1: Create a Hasura One-click Droplet
|
|
|
|
|
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
2018-10-20 18:41:08 +03:00
|
|
|
|
|
2019-09-11 10:17:14 +03:00
|
|
|
|
Click the button below to create a new Hasura GraphQL engine Droplet through
|
|
|
|
|
the DigitalOcean Marketplace. For first time users, the link also contains a
|
2019-03-07 10:10:16 +03:00
|
|
|
|
referral code with gives you $100 over days. A $5 droplet is good enough to
|
|
|
|
|
support most workloads. (``Ctrl+Click`` to open in a new tab)
|
2018-11-30 19:20:56 +03:00
|
|
|
|
|
|
|
|
|
.. image:: https://graphql-engine-cdn.hasura.io/img/create_hasura_droplet.png
|
|
|
|
|
:width: 300px
|
|
|
|
|
:alt: do_create_droplet_button
|
|
|
|
|
:class: no-shadow
|
2019-03-07 10:10:16 +03:00
|
|
|
|
:target: https://marketplace.digitalocean.com/apps/hasura?action=deploy&refcode=c4d9092d2c48&utm_source=hasura&utm_campaign=docs
|
2018-10-20 18:41:08 +03:00
|
|
|
|
|
2020-07-23 15:34:17 +03:00
|
|
|
|
Step 2: Open console
|
|
|
|
|
^^^^^^^^^^^^^^^^^^^^
|
2018-10-20 18:41:08 +03:00
|
|
|
|
|
2019-09-11 10:17:14 +03:00
|
|
|
|
Once the Hasura GraphQL engine Droplet is ready, you can visit the Droplet IP to
|
2019-03-07 10:10:16 +03:00
|
|
|
|
open the Hasura console, where you can create tables, explore GraphQL APIs etc.
|
|
|
|
|
Note that it might take 1 or 2 minutes for everything to start running.
|
2018-10-20 18:41:08 +03:00
|
|
|
|
|
2021-02-17 15:40:37 +03:00
|
|
|
|
The ``Droplet IP`` is highlighted in the image below:
|
|
|
|
|
|
|
|
|
|
.. thumbnail:: /img/graphql/core/deployment/dashboard-digital-ocean.png
|
|
|
|
|
:alt: Dashboard for digital ocean droplet
|
|
|
|
|
|
2018-10-20 18:41:08 +03:00
|
|
|
|
The Hasura console will be at:
|
|
|
|
|
|
|
|
|
|
.. code-block:: bash
|
|
|
|
|
|
2019-03-07 10:10:16 +03:00
|
|
|
|
http://<your_droplet_ip>/console
|
2018-10-20 18:41:08 +03:00
|
|
|
|
|
2019-09-11 10:17:14 +03:00
|
|
|
|
The GraphQL endpoint will be:
|
2018-10-20 18:41:08 +03:00
|
|
|
|
|
|
|
|
|
.. code-block:: bash
|
|
|
|
|
|
2019-05-10 09:05:11 +03:00
|
|
|
|
http://<your_droplet_ip>/v1/graphql
|
2018-10-20 18:41:08 +03:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
A Postgres database is also provisioned on the Droplet. Using the console, you
|
|
|
|
|
can create a table on this Postgres instance and make your first GraphQL query.
|
|
|
|
|
|
2021-02-17 15:40:37 +03:00
|
|
|
|
.. thumbnail:: /img/graphql/core/deployment/digital-ocean-hasura-console.png
|
2018-10-20 18:41:08 +03:00
|
|
|
|
:alt: Hasura console
|
|
|
|
|
|
2020-07-23 15:34:17 +03:00
|
|
|
|
Step 3: Create a table
|
|
|
|
|
^^^^^^^^^^^^^^^^^^^^^^
|
2018-10-20 18:41:08 +03:00
|
|
|
|
|
2021-02-17 15:40:37 +03:00
|
|
|
|
Navigate to ``Data -> Add table`` on the console and create a table called ``profile`` with the following columns:
|
2018-10-20 18:41:08 +03:00
|
|
|
|
|
|
|
|
|
``profile``
|
|
|
|
|
|
|
|
|
|
=============== ========
|
|
|
|
|
column name type
|
|
|
|
|
=============== ========
|
|
|
|
|
``id`` Integer (auto-increment)
|
|
|
|
|
``name`` Text
|
|
|
|
|
=============== ========
|
|
|
|
|
|
2021-02-17 15:40:37 +03:00
|
|
|
|
Choose ``id`` as the Primary key and click the ``Add Table`` button.
|
2018-10-20 18:41:08 +03:00
|
|
|
|
|
2021-02-17 15:40:37 +03:00
|
|
|
|
.. thumbnail:: /img/graphql/core/deployment/digital-ocean-create-table.png
|
|
|
|
|
:alt: Create a table
|
2018-10-20 18:41:08 +03:00
|
|
|
|
|
2020-07-23 15:34:17 +03:00
|
|
|
|
Step 4: Insert sample data
|
|
|
|
|
^^^^^^^^^^^^^^^^^^^^^^^^^^
|
2018-10-20 18:41:08 +03:00
|
|
|
|
|
|
|
|
|
Once the table is created, go to the ``Insert Row`` tab and insert some sample rows:
|
|
|
|
|
|
|
|
|
|
.. code-block:: bash
|
|
|
|
|
|
|
|
|
|
Thor
|
|
|
|
|
Iron Man
|
|
|
|
|
Hulk
|
|
|
|
|
Captain America
|
|
|
|
|
Black Widow
|
|
|
|
|
|
2021-02-17 15:40:37 +03:00
|
|
|
|
.. thumbnail:: /img/graphql/core/deployment/digital-ocean-hasura-insert-data.png
|
2018-10-20 18:41:08 +03:00
|
|
|
|
:alt: Hasura console - insert data
|
|
|
|
|
|
2020-07-23 15:34:17 +03:00
|
|
|
|
Step 5: Try out GraphQL
|
|
|
|
|
^^^^^^^^^^^^^^^^^^^^^^^
|
2018-10-20 18:41:08 +03:00
|
|
|
|
|
|
|
|
|
Switch to the ``GraphiQL`` tab on top and execute the following GraphQL query:
|
|
|
|
|
|
|
|
|
|
.. code-block:: graphql
|
|
|
|
|
|
|
|
|
|
query {
|
|
|
|
|
profile {
|
|
|
|
|
id
|
|
|
|
|
name
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-02-17 15:40:37 +03:00
|
|
|
|
.. thumbnail:: /img/graphql/core/deployment/hasura-graphql-query.png
|
2018-10-20 18:41:08 +03:00
|
|
|
|
:alt: Hasura console - GraphiQL
|
|
|
|
|
|
2020-10-01 16:12:14 +03:00
|
|
|
|
|
2020-07-23 15:34:17 +03:00
|
|
|
|
.. _digital_ocean_secure:
|
|
|
|
|
|
|
|
|
|
Securing the GraphQL endpoint
|
|
|
|
|
-----------------------------
|
2018-10-20 18:41:08 +03:00
|
|
|
|
|
2019-03-07 10:10:16 +03:00
|
|
|
|
By default Hasura is exposed without any admin secret. Anyone can read and write
|
2018-10-20 18:41:08 +03:00
|
|
|
|
to your database using GraphQL. When deploying to production, you should secure
|
2019-02-14 12:37:47 +03:00
|
|
|
|
the endpoint by adding an admin secret key and then setting up permission rules on
|
2018-10-20 18:41:08 +03:00
|
|
|
|
tables.
|
|
|
|
|
|
2019-09-11 10:17:14 +03:00
|
|
|
|
To add an admin secret key, follow the steps described below:
|
2018-10-20 18:41:08 +03:00
|
|
|
|
|
2020-07-23 15:34:17 +03:00
|
|
|
|
Step 1: Connect to the Droplet via SSH
|
|
|
|
|
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
2018-10-20 18:41:08 +03:00
|
|
|
|
|
2020-07-23 15:34:17 +03:00
|
|
|
|
.. code-block:: bash
|
2018-10-20 18:41:08 +03:00
|
|
|
|
|
2020-07-23 15:34:17 +03:00
|
|
|
|
ssh root@<your_droplet_ip>
|
2018-10-20 18:41:08 +03:00
|
|
|
|
|
|
|
|
|
|
2020-07-23 15:34:17 +03:00
|
|
|
|
Step 2: Go to the ``/etc/hasura`` directory
|
|
|
|
|
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
2018-10-20 18:41:08 +03:00
|
|
|
|
|
2020-07-23 15:34:17 +03:00
|
|
|
|
.. code-block:: bash
|
2018-10-20 18:41:08 +03:00
|
|
|
|
|
2020-07-23 15:34:17 +03:00
|
|
|
|
cd /etc/hasura
|
2018-10-20 18:41:08 +03:00
|
|
|
|
|
|
|
|
|
|
2020-07-23 15:34:17 +03:00
|
|
|
|
Step 3: Set an admin secret
|
|
|
|
|
^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
2018-10-20 18:41:08 +03:00
|
|
|
|
|
2020-07-23 15:34:17 +03:00
|
|
|
|
Edit ``docker-compose.yaml`` and un-comment the line that mentions admin secret key.
|
|
|
|
|
Also change it to some unique secret:
|
2018-10-20 18:41:08 +03:00
|
|
|
|
|
2020-07-23 15:34:17 +03:00
|
|
|
|
.. code-block:: bash
|
2018-10-20 18:41:08 +03:00
|
|
|
|
|
2020-07-23 15:34:17 +03:00
|
|
|
|
vim docker-compose.yaml
|
2018-10-20 18:41:08 +03:00
|
|
|
|
|
2020-07-23 15:34:17 +03:00
|
|
|
|
...
|
|
|
|
|
# un-comment next line to add an admin secret key
|
2021-01-11 22:20:38 +03:00
|
|
|
|
HASURA_GRAPHQL_ADMIN_SECRET: <myadminsecretkey>
|
2020-07-23 15:34:17 +03:00
|
|
|
|
...
|
2018-10-20 18:41:08 +03:00
|
|
|
|
|
2020-07-23 15:34:17 +03:00
|
|
|
|
# type ESC followed by :wq to save and quit
|
2018-10-20 18:41:08 +03:00
|
|
|
|
|
|
|
|
|
|
2020-07-23 15:34:17 +03:00
|
|
|
|
Step 4: Update the container
|
|
|
|
|
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
2018-10-20 18:41:08 +03:00
|
|
|
|
|
2020-07-23 15:34:17 +03:00
|
|
|
|
.. code-block:: bash
|
2018-10-20 18:41:08 +03:00
|
|
|
|
|
2020-07-23 15:34:17 +03:00
|
|
|
|
docker-compose up -d
|
2018-10-20 18:41:08 +03:00
|
|
|
|
|
2019-03-07 10:10:16 +03:00
|
|
|
|
That's it. Visit the console at ``http://<your_droplet_ip>/console`` and it should
|
2019-02-14 12:37:47 +03:00
|
|
|
|
prompt for the admin secret key. Further API requests can be made by adding the
|
2018-10-20 18:41:08 +03:00
|
|
|
|
following header:
|
|
|
|
|
|
|
|
|
|
.. code-block:: bash
|
|
|
|
|
|
2021-01-11 22:20:38 +03:00
|
|
|
|
X-Hasura-Admin-Secret: <myadminsecretkey>
|
2018-10-20 18:41:08 +03:00
|
|
|
|
|
|
|
|
|
|
2019-09-11 10:17:14 +03:00
|
|
|
|
Adding a domain & enabling HTTPS
|
2018-10-20 18:41:08 +03:00
|
|
|
|
--------------------------------
|
|
|
|
|
|
|
|
|
|
If you own a domain, you can enable HTTPS on this Droplet by mapping the domain
|
2019-03-07 10:10:16 +03:00
|
|
|
|
to the Droplet's IP. The Hasura GraphQL Droplet is configured with Caddy which is an
|
2018-10-20 18:41:08 +03:00
|
|
|
|
HTTP/2 web server with automatic HTTPS using Let's Encrypt.
|
|
|
|
|
|
2020-07-23 15:34:17 +03:00
|
|
|
|
Step 1: Add a record mapping
|
|
|
|
|
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
2018-10-20 18:41:08 +03:00
|
|
|
|
|
2020-07-23 15:34:17 +03:00
|
|
|
|
Go to your domain's DNS dashboard and add an A record mapping the domain to the Droplet IP.
|
2018-10-20 18:41:08 +03:00
|
|
|
|
|
2020-07-23 15:34:17 +03:00
|
|
|
|
Step 2: Connect to the Droplet via SSH
|
|
|
|
|
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
2018-10-20 18:41:08 +03:00
|
|
|
|
|
2020-07-23 15:34:17 +03:00
|
|
|
|
.. code-block:: bash
|
2018-10-20 18:41:08 +03:00
|
|
|
|
|
2020-07-23 15:34:17 +03:00
|
|
|
|
ssh root@<your_droplet_ip>
|
2018-10-20 18:41:08 +03:00
|
|
|
|
|
|
|
|
|
|
2020-07-23 15:34:17 +03:00
|
|
|
|
Step 3: Go to the ``/etc/hasura`` directory
|
|
|
|
|
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
2018-10-20 18:41:08 +03:00
|
|
|
|
|
2020-07-23 15:34:17 +03:00
|
|
|
|
.. code-block:: bash
|
|
|
|
|
|
|
|
|
|
cd /etc/hasura
|
2018-10-20 18:41:08 +03:00
|
|
|
|
|
|
|
|
|
|
2020-07-23 15:34:17 +03:00
|
|
|
|
Step 4: Edit the ``Caddyfile`` and change ``:80`` to your domain
|
|
|
|
|
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
|
|
|
|
|
|
|
|
.. code-block:: bash
|
2018-10-20 18:41:08 +03:00
|
|
|
|
|
2020-07-23 15:34:17 +03:00
|
|
|
|
vim Caddyfile
|
2018-10-20 18:41:08 +03:00
|
|
|
|
|
2020-07-23 15:34:17 +03:00
|
|
|
|
...
|
|
|
|
|
add_your-domain-here {
|
2022-02-01 16:48:59 +03:00
|
|
|
|
reverse_proxy / graphql-engine:8080
|
2020-07-23 15:34:17 +03:00
|
|
|
|
}
|
|
|
|
|
...
|
2018-10-20 18:41:08 +03:00
|
|
|
|
|
2020-07-23 15:34:17 +03:00
|
|
|
|
# type ESC followed by :wq to save and quit
|
2018-10-20 18:41:08 +03:00
|
|
|
|
|
|
|
|
|
|
2020-07-23 15:34:17 +03:00
|
|
|
|
Step 5: Restart the container
|
|
|
|
|
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
2018-10-20 18:41:08 +03:00
|
|
|
|
|
2020-07-23 15:34:17 +03:00
|
|
|
|
.. code-block:: bash
|
2018-10-20 18:41:08 +03:00
|
|
|
|
|
2020-07-23 15:34:17 +03:00
|
|
|
|
docker-compose restart caddy
|
2018-10-20 18:41:08 +03:00
|
|
|
|
|
|
|
|
|
|
2019-09-11 10:17:14 +03:00
|
|
|
|
Go to ``https://<your_domain>/console`` to visit the Hasura console.
|
2018-10-20 18:41:08 +03:00
|
|
|
|
|
2020-07-23 15:34:17 +03:00
|
|
|
|
.. _do_updating:
|
|
|
|
|
|
2018-12-03 15:12:24 +03:00
|
|
|
|
Updating to the latest version
|
|
|
|
|
------------------------------
|
2018-10-20 18:41:08 +03:00
|
|
|
|
|
2019-09-11 10:17:14 +03:00
|
|
|
|
When a new version of the GraphQL engine is released, you can upgrade to it by just
|
|
|
|
|
changing the version tag in ``docker-compose.yaml``. You can find the latest
|
2019-03-07 10:10:16 +03:00
|
|
|
|
releases on the `GitHub releases page
|
|
|
|
|
<https://github.com/hasura/graphql-engine/releases>`__.
|
2018-10-20 18:41:08 +03:00
|
|
|
|
|
2020-07-23 15:34:17 +03:00
|
|
|
|
Step 1: Connect to the Droplet via SSH
|
|
|
|
|
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
2018-10-20 18:41:08 +03:00
|
|
|
|
|
2020-07-23 15:34:17 +03:00
|
|
|
|
.. code-block:: bash
|
2018-10-20 18:41:08 +03:00
|
|
|
|
|
2020-07-23 15:34:17 +03:00
|
|
|
|
ssh root@<your_droplet_ip>
|
2018-10-20 18:41:08 +03:00
|
|
|
|
|
|
|
|
|
|
2020-07-23 15:34:17 +03:00
|
|
|
|
Step 2: Go to the ``/etc/hasura`` directory
|
|
|
|
|
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
2018-10-20 18:41:08 +03:00
|
|
|
|
|
2020-07-23 15:34:17 +03:00
|
|
|
|
.. code-block:: bash
|
2018-10-20 18:41:08 +03:00
|
|
|
|
|
2020-07-23 15:34:17 +03:00
|
|
|
|
cd /etc/hasura
|
2018-10-20 18:41:08 +03:00
|
|
|
|
|
|
|
|
|
|
2020-07-23 15:34:17 +03:00
|
|
|
|
Step 3: Edit ``docker-compose.yaml`` and change the image tag to the latest one
|
|
|
|
|
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
2018-10-20 18:41:08 +03:00
|
|
|
|
|
2020-07-23 15:34:17 +03:00
|
|
|
|
.. code-block:: bash
|
2018-10-20 18:41:08 +03:00
|
|
|
|
|
2020-07-23 15:34:17 +03:00
|
|
|
|
vim docker-compose.yaml
|
2018-10-20 18:41:08 +03:00
|
|
|
|
|
2020-07-23 15:34:17 +03:00
|
|
|
|
...
|
|
|
|
|
graphql-engine:
|
|
|
|
|
image: hasura/graphql-engine:latest_tag_here
|
|
|
|
|
...
|
2018-10-20 18:41:08 +03:00
|
|
|
|
|
2020-07-23 15:34:17 +03:00
|
|
|
|
# type ESC followed by :wq to save and quit
|
2018-10-20 18:41:08 +03:00
|
|
|
|
|
|
|
|
|
|
2020-07-23 15:34:17 +03:00
|
|
|
|
Step 4: Restart the container
|
|
|
|
|
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
2018-10-20 18:41:08 +03:00
|
|
|
|
|
2020-07-23 15:34:17 +03:00
|
|
|
|
.. code-block:: bash
|
2018-10-20 18:41:08 +03:00
|
|
|
|
|
2020-07-23 15:34:17 +03:00
|
|
|
|
docker-compose up -d
|
2018-10-20 18:41:08 +03:00
|
|
|
|
|
2020-10-01 16:12:14 +03:00
|
|
|
|
.. _do_managed_pg_db:
|
2018-10-20 18:41:08 +03:00
|
|
|
|
|
2019-03-07 10:10:16 +03:00
|
|
|
|
Using DigitalOcean Managed Postgres Database
|
|
|
|
|
--------------------------------------------
|
2018-10-20 18:41:08 +03:00
|
|
|
|
|
2020-07-23 15:34:17 +03:00
|
|
|
|
Step 1: Create a Postgres database
|
|
|
|
|
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
|
|
|
|
|
|
|
|
Create a new Postgres database from the DigitalOcean console, preferably in the same region as the Droplet.
|
|
|
|
|
|
|
|
|
|
Step 2: Get the database URL
|
|
|
|
|
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
|
|
|
|
|
|
|
|
Once the database is created, under the "Overview" tab, from the "Connection Details" section, choose "Connection string" from the dropdown.
|
|
|
|
|
"Connection string" is the "Database URL". Copy it.
|
2018-10-20 18:41:08 +03:00
|
|
|
|
|
2020-07-23 15:34:17 +03:00
|
|
|
|
Step 3: Connect to the Droplet via SSH
|
|
|
|
|
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
2018-10-20 18:41:08 +03:00
|
|
|
|
|
2020-07-23 15:34:17 +03:00
|
|
|
|
.. code-block:: bash
|
|
|
|
|
|
|
|
|
|
ssh root@<your_droplet_ip>
|
2018-10-20 18:41:08 +03:00
|
|
|
|
|
|
|
|
|
|
2020-07-23 15:34:17 +03:00
|
|
|
|
Step 4: Go to the ``/etc/hasura`` directory
|
|
|
|
|
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
2018-10-20 18:41:08 +03:00
|
|
|
|
|
2020-07-23 15:34:17 +03:00
|
|
|
|
.. code-block:: bash
|
2018-10-20 18:41:08 +03:00
|
|
|
|
|
2020-07-23 15:34:17 +03:00
|
|
|
|
cd /etc/hasura
|
2018-10-20 18:41:08 +03:00
|
|
|
|
|
2020-07-23 15:34:17 +03:00
|
|
|
|
Step 5: Edit ``docker-compose.yaml`` and change the database URL
|
|
|
|
|
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
2018-10-20 18:41:08 +03:00
|
|
|
|
|
2020-07-23 15:34:17 +03:00
|
|
|
|
.. code-block:: bash
|
2018-10-20 18:41:08 +03:00
|
|
|
|
|
2020-07-23 15:34:17 +03:00
|
|
|
|
vim docker-compose.yaml
|
2018-10-20 18:41:08 +03:00
|
|
|
|
|
2020-07-23 15:34:17 +03:00
|
|
|
|
...
|
|
|
|
|
# change the url to use a different database
|
|
|
|
|
HASURA_GRAPHQL_DATABASE_URL: <database-url>
|
|
|
|
|
...
|
2018-10-20 18:41:08 +03:00
|
|
|
|
|
2020-07-23 15:34:17 +03:00
|
|
|
|
# type ESC followed by :wq to save and quit
|
2018-10-20 18:41:08 +03:00
|
|
|
|
|
2019-09-11 10:17:14 +03:00
|
|
|
|
Similarly, the database URL can be changed to connect to any other Postgres
|
2019-03-07 10:10:16 +03:00
|
|
|
|
database.
|
2019-01-29 12:27:15 +03:00
|
|
|
|
|
2019-03-07 10:10:16 +03:00
|
|
|
|
.. note::
|
2019-01-29 12:27:15 +03:00
|
|
|
|
|
2019-03-07 10:10:16 +03:00
|
|
|
|
If you're using Hasura with a restricted database user, make sure you go
|
2020-03-11 22:42:36 +03:00
|
|
|
|
through :ref:`Postgres permissions <postgres_permissions>`
|
2019-09-11 10:17:14 +03:00
|
|
|
|
to configure all required permissions (not applicable with the default
|
|
|
|
|
connection string with DO Managed Postgres).
|
2018-10-20 18:41:08 +03:00
|
|
|
|
|
2019-10-04 10:00:41 +03:00
|
|
|
|
Connection pooling
|
|
|
|
|
~~~~~~~~~~~~~~~~~~
|
|
|
|
|
Connection pooling is a built-in feature of graphql-engine. The default connection pool size is 50.
|
|
|
|
|
If you need to configure the pool size or the timeout, you can use the below environment variables.
|
|
|
|
|
|
2019-12-12 23:10:04 +03:00
|
|
|
|
- ``HASURA_GRAPHQL_PG_CONNECTIONS``: Maximum number of Postgres connections that can be opened per stripe (default: 50).
|
2019-10-04 10:00:41 +03:00
|
|
|
|
- ``HASURA_GRAPHQL_PG_TIMEOUT``: Each connection’s idle time before it is closed (default: 180 sec)
|
|
|
|
|
|
|
|
|
|
.. note::
|
|
|
|
|
|
|
|
|
|
If you still want to enable connection pooling on your managed database on DigitalOcean, you should do so in the ``session`` mode.
|
|
|
|
|
|
2020-10-01 16:12:14 +03:00
|
|
|
|
.. _digital_ocean_connect_psql:
|
|
|
|
|
|
|
|
|
|
Access database via psql
|
|
|
|
|
------------------------
|
|
|
|
|
|
|
|
|
|
To access the Postgres database via ``psql``, you can use the following command
|
|
|
|
|
via the terminal:
|
|
|
|
|
|
|
|
|
|
.. code-block:: bash
|
|
|
|
|
|
|
|
|
|
docker exec -it hasura_postgres_1 psql -U postgres
|
|
|
|
|
|
|
|
|
|
If you are using a hosted database :ref:`as outlined above <do_managed_pg_db>`, it's a little different:
|
|
|
|
|
|
|
|
|
|
.. code-block:: bash
|
|
|
|
|
|
|
|
|
|
docker exec -it hasura_postgres_1 psql -h <your database url> -p <your port> -d <your database> -U <your database user>
|
|
|
|
|
|
|
|
|
|
.. note::
|
|
|
|
|
|
|
|
|
|
Different hosted Postgres providers may have different requirements for connection, e.g. setting ``sslmode``.
|
|
|
|
|
Please refer to your provider's documentation for generating the proper ``psql`` command flags.
|
|
|
|
|
|
2020-07-23 15:34:17 +03:00
|
|
|
|
.. _do_logs:
|
2019-10-04 10:00:41 +03:00
|
|
|
|
|
2018-10-20 18:41:08 +03:00
|
|
|
|
Logs
|
|
|
|
|
----
|
|
|
|
|
|
2020-07-23 15:34:17 +03:00
|
|
|
|
Step 1: Connect to the Droplet via SSH
|
|
|
|
|
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
2018-10-20 18:41:08 +03:00
|
|
|
|
|
2020-07-23 15:34:17 +03:00
|
|
|
|
.. code-block:: bash
|
2018-10-20 18:41:08 +03:00
|
|
|
|
|
2020-07-23 15:34:17 +03:00
|
|
|
|
ssh root@<your_droplet_ip>
|
2018-10-20 18:41:08 +03:00
|
|
|
|
|
|
|
|
|
|
2020-07-23 15:34:17 +03:00
|
|
|
|
Step 2: Go to the ``/etc/hasura`` directory
|
|
|
|
|
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
2018-10-20 18:41:08 +03:00
|
|
|
|
|
2020-07-23 15:34:17 +03:00
|
|
|
|
.. code-block:: bash
|
2018-10-20 18:41:08 +03:00
|
|
|
|
|
2020-07-23 15:34:17 +03:00
|
|
|
|
cd /etc/hasura
|
2018-10-20 18:41:08 +03:00
|
|
|
|
|
2020-07-23 15:34:17 +03:00
|
|
|
|
Step 3: Check logs
|
|
|
|
|
^^^^^^^^^^^^^^^^^^
|
2018-10-20 18:41:08 +03:00
|
|
|
|
|
2020-07-23 15:34:17 +03:00
|
|
|
|
To checks logs for any container, use the following command:
|
2018-10-20 18:41:08 +03:00
|
|
|
|
|
2020-07-23 15:34:17 +03:00
|
|
|
|
.. code-block:: bash
|
2018-10-20 18:41:08 +03:00
|
|
|
|
|
2020-07-23 15:34:17 +03:00
|
|
|
|
docker-compose logs <container_name>
|
2018-10-20 18:41:08 +03:00
|
|
|
|
|
|
|
|
|
Where ``<container_name>`` is one of ``graphql-engine``, ``postgres`` or
|
|
|
|
|
``caddy``.
|
2018-12-16 12:55:06 +03:00
|
|
|
|
|
2020-10-01 16:12:14 +03:00
|
|
|
|
|
2019-03-07 10:10:16 +03:00
|
|
|
|
Troubleshooting
|
|
|
|
|
---------------
|
|
|
|
|
|
|
|
|
|
Logs should be able to help you in most scenarios. If it doesn't, feel free to
|
2022-02-01 16:48:59 +03:00
|
|
|
|
talk to us on `Discord <https://discord.gg/hasura>`__.
|