docs: update getting-started docker

PR-URL: https://github.com/hasura/graphql-engine-mono/pull/7146
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Sean Park-Ross <94021366+seanparkross@users.noreply.github.com>
GitOrigin-RevId: 7e5a35d3a9f78ab10feafdcfe6549eda6f033f90
This commit is contained in:
Rob Dominguez 2023-01-23 09:06:35 -06:00 committed by hasura-bot
parent 24cba66344
commit 23e232eedd
3 changed files with 57 additions and 76 deletions

View File

@ -15,74 +15,48 @@ import Thumbnail from '@site/src/components/Thumbnail';
## Introduction
This guide will help you get the Hasura GraphQL Engine and a Postgres database to store its Metadata running as Docker
containers using Docker Compose. This is the easiest way to set up Hasura GraphQL Engine on your **local environment**.
This guide will help you get up and running quickly with the Hasura GraphQL Engine and a Postgres database running as
Docker containers using Docker Compose.
## Prerequisites
You'll need to have Docker installed in order to run the container. Check out
[the Docker documentation](https://docs.docker.com/install/) for instructions.
- [Docker](https://docs.docker.com/install/) installed and running.
## Step 1: Get the docker-compose file
## Step 1: Get the Compose file & start the containers
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:
Get the Compose file from our repo. If you're using curl, run this command in a new directory:
```bash
# 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
```
## Step 2: Run Hasura GraphQL Engine
The following command will run Hasura GraphQL Engine along with a Postgres database to store its Metadata.
If you're using wget, run this command in a new directory:
```bash
$ docker compose up -d
wget https://raw.githubusercontent.com/hasura/graphql-engine/stable/install-manifests/docker-compose/docker-compose.yaml
```
Check if the containers are running:
Then, run the following command to start both the Hasura GraphQL Engine and the Postgres database in Docker containers:
```bash
$ docker ps
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 ...
docker compose up -d
```
## Step 3: Connect a database
## Step 2: Connect a database
Head to `http://localhost:8080/console` to open the Hasura Console.
Navigate to `Data -> Manage -> Connect Database`:
Open the Hasura Console by navigating to `http://localhost:8080/console`. From the Console, click the `Data` tab:
<Thumbnail src="/img/getting-started/connect-db-console.png" alt="Connect database" width="1000px" />
Enter your database connection URL. _(See the note below if you do not have an existing database)_
Select the `Environment Variable` option and enter `PG_DATABASE_URL` as the environment variable name:
<Thumbnail src="/img/getting-started/connect-db-env-var.png" alt="Enter URL for existing database" width="1000px" />
Click `Connect Database`.
<Thumbnail src="/img/getting-started/connect-db-core.png" alt="Enter URL for existing database" width="700px" />
## Step 3: Try out Hasura
:::info Starting from scratch
If you are looking to start setting up a backend from scratch, we recommend using Postgres as the database.
If you do not have an existing Postgres database, you can choose to connect to the Postgres database that was created
along with Hasura (to store its metadata) and use it as a data source as well. The docker-compose file has an additional
env var `PG_DATABASE_URL` which points to the created Metadata database. You can use this env var to connect the same
database as a data source and continue.
:::
## Step 4: Try out Hasura
<!-- TODO: add options to track existing vs create new tables -->
### Create a table
### Create a table and insert some demo data
On the Hasura Console, navigate to `Data -> Create table` and create a sample table called `profiles` with the following
columns:
@ -115,56 +89,63 @@ You'll see that you get all the inserted data!
<Thumbnail src="/img/getting-started/profile-query.png" alt="Try out a query" width="1200px" />
## Next steps
## Recap
### Learn tutorial
What did we just do? Well, you just created a powerful, full-featured GraphQL API in less than five minutes. 🎉
For a full hands-on tour of Hasura, check out our
[30-Minute Hasura Basics Tutorial](https://hasura.io/learn/graphql/hasura/introduction/).
We started two Docker containers - one for the Hasura GraphQL Engine and one for the Postgres database. In this example,
our Postgres database also contains the [Hasura Metadata](/migrations-metadata-seeds/manage-metadata.mdx); which is how
Hasura records its information about the GraphQL schema, the relationships between tables, and much more. Finally, we
connected our Postgres database to the Hasura GraphQL Engine, which allowed Hasura Engine to automatically create a full
CRUD GraphQL API for our Postgres database which we could then easily query, mutate and subscribe to.
### Stay up to date
:::info Important: Set up the Hasura CLI
We release new features every month. Sign up for our newsletter by using the link below. We send newsletters only once a
month. <https://hasura.io/newsletter/>.
### Security Announcements
Join the [Hasura Security Announcements](https://groups.google.com/forum/#!forum/hasura-security-announce) group for
emails about security announcements.
The Hasura CLI is a powerful tool that helps you manage your Hasura project and is recommended for the majority of
development workflows. It helps track and manage your
[Hasura Metadata and Migrations](/migrations-metadata-seeds/index.mdx) and commit them to version control and allows you
to quickly move between environments like development and production.
### Database operations
- [Database modeling](/schema/postgres/index.mdx): Learn how to model your database schema, as well as how to extend it.
- [Querying data](/queries/postgres/index.mdx): Use GraphQL queries to query data from your GraphQL API.
- [Inserting data](/mutations/postgres/index.mdx): Use GraphQL mutations to insert data into your GraphQL API.
We omitted the CLI steps in this guide for the sake of simplicity and brevity, but in a typical new project, you would
always include the CLI setup steps.
### Business logic
Every developer working with Hasura should have the Hasura CLI installed. You can do so by
[following this guide](/hasura-cli/install-hasura-cli.mdx) and learn more by checking out our
[Advanced Hasura course](https://hasura.io/learn/graphql/hasura-advanced/introduction/).
There are several options for the implementation of business logic, depending on your use case.
:::
- [Actions](/actions/index.mdx): Actions can be used if you'd like to extend your GraphQL schema by integrating with a
REST endpoint.
- [Remote Schemas](/remote-schemas/index.mdx): If you have an existing GraphQL server or if you're comfortable with
implementing one, you can use Remote Schemas.
- [Event Triggers](/event-triggers/index.mdx): To trigger a serverless function based on a database event, use event
triggers.
- [Scheduled Triggers](/scheduled-triggers/index.mdx): Scheduled Triggers are used to execute custom business logic at
specific points in time.
## Next steps
### Migrations
- If you're interested in taking a deep dive into Hasura, check out our hands-on
[30-Minute Hasura Basics Tutorial](https://hasura.io/learn/graphql/hasura/introduction/).
Set up [Hasura Migrations](/migrations-metadata-seeds/migrations-metadata-setup.mdx) to track your database alterations.
This will make it easier to move to a different environment (e.g. staging or prod) later.
- There are several options for the implementation of business logic, depending on your use case.
### Secure your endpoint
- [Actions](/actions/index.mdx): Actions can be used if you'd like to extend your GraphQL schema by integrating with a
REST endpoint.
- [Remote Schemas](/remote-schemas/index.mdx): If you have an existing GraphQL server or if you're comfortable with
implementing one, you can use Remote Schemas.
- [Event Triggers](/event-triggers/index.mdx): To trigger a serverless function based on a database event, use Event
Triggers.
- [Scheduled Triggers](/scheduled-triggers/index.mdx): Scheduled Triggers are used to execute custom business logic at
specific points in time.
[Add an admin secret](/deployment/deployment-guides/docker.mdx#docker-secure) to make sure that your GraphQL endpoint
and the Hasura Console are not publicly accessible.
- If you're new to database modeling, check out these guides:
## Detailed Docker setup
- [Database modeling](/schema/postgres/index.mdx): Learn how to model your database schema, as well as how to extend
it.
- [Querying data](/queries/postgres/index.mdx): Use GraphQL queries to query data from your GraphQL API.
- [Inserting data](/mutations/postgres/index.mdx): Use GraphQL mutations to insert data into your GraphQL API.
This was a quickstart guide to get the Hasura GraphQL Engine up and running quickly. For more detailed instructions on
deploying using Docker, check out [Run Hasura GraphQL Engine using Docker](/deployment/deployment-guides/docker.mdx).
- **Security Announcements**: Join the [Hasura Security Announcements](https://groups.google.com/forum/#!forum/hasura-security-announce) group for
emails about security announcements.
- We release new features every month. Sign up for our newsletter by using the link below. We send newsletters only once
a month. <https://hasura.io/newsletter/>.
:::info Additional Resources

Binary file not shown.

Before

Width:  |  Height:  |  Size: 41 KiB

After

Width:  |  Height:  |  Size: 79 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 149 KiB