|
2 | 2 |
|
3 | 3 | [](https://portal.defang.dev/redirect?url=https%3A%2F%2Fgithub.com%2Fnew%3Ftemplate_name%3Dsample-huginn-template%26template_owner%3DDefangSamples)
|
4 | 4 |
|
| 5 | +This sample shows how to deploy Huginn with Defang. |
| 6 | + |
5 | 7 | 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.
|
6 | 8 |
|
7 | 9 | ## Prerequisites
|
8 | 10 |
|
9 | 11 | 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) |
12 | 59 |
|
13 |
| -## Local |
| 60 | +### Defang Playground |
14 | 61 |
|
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 | +``` |
16 | 66 |
|
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) |
18 | 68 |
|
19 |
| -## Deploying |
| 69 | +If you want to deploy to your own cloud account, you can use Defang BYOC: |
20 | 70 |
|
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 | + ``` |
25 | 76 |
|
26 | 77 | ---
|
27 | 78 |
|
|
0 commit comments