|
2 | 2 |
|
3 | 3 | [](https://portal.defang.dev/redirect?url=https%3A%2F%2Fgithub.com%2Fnew%3Ftemplate_name%3Dsample-bullmq-bullboard-redis-template%26template_owner%3DDefangSamples)
|
4 | 4 |
|
5 |
| -This sample project demonstrates how to deploy a BullMQ message queue on top of managed Redis with a queue processor and a dashboard to monitor the queue. |
| 5 | +This sample demonstrates how to deploy a BullMQ message queue on top of managed Redis with a queue processor and a dashboard to monitor the queue. |
6 | 6 |
|
7 |
| -Once your app is up and running you can go to the `/board` route for the `board` service to see the Bull Board dashboard and use the username `admin` and the password you set to log in (see [Deploying](#deploying)). |
| 7 | +Once your app is up and running you can go to the `/board` route for the `board` service to see the Bull Board dashboard and use the username `admin` and the board password you set to log in (see [Configuration](#configuration)). |
8 | 8 |
|
9 |
| -To add a job to the queue, you can go to the `/add` route of the `api` service. This will use some default values so you can test things out. You can also see an example of a post request in the [sample http request](./api/add.test.http) file. |
| 9 | +To add a job to the queue, you can go to the `/add` route of the `api` service. This will use some default values so you can test things out. You can also see an example of a post request in the [sample HTTP request](./api/add.test.http) file. |
10 | 10 |
|
11 | 11 | The `worker` service is the queue processor that will process the jobs added to the queue. You can see in the `compose.yaml` file that the `worker` service is set to scale to 2 instances. This means that there will be 2 workers processing jobs from the queue. You can set this to your desired number of workers, but we wanted to show how you can increase the number of workers to handle more jobs.
|
12 | 12 |
|
13 | 13 | ## Prerequisites
|
14 | 14 |
|
15 |
| -1. Download <a href="https://github.com/defang-io/defang">Defang CLI</a> |
16 |
| -2. (optional) If you are using <a href="https://docs.defang.io/docs/concepts/defang-byoc">Defang BYOC</a>, make sure you have properly <a href="https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-configure.html">authenticated your AWS account</a>. |
| 15 | +1. Download [Defang CLI](https://github.com/DefangLabs/defang) |
| 16 | +2. (Optional) If you are using [Defang BYOC](https://docs.defang.io/docs/concepts/defang-byoc) authenticate with your cloud provider account |
| 17 | +3. (Optional for local development) [Docker CLI](https://docs.docker.com/engine/install/) |
17 | 18 |
|
18 |
| -## Deploying |
| 19 | +## Development |
19 | 20 |
|
20 |
| -1. Open the terminal and type `defang login` |
21 |
| -2. Run `defang config set BOARD_PASSWORD` to set the password for the BullBoard dashboard. |
22 |
| -3. Type `defang compose up` in the CLI. |
23 |
| -4. Your app will be running within a few minutes. |
| 21 | +To run the application locally, you can use the following command: |
24 | 22 |
|
25 |
| -## Local Development |
| 23 | +```bash |
| 24 | +docker compose -f compose.dev.yaml up --build |
| 25 | +``` |
26 | 26 |
|
27 |
| -1. Run `docker compose -f compose.dev.yaml up --build` |
| 27 | +## Configuration |
| 28 | + |
| 29 | +For this sample, you will need to provide the following [configuration](https://docs.defang.io/docs/concepts/configuration): |
| 30 | + |
| 31 | +> 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. |
| 32 | +
|
| 33 | +### `BOARD_PASSWORD` |
| 34 | +Set a board password and use together with the board username `admin` when signing in. |
| 35 | +```bash |
| 36 | +defang config set BOARD_PASSWORD |
| 37 | +``` |
| 38 | + |
| 39 | +### `QUEUE` |
| 40 | +```bash |
| 41 | +defang config set QUEUE |
| 42 | +``` |
| 43 | + |
| 44 | +## Deployment |
| 45 | + |
| 46 | +> [!NOTE] |
| 47 | +> Download [Defang CLI](https://github.com/DefangLabs/defang) |
| 48 | +
|
| 49 | +### Defang Playground |
| 50 | + |
| 51 | +Deploy your application to the Defang Playground by opening up your terminal and typing: |
| 52 | +```bash |
| 53 | +defang compose up |
| 54 | +``` |
| 55 | + |
| 56 | +### BYOC (AWS) |
| 57 | + |
| 58 | +If you want to deploy to your own cloud account, you can use Defang BYOC: |
| 59 | + |
| 60 | +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`. |
| 61 | +2. Run in a terminal that has access to your AWS environment variables: |
| 62 | + ```bash |
| 63 | + defang --provider=aws compose up |
| 64 | + ``` |
28 | 65 |
|
29 | 66 | ---
|
30 | 67 |
|
|
0 commit comments