Skip to content

Commit 0dc408f

Browse files
Merge pull request #275 from DefangLabs/linda-huginn
huginn changes
2 parents 4ac57ac + dc902ad commit 0dc408f

File tree

3 files changed

+87
-21
lines changed

3 files changed

+87
-21
lines changed

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

samples/huginn/compose.dev.yaml

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
11
services:
22
huginn:
3+
extends:
4+
file: compose.yaml
5+
service: huginn-app
36
environment:
47
- DATABASE_ADAPTER=postgresql
58
- DATABASE_NAME=huginn
69
- DATABASE_USERNAME=huginn
710
- DATABASE_PASSWORD=huginn
8-
- DATABASE_HOST=postgres
9-
depends_on:
10-
- postgres
11-
postgres:
12-
image: postgres:16
11+
- DATABASE_HOST=db
12+
db:
13+
extends:
14+
file: compose.yaml
15+
service: db
1316
environment:
1417
POSTGRES_USER: huginn
1518
POSTGRES_PASSWORD: huginn
@@ -18,4 +21,4 @@ services:
1821
- postgres:/var/lib/postgresql/data
1922

2023
volumes:
21-
postgres:
24+
postgres:

samples/huginn/compose.yaml

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,27 @@ services:
1010
resources:
1111
reservations:
1212
cpus: '1.0'
13-
memory: '2G'
13+
memory: 1G
1414
healthcheck:
1515
test: ["CMD", "curl", "-f", "http://localhost:3000/"]
1616
interval: 1m30s
1717
timeout: 30s
1818
retries: 10
1919
environment:
2020
- DATABASE_ADAPTER=postgresql
21-
- DATABASE_NAME
22-
- DATABASE_USERNAME
23-
- DATABASE_PASSWORD
24-
- DATABASE_HOST
21+
- DATABASE_NAME=huginn
22+
- DATABASE_USERNAME=huginn
23+
- DATABASE_HOST=db
24+
- DATABASE_PASSWORD="${POSTGRES_PASSWORD}"
25+
depends_on:
26+
- db
27+
db:
28+
image: postgres:16
29+
environment:
30+
- POSTGRES_USER=huginn
31+
- POSTGRES_DB=huginn
32+
- POSTGRES_PASSWORD
33+
ports:
34+
- mode: host
35+
target: 5432
36+
published: 5432

0 commit comments

Comments
 (0)