2020-01-14 15:57:45 +03:00
|
|
|
.. meta::
|
|
|
|
:description: Deploy Hasura GraphQL engine with Docker
|
|
|
|
:keywords: hasura, docs, deployment, docker
|
|
|
|
|
2020-03-11 22:42:36 +03:00
|
|
|
.. _deployment_docker:
|
|
|
|
|
2019-09-11 10:17:14 +03:00
|
|
|
Run Hasura GraphQL engine using Docker
|
2018-09-11 14:11:24 +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
|
|
|
|
------------
|
|
|
|
|
2021-06-23 14:21:06 +03:00
|
|
|
This guide will help you deploy the Hasura GraphQL engine and a Postgres database to store its metadata
|
|
|
|
using Docker Compose.
|
2020-07-31 18:26:55 +03:00
|
|
|
|
2020-07-23 15:34:17 +03:00
|
|
|
Deploying Hasura using Docker
|
|
|
|
-----------------------------
|
|
|
|
|
2018-12-03 15:12:24 +03:00
|
|
|
Prerequisites
|
2020-07-23 15:34:17 +03:00
|
|
|
^^^^^^^^^^^^^
|
2018-09-11 14:11:24 +03:00
|
|
|
|
|
|
|
- `Docker <https://docs.docker.com/install/>`_
|
2021-06-23 14:21:06 +03:00
|
|
|
- `Docker Compose <https://docs.docker.com/compose/install/>`__
|
2018-09-11 14:11:24 +03:00
|
|
|
|
2021-06-23 14:21:06 +03:00
|
|
|
Step 1: Get the docker-compose file
|
|
|
|
-----------------------------------
|
2018-09-11 14:11:24 +03:00
|
|
|
|
2021-06-23 14:21:06 +03:00
|
|
|
The `hasura/graphql-engine/install-manifests <https://github.com/hasura/graphql-engine/tree/stable/install-manifests>`__ repo
|
|
|
|
contains all installation manifests required to deploy Hasura anywhere. Get the docker compose file from there:
|
2018-09-11 14:11:24 +03:00
|
|
|
|
|
|
|
.. code-block:: bash
|
2019-01-11 14:38:41 +03:00
|
|
|
|
2021-06-23 14:21:06 +03:00
|
|
|
# in a new directory run
|
|
|
|
wget https://raw.githubusercontent.com/hasura/graphql-engine/stable/install-manifests/docker-compose/docker-compose.yaml
|
|
|
|
# or run
|
|
|
|
curl https://raw.githubusercontent.com/hasura/graphql-engine/stable/install-manifests/docker-compose/docker-compose.yaml -o docker-compose.yml
|
2019-01-11 14:38:41 +03:00
|
|
|
|
2021-06-23 14:21:06 +03:00
|
|
|
Step 2: Run Hasura GraphQL engine
|
|
|
|
---------------------------------
|
2021-05-07 16:01:32 +03:00
|
|
|
|
2021-06-23 14:21:06 +03:00
|
|
|
The following command will run Hasura GraphQL engine along with a Postgres database to store its metadata.
|
2021-05-07 16:01:32 +03:00
|
|
|
|
2021-06-23 14:21:06 +03:00
|
|
|
.. code-block:: bash
|
2018-09-27 19:04:21 +03:00
|
|
|
|
2021-06-23 14:21:06 +03:00
|
|
|
$ docker-compose up -d
|
2018-09-11 14:11:24 +03:00
|
|
|
|
2021-06-23 14:21:06 +03:00
|
|
|
Check if the containers are running:
|
2018-09-11 14:11:24 +03:00
|
|
|
|
|
|
|
.. code-block:: bash
|
|
|
|
|
2021-06-23 14:21:06 +03:00
|
|
|
$ docker ps
|
2018-09-11 14:11:24 +03:00
|
|
|
|
2021-06-23 14:21:06 +03:00
|
|
|
CONTAINER ID IMAGE ... CREATED STATUS PORTS ...
|
|
|
|
097f58433a2b hasura/graphql-engine ... 1m ago Up 1m 8080->8080/tcp ...
|
|
|
|
b0b1aac0508d postgres ... 1m ago Up 1m 5432/tcp ...
|
2018-09-11 14:11:24 +03:00
|
|
|
|
2020-07-23 15:34:17 +03:00
|
|
|
.. _docker_secure:
|
|
|
|
|
|
|
|
Securing the GraphQL endpoint
|
|
|
|
-----------------------------
|
|
|
|
|
|
|
|
To make sure that your GraphQL endpoint and the Hasura console are not publicly accessible, you need to
|
|
|
|
configure an admin secret key.
|
|
|
|
|
2021-06-23 14:21:06 +03:00
|
|
|
Run the Docker container with an admin-secret env var
|
|
|
|
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
2020-07-23 15:34:17 +03:00
|
|
|
|
2021-06-23 14:21:06 +03:00
|
|
|
.. code-block:: yaml
|
2020-07-23 15:34:17 +03:00
|
|
|
:emphasize-lines: 5
|
|
|
|
|
2021-06-23 14:21:06 +03:00
|
|
|
graphql-engine:
|
|
|
|
image: hasura/graphql-engine:v2.0.0
|
|
|
|
environment:
|
|
|
|
HASURA_GRAPHQL_METADATA_DATABASE_URL: postgres://postgres:postgrespassword@postgres:5432/postgres
|
|
|
|
HASURA_GRAPHQL_ADMIN_SECRET: myadminsecretkey
|
|
|
|
...
|
2020-07-23 15:34:17 +03:00
|
|
|
|
|
|
|
.. note::
|
|
|
|
|
|
|
|
The ``HASURA_GRAPHQL_ADMIN_SECRET`` should never be passed from the client to the Hasura GraphQL engine as it would
|
|
|
|
give the client full admin rights to your Hasura instance. See :ref:`auth` for information on
|
|
|
|
setting up authentication.
|
|
|
|
|
|
|
|
.. _docker_logs:
|
|
|
|
|
|
|
|
Hasura GraphQL engine server logs
|
|
|
|
---------------------------------
|
|
|
|
|
|
|
|
You can check the logs of the Hasura GraphQL engine deployed using Docker by checking the logs of the
|
|
|
|
GraphQL engine container:
|
|
|
|
|
|
|
|
.. code-block:: bash
|
|
|
|
|
|
|
|
$ docker ps
|
|
|
|
|
2021-06-23 14:21:06 +03:00
|
|
|
CONTAINER ID IMAGE ... CREATED STATUS PORTS ...
|
|
|
|
097f58433a2b hasura/graphql-engine ... 1m ago Up 1m 8080->8080/tcp ...
|
|
|
|
b0b1aac0508d postgres ... 1m ago Up 1m 5432/tcp ...
|
|
|
|
|
2020-07-23 15:34:17 +03:00
|
|
|
|
2021-06-23 14:21:06 +03:00
|
|
|
$ docker logs 097f58433a2b
|
2020-07-23 15:34:17 +03:00
|
|
|
|
|
|
|
{"timestamp":"2018-10-09T11:20:32.054+0000", "level":"info", "type":"http-log", "detail":{"status":200, "query_hash":"01640c6dd131826cff44308111ed40d7fbd1cbed", "http_version":"HTTP/1.1", "query_execution_time":3.0177627e-2, "request_id":null, "url":"/v1/graphql", "user":{"x-hasura-role":"admin"}, "ip":"127.0.0.1", "response_size":209329, "method":"POST", "detail":null}}
|
|
|
|
...
|
|
|
|
|
|
|
|
**See:**
|
|
|
|
|
|
|
|
- https://docs.docker.com/config/containers/logging for more details on logging in Docker.
|
|
|
|
|
|
|
|
- :ref:`hge_logs` for more details on Hasura logs.
|
|
|
|
|
|
|
|
.. _docker_update:
|
|
|
|
|
|
|
|
Updating Hasura GraphQL engine
|
|
|
|
------------------------------
|
|
|
|
|
|
|
|
This guide will help you update the Hasura GraphQL engine running with Docker. This guide assumes that you already have
|
|
|
|
Hasura GraphQL engine running with Docker.
|
|
|
|
|
|
|
|
Step 1: Check the latest release version
|
|
|
|
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
|
|
|
|
|
|
The current latest version is:
|
|
|
|
|
|
|
|
.. raw:: html
|
|
|
|
|
|
|
|
<code>hasura/graphql-engine:<span class="latest-release-tag">latest</span></code>
|
|
|
|
|
|
|
|
All the versions can be found at: https://github.com/hasura/graphql-engine/releases
|
|
|
|
|
|
|
|
Step 2: Update the Docker image
|
|
|
|
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
|
|
|
2021-06-23 14:21:06 +03:00
|
|
|
In the ``docker-compose`` command that you're running, update the image tag to this
|
2020-07-23 15:34:17 +03:00
|
|
|
latest version.
|
|
|
|
|
|
|
|
For example, if you had:
|
|
|
|
|
|
|
|
.. raw:: html
|
|
|
|
|
2021-06-23 14:21:06 +03:00
|
|
|
<code>
|
|
|
|
graphql-engine:<br/>
|
|
|
|
image: hasura/graphql-engine:v1.2.0
|
|
|
|
</code>
|
2020-07-23 15:34:17 +03:00
|
|
|
|
|
|
|
you should change it to:
|
|
|
|
|
|
|
|
.. raw:: html
|
|
|
|
|
2021-06-23 14:21:06 +03:00
|
|
|
<code>
|
|
|
|
graphql-engine:<br/>
|
|
|
|
image: hasura/graphql-engine:<span class="latest-release-tag">latest</span>
|
|
|
|
</code>
|
2020-07-23 15:34:17 +03:00
|
|
|
|
|
|
|
.. note::
|
|
|
|
|
|
|
|
If you are downgrading to an older version of the GraphQL engine you might need to downgrade your metadata catalogue version
|
|
|
|
as described in :ref:`downgrade_hge`
|
|
|
|
|
2018-12-03 15:12:24 +03:00
|
|
|
Advanced
|
|
|
|
--------
|
2018-09-11 14:11:24 +03:00
|
|
|
|
2020-06-11 15:57:46 +03:00
|
|
|
- :ref:`Setting up migrations <migrations>`
|
2018-09-11 14:11:24 +03:00
|
|
|
|