Skip to content

Commit 55c1261

Browse files
committed
changes to readmes
1 parent 4b9cf29 commit 55c1261

File tree

2 files changed

+115
-26
lines changed

2 files changed

+115
-26
lines changed

samples/hasura/README.md

Lines changed: 54 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,34 +2,72 @@
22

33
[![1-click-deploy](https://defang.io/deploy-with-defang.png)](https://portal.defang.dev/redirect?url=https%3A%2F%2Fgithub.com%2Fnew%3Ftemplate_name%3Dsample-hasura-template%26template_owner%3DDefangSamples)
44

5-
This sample project demonstrates how to deploy Hasura with Defang and connect it to a Postgres database. We also demonstrate how to run a Postgres container during development and how to switch over to a managed postgres service like RDS, Neon, or others in production. If you want to get a compatible database ready to go really quickly for free, [Neon](https://neon.tech/) is a quick and easy way to go. The sample populates the database with some sample data so you can quickly start playing with the Hasura console. It sets wide open permissions on the tables as well so you can start querying or mutating the data right away.
5+
This sample project demonstrates how to deploy Hasura with Defang and connect it to a Postgres database.
6+
7+
The sample populates the database with some sample data so you can quickly start playing with the Hasura console. It sets wide open permissions on the tables as well so you can start querying or mutating the data right away.
68

79
## Prerequisites
810

911
1. Download [Defang CLI](https://github.com/DefangLabs/defang)
10-
2. Have a managed database service configured and have the connection string ready.
11-
3. (Optional) If you are using [Defang BYOC](https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-configure.html) authenticated with your AWS account
12-
4. (Optional - for local development) [Docker CLI](https://docs.docker.com/engine/install/)
13-
5. (Optional) [Install the Hasura CLI](https://hasura.io/docs/latest/hasura-cli/install-hasura-cli/) to create migrations and update metadata for your Hasura GraphQL api.
12+
2. Have a managed database service configured and ready, such as [Neon PostgreSQL](https://neon.tech/)
13+
3. (Optional) If you are using [Defang BYOC](https://docs.defang.io/docs/concepts/defang-byoc) authenticate with your cloud provider account
14+
4. (Optional for local development) [Docker CLI](https://docs.docker.com/engine/install/)
15+
5. (Optional) Install the [Hasura CLI](https://hasura.io/docs/latest/hasura-cli/install-hasura-cli/) to create migrations and update metadata for your Hasura GraphQL API
1416

1517
## Development
1618

17-
For development, we use a Postgres container. The Postgres container is defined in the `compose.dev.yaml` file. The Hasura container is defined in the `compose.yaml` file, with some overrides in the `compose.dev.yaml` file so it can correctly connect to the development database container.
19+
To run the application locally, you can use the following command:
20+
21+
```bash
22+
docker compose -f ./compose.yaml -f ./compose.dev.yaml up --build
23+
```
24+
This will start the Postgres container (from `compose.dev.yaml`) and the Hasura container (from `compose.yaml` with some overrides). The Hasura console will be available at `http://localhost:8080` with the password `password`.
25+
26+
> Note: If you want to make changes to your database, permissions, etc. see [Editing Hasura Settings](#editing-hasura-settings) for more information.
27+
28+
### Editing Hasura Settings
29+
30+
To edit the database, permissions, or any other Hasura settings such that you can deploy them to production, you should install the [ Hasura CLI](https://hasura.io/docs/latest/hasura-cli/install-hasura-cli/). Then, after starting the development environment, you can run `hasura console` _inside the `./hasura` directory_. This will open the Hasura console in your browser. Any changes you make in the console will be saved to the `migrations` and `metadata` directories. When you run `defang compose up`, these changes will be applied to the production environment.
31+
32+
## Configuration
33+
34+
For this sample, you will need to provide the following [configuration](https://docs.defang.io/docs/concepts/configuration):
35+
36+
> Note that if you are using the 1-click deploy option, you can set these values as secrets in your GitHub repository and the action will automatically deploy them for you.
37+
38+
### `HASURA_GRAPHQL_DATABASE_URL`
39+
A connection string of the format `postgres://username:password@host:port/dbname`.
40+
```bash
41+
defang config set HASURA_GRAPHQL_DATABASE_URL
42+
```
43+
44+
### `HASURA_GRAPHQL_ADMIN_SECRET`
45+
A password you would like to log into Hasura with.
46+
```bash
47+
defang config set HASURA_GRAPHQL_ADMIN_SECRET
48+
```
49+
50+
## Deployment
51+
52+
> [!NOTE]
53+
> Download [Defang CLI](https://github.com/DefangLabs/defang)
1854
19-
To start the development environment, run `docker compose -f ./compose.yaml -f ./compose.dev.yaml up`. This will start the Postgres container and the Hasura container. The Hasura console will be available at `http://localhost:8080` with the password `password`.
20-
**Note:** _If you want to make changes to your database, permissions, etc. you should use the Hasura console and the Hasura CLI to make those changes. See the next section for more information._
55+
### Defang Playground
2156

22-
### Editing the database/permissions etc.
57+
Deploy your application to the Defang Playground by opening up your terminal and typing:
58+
```bash
59+
defang compose up
60+
```
2361

24-
If you want to edit the database, permissions, or any other Hasura settings such that you can deploy them to production, you should [install the Hasura CLI](https://hasura.io/docs/latest/hasura-cli/install-hasura-cli/). Then, after starting the development environment, you can run `hasura console` _inside the `./hasura` directory_. This will open the Hasura console in your browser. Any changes you make in the console will be saved to the `migrations` and `metadata` directories. When you run `defang compose up` these changes will be applied to the production environment.
62+
### BYOC (AWS)
2563

26-
## Deploying
64+
If you want to deploy to your own cloud account, you can use Defang BYOC:
2765

28-
1. Open the terminal and type `defang login`
29-
2. Add your connection string as a defang config value by typing `defang config set HASURA_GRAPHQL_DATABASE_URL` and pasting your connection string (which should be in the format `postgres://username:password@host:port/dbname`)
30-
3. Setup a password for hasura by typing `defang config set HASURA_GRAPHQL_ADMIN_SECRET` and adding a password you would like to login with.
31-
4. Type `defang compose up` in the CLI.
32-
5. Your app will be running within a few minutes.
66+
1. [Authenticate your AWS account](https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-configure.html), and check that you have properly set your environment variables like `AWS_PROFILE`, `AWS_REGION`, `AWS_ACCESS_KEY_ID`, and `AWS_SECRET_ACCESS_KEY`.
67+
2. Run in a terminal that has access to your AWS environment variables:
68+
```bash
69+
defang --provider=aws compose up
70+
```
3371

3472
---
3573

samples/huginn/README.md

Lines changed: 61 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,77 @@
22

33
[![1-click-deploy](https://defang.io/deploy-with-defang.png)](https://portal.defang.dev/redirect?url=https%3A%2F%2Fgithub.com%2Fnew%3Ftemplate_name%3Dsample-huginn-template%26template_owner%3DDefangSamples)
44

5+
This sample shows how to deploy Huginn with Defang.
6+
57
Huginn is a system for building agents that perform automated tasks for you online. Huginn's Agents can monitor the web, respond to events, and act on your behalf. They propagate events along a directed graph. It's like a customizable IFTTT or Zapier on your own server, ensuring data privacy.
68

79
## Prerequisites
810

911
1. Download [Defang CLI](https://github.com/DefangLabs/defang)
10-
2. Have a managed database service configured and have the connection details ready. Neon postgres is a good free option.
11-
3. (optional) If you are using [Defang BYOC](https://docs.defang.io/docs/concepts/defang-byoc), make sure you have properly [authenticated your AWS account](https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-configure.html).
12+
2. Have a managed database service configured and ready, such as [Neon PostgreSQL](https://neon.tech/)
13+
3. (Optional) If you are using [Defang BYOC](https://docs.defang.io/docs/concepts/defang-byoc) authenticate with your cloud provider account
14+
4. (Optional for local development) [Docker CLI](https://docs.docker.com/engine/install/)
15+
16+
## Development
17+
18+
To run the application locally, you can use the following command:
19+
20+
```bash
21+
`docker compose -f ./compose.yaml -f ./compose.dev.yaml up
22+
```
23+
This will start the Postgres container and the Huginn container. Huginn will be available at `http://localhost:3000` with the username `admin` and password `password`.
24+
25+
## Configuration
26+
27+
For this sample, you will need to provide the following [configuration](https://docs.defang.io/docs/concepts/configuration):
28+
29+
> Note that if you are using the 1-click deploy option, you can set these values as secrets in your GitHub repository and the action will automatically deploy them for you.
30+
31+
### `DATABASE_NAME`
32+
The name of the database.
33+
```bash
34+
defang config set DATABASE_NAME
35+
```
36+
37+
### `DATABASE_USERNAME`
38+
The username used with the database.
39+
```bash
40+
defang config set DATABASE_USERNAME
41+
```
42+
43+
### `DATABASE_PASSWORD`
44+
The password used with the database.
45+
```bash
46+
defang config set DATABASE_PASSWORD
47+
```
48+
49+
### `DATABASE_HOST`
50+
The host of the database.
51+
```bash
52+
defang config set DATABASE_HOST
53+
```
54+
55+
## Deployment
56+
57+
> [!NOTE]
58+
> Download [Defang CLI](https://github.com/DefangLabs/defang)
1259

13-
## Local
60+
### Defang Playground
1461

15-
For development, we use a Postgres container. The Postgres container is defined in the `compose.dev.yaml` file. The Huginn container is defined in the `compose.yaml` file, with some overrides in the `compose.dev.yaml` file so it can correctly connect to the local database container.
62+
Deploy your application to the Defang Playground by opening up your terminal and typing:
63+
```bash
64+
defang compose up
65+
```
1666

17-
To start the local environment, run `docker compose -f ./compose.yaml -f ./compose.dev.yaml up`. This will start the Postgres container and the Huginn container. Huginn will be available at `http://localhost:3000` with the username `admin` and password `password`.
67+
### BYOC (AWS)
1868

19-
## Deploying
69+
If you want to deploy to your own cloud account, you can use Defang BYOC:
2070

21-
1. Open the terminal and type `defang login`
22-
2. Add your database connection details using `defang config` by typing `defang config set <CONFIG_VAL>` where `<CONFIG_VAL>` is the each of the following `DATABASE_NAME`, `DATABASE_USERNAME`, `DATABASE_PASSWORD`, `DATABASE_HOST`. For example `defang config set DATABASE_NAME` and pasting your database name.
23-
3. Type `defang compose up` in the CLI.
24-
4. Your app will be running within a few minutes.
71+
1. [Authenticate your AWS account](https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-configure.html), and check that you have properly set your environment variables like `AWS_PROFILE`, `AWS_REGION`, `AWS_ACCESS_KEY_ID`, and `AWS_SECRET_ACCESS_KEY`.
72+
2. Run in a terminal that has access to your AWS environment variables:
73+
```bash
74+
defang --provider=aws compose up
75+
```
2576

2677
---
2778

0 commit comments

Comments
 (0)