mirror of
https://github.com/hasura/graphql-engine.git
synced 2024-12-15 09:22:43 +03:00
add digital ocean one-click docs (#813)
This commit is contained in:
parent
748b6c91c9
commit
71f2af9fb8
@ -5,7 +5,7 @@ In this section, we're going to set up a simple access control rule for restrict
|
||||
We're working with a simple ``author`` table where users have some information stored about themselves.
|
||||
|
||||
Create an author table
|
||||
---------------------
|
||||
----------------------
|
||||
|
||||
Head to your console and create an ``author`` table with the following columns:
|
||||
|
||||
|
@ -0,0 +1,298 @@
|
||||
Hasura GraphQL Engine DigitalOcean One-click App
|
||||
================================================
|
||||
|
||||
Hasura GraphQL Engine is available as a One-click app on DigitalOcean. It is
|
||||
packed with a Postgres database and `Caddy <https://caddyserver.com/>`__
|
||||
webserver for easy and automatic HTTPS using Let's Encrypt.
|
||||
|
||||
|
||||
Quickstart
|
||||
----------
|
||||
|
||||
1. Create Hasura One-click Droplet
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Create a new droplet and choose Hasura GraphQL Engine under One-click apps while
|
||||
choosing the image.
|
||||
|
||||
2. Open console
|
||||
~~~~~~~~~~~~~~~
|
||||
|
||||
Once Hasura GraphQL Engine One-Click Droplet is ready, you can visit the Droplet
|
||||
IP to open 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.
|
||||
|
||||
The Hasura console will be at:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
http://your_droplet_ip/console
|
||||
|
||||
|
||||
The GraphQL Endpoint will be:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
http://your_droplet_ip/v1alpha1/graphql
|
||||
|
||||
|
||||
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.
|
||||
|
||||
.. image:: https://graphql-engine-cdn.hasura.io/heroku-repo/assets/hasura_console.png
|
||||
:alt: Hasura console
|
||||
|
||||
3. Create a table
|
||||
~~~~~~~~~~~~~~~~~
|
||||
|
||||
Navigate to ``Data -> Create table`` on the console and create a table called ``profile`` with the following columns:
|
||||
|
||||
``profile``
|
||||
|
||||
=============== ========
|
||||
column name type
|
||||
=============== ========
|
||||
``id`` Integer (auto-increment)
|
||||
``name`` Text
|
||||
=============== ========
|
||||
|
||||
Choose ``id`` as the Primary key and click the ``Create`` button.
|
||||
|
||||
.. image:: https://graphql-engine-cdn.hasura.io/heroku-repo/assets/hasura_create_table.png
|
||||
:alt: Hasura console - create table
|
||||
|
||||
4. Insert sample data
|
||||
~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
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
|
||||
|
||||
.. image:: https://graphql-engine-cdn.hasura.io/heroku-repo/assets/hasura_insert_row.png
|
||||
:alt: Hasura console - insert data
|
||||
|
||||
5. Try out GraphQL
|
||||
~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Switch to the ``GraphiQL`` tab on top and execute the following GraphQL query:
|
||||
|
||||
.. code-block:: graphql
|
||||
|
||||
query {
|
||||
profile {
|
||||
id
|
||||
name
|
||||
}
|
||||
}
|
||||
|
||||
.. image:: https://graphql-engine-cdn.hasura.io/heroku-repo/assets/hasura_graphql_query.png
|
||||
:alt: Hasura console - GraphiQL
|
||||
|
||||
Secure the GraphQL endpoint
|
||||
---------------------------
|
||||
|
||||
By default Hasura is exposed without any access key. Anyone can read and write
|
||||
to your database using GraphQL. When deploying to production, you should secure
|
||||
the endpoint by adding an access key and then setting up permission rules on
|
||||
tables.
|
||||
|
||||
To add an access key, follow the steps given below:
|
||||
|
||||
1. Connect to the Droplet via SSH:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
ssh root@your_droplet_ip
|
||||
|
||||
|
||||
2. Goto ``/etc/hasura`` directory:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
cd /etc/hasura
|
||||
|
||||
|
||||
3. Edit ``docker-compose.yaml`` and un-comment the line that mentions access key.
|
||||
Also change it to some unique secret:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
vim docker-compose.yaml
|
||||
|
||||
...
|
||||
# un-comment next line to add an access key
|
||||
HASURA_GRAPHQL_ACCESS_KEY: mysecretaccesskey
|
||||
...
|
||||
|
||||
# type ESC followed by :wq to save and quit
|
||||
|
||||
|
||||
4. Update the container:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
docker-compose up -d
|
||||
|
||||
|
||||
That's it. Visit the console at ``http://your_droplet_ip/console`` and it should
|
||||
prompt for the access key. Further API requests can be made by adding the
|
||||
following header:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
X-Hasura-Access-Key: mysecretaccesskey
|
||||
|
||||
|
||||
Adding a domain & Enabling HTTPS
|
||||
--------------------------------
|
||||
|
||||
If you own a domain, you can enable HTTPS on this Droplet by mapping the domain
|
||||
to the Droplet IP. The One-Click Droplet is configured with Caddy which is an
|
||||
HTTP/2 web server with automatic HTTPS using Let's Encrypt.
|
||||
|
||||
1. Go to your domain's DNS dashboard and add an A record mapping the domain to the Droplet IP.
|
||||
2. Connect to the Droplet via SSH:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
ssh root@your_droplet_ip
|
||||
|
||||
|
||||
3. Goto ``/etc/hasura`` directory:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
cd /etc/hasura
|
||||
|
||||
|
||||
4. Edit ``Caddyfile`` and change ``:80`` to your domain:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
vim Caddyfile
|
||||
|
||||
...
|
||||
add_your-domain-here {
|
||||
proxy / graphql-engine:8080 {
|
||||
websocket
|
||||
}
|
||||
}
|
||||
...
|
||||
|
||||
# type ESC followed by :wq to save and quit
|
||||
|
||||
|
||||
5. Restart the container:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
docker-compose restart caddy
|
||||
|
||||
|
||||
Visit ``https://your_domain/console`` to visit the Hasura console.
|
||||
|
||||
Updating to latest version
|
||||
--------------------------
|
||||
|
||||
When a new version of GraphQL Engine is released, you can upgrade to it by just
|
||||
changing the version tag in docker-compose.yaml. You can find the latest
|
||||
releases in the GitHub releases page.
|
||||
|
||||
1. Connect to the Droplet via SSH:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
ssh root@your_droplet_ip
|
||||
|
||||
|
||||
2. Goto ``/etc/hasura`` directory:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
cd /etc/hasura
|
||||
|
||||
|
||||
3. Edit ``docker-compose.yaml`` and change the image tag to the latest one:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
vim docker-compose.yaml
|
||||
|
||||
...
|
||||
graphql-engine:
|
||||
image: hasura/graphql-engine:latest_tag_here
|
||||
...
|
||||
|
||||
# type ESC followed by :wq to save and quit
|
||||
|
||||
|
||||
4. Restart the container:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
docker-compose up -d
|
||||
|
||||
|
||||
Using a different database
|
||||
--------------------------
|
||||
|
||||
1. Connect to the Droplet via SSH:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
ssh root@your_droplet_ip
|
||||
|
||||
|
||||
2. Goto ``/etc/hasura`` directory:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
cd /etc/hasura
|
||||
|
||||
3. Setup the database that you wish to use, preferably via Docker Compose
|
||||
|
||||
4. Edit ``docker-compose.yaml`` and change the database URL:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
vim docker-compose.yaml
|
||||
|
||||
...
|
||||
# change the url to use a different database
|
||||
HASURA_GRAPHQL_DATABASE_URL: postgres://<new-database-url>/<new-database-name>
|
||||
...
|
||||
|
||||
# type ESC followed by :wq to save and quit
|
||||
|
||||
|
||||
Logs
|
||||
----
|
||||
|
||||
|
||||
1. Connect to the Droplet via SSH:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
ssh root@your_droplet_ip
|
||||
|
||||
|
||||
2. Goto ``/etc/hasura`` directory:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
cd /etc/hasura
|
||||
|
||||
3. To checks logs for any contaier, use the follwing command:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
docker-compose logs <container_name>
|
||||
|
||||
Where ``<container_name>`` is one of ``graphql-engine``, ``postgres`` or
|
||||
``caddy``.
|
@ -2,6 +2,7 @@ Guides: Deployment
|
||||
==================
|
||||
|
||||
- :doc:`Deploy on Digital Ocean using Docker <digital-ocean>`
|
||||
- :doc:`Digital Ocean One-click App <digital-ocean-one-click>`
|
||||
|
||||
.. note::
|
||||
The above are guides to deploy Hasura GraphQL engine on some specific platforms.
|
||||
@ -14,3 +15,4 @@ Guides: Deployment
|
||||
:hidden:
|
||||
|
||||
On Digital Ocean using Docker <digital-ocean>
|
||||
DigitalOcean One-click App <digital-ocean-one-click>
|
||||
|
@ -5,6 +5,7 @@ Deployment guides
|
||||
-----------------
|
||||
|
||||
- :doc:`Deploy on Digital Ocean using Docker <deployment/digital-ocean>`
|
||||
- :doc:`Digital Ocean One-click App <deployment/digital-ocean-one-click>`
|
||||
|
||||
.. note::
|
||||
The above are guides to deploy Hasura GraphQL engine on some specific platforms.
|
||||
@ -16,22 +17,22 @@ Sample apps
|
||||
|
||||
Articles:
|
||||
^^^^^^^^^
|
||||
- `Build a realtime chat app with GraphQL Subscriptions <https://blog.hasura.io/building-a-realtime-chat-app-with-graphql-subscriptions-d68cd33e73f>`_.
|
||||
- `Build a React To Do Application <https://hackernoon.com/building-a-react-todo-app-with-hasura-graphql-engine-511b703a7ef>`_.
|
||||
- `Build a realtime chat app with GraphQL Subscriptions <https://blog.hasura.io/building-a-realtime-chat-app-with-graphql-subscriptions-d68cd33e73f>`__.
|
||||
- `Build a React To Do Application <https://hackernoon.com/building-a-react-todo-app-with-hasura-graphql-engine-511b703a7ef>`__.
|
||||
|
||||
Videos:
|
||||
^^^^^^^
|
||||
- `Build a realtime chat app with GraphQL Subscriptions <https://www.youtube.com/watch?v=xNcxdGaUGqI>`_.
|
||||
- `Build a realtime chat app with GraphQL Subscriptions <https://www.youtube.com/watch?v=xNcxdGaUGqI>`__.
|
||||
|
||||
Integration/migration tutorials
|
||||
-------------------------------
|
||||
|
||||
Articles:
|
||||
^^^^^^^^^
|
||||
- `Move from firebase to realtime GraphQL on Postgres <https://blog.hasura.io/firebase2graphql-moving-from-firebase-to-realtime-graphql-on-postgres-4d36cb7f4eaf>`_.
|
||||
- `Create a Gatsby site using GraphQL on Postgres <https://blog.hasura.io/create-gatsby-sites-using-graphql-on-postgres-603b5dd1e516>`_.
|
||||
- `Instant GraphQL on AWS RDS <https://blog.hasura.io/instant-graphql-on-aws-rds-1edfb85b5985>`_.
|
||||
- `Using TimescaleDB with Hasura GraphQL <https://blog.hasura.io/using-timescaledb-with-hasura-graphql-d05f030c4b10>`_.
|
||||
- `Move from firebase to realtime GraphQL on Postgres <https://blog.hasura.io/firebase2graphql-moving-from-firebase-to-realtime-graphql-on-postgres-4d36cb7f4eaf>`__.
|
||||
- `Create a Gatsby site using GraphQL on Postgres <https://blog.hasura.io/create-gatsby-sites-using-graphql-on-postgres-603b5dd1e516>`__.
|
||||
- `Instant GraphQL on AWS RDS <https://blog.hasura.io/instant-graphql-on-aws-rds-1edfb85b5985>`__.
|
||||
- `Using TimescaleDB with Hasura GraphQL <https://blog.hasura.io/using-timescaledb-with-hasura-graphql-d05f030c4b10>`__.
|
||||
|
||||
Integrating with monitoring frameworks
|
||||
--------------------------------------
|
||||
@ -41,8 +42,8 @@ monitoring frameworks:
|
||||
|
||||
Articles:
|
||||
^^^^^^^^^
|
||||
- `GraphQL Observability with Hasura GraphQL Engine and Honeycomb <https://blog.hasura.io/graphql-observability-with-hasura-graphql-engine-and-honeycomb-ee0a1a836c41>`_
|
||||
- `Uptime Monitoring for Hasura GraphQL Engine with DataDog on GKE <https://blog.hasura.io/uptime-monitoring-for-hasura-graphql-engine-with-datadog-on-gke-4faff5832e7f>`_
|
||||
- `GraphQL Observability with Hasura GraphQL Engine and Honeycomb <https://blog.hasura.io/graphql-observability-with-hasura-graphql-engine-and-honeycomb-ee0a1a836c41>`__
|
||||
- `Uptime Monitoring for Hasura GraphQL Engine with DataDog on GKE <https://blog.hasura.io/uptime-monitoring-for-hasura-graphql-engine-with-datadog-on-gke-4faff5832e7f>`__
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 1
|
||||
|
@ -3,9 +3,9 @@ Guides: Sample apps
|
||||
|
||||
Articles:
|
||||
^^^^^^^^^
|
||||
- `Build a realtime chat app with GraphQL Subscriptions <https://blog.hasura.io/building-a-realtime-chat-app-with-graphql-subscriptions-d68cd33e73f>`_.
|
||||
- `Build a React To Do Application <https://hackernoon.com/building-a-react-todo-app-with-hasura-graphql-engine-511b703a7ef>`_.
|
||||
- `Build a realtime chat app with GraphQL Subscriptions <https://blog.hasura.io/building-a-realtime-chat-app-with-graphql-subscriptions-d68cd33e73f>`__.
|
||||
- `Build a React To Do Application <https://hackernoon.com/building-a-react-todo-app-with-hasura-graphql-engine-511b703a7ef>`__.
|
||||
|
||||
Videos:
|
||||
^^^^^^^
|
||||
- `Build a realtime chat app with GraphQL Subscriptions <https://www.youtube.com/watch?v=xNcxdGaUGqI>`_.
|
||||
- `Build a realtime chat app with GraphQL Subscriptions <https://www.youtube.com/watch?v=xNcxdGaUGqI>`__.
|
||||
|
Loading…
Reference in New Issue
Block a user