Skip to content

Commit a950768

Browse files
Merge pull request #263 from DefangLabs/linda-bullmq
Bullmq changes
2 parents 7c85d7d + 2e52c9f commit a950768

File tree

4 files changed

+64
-15
lines changed

4 files changed

+64
-15
lines changed

samples/bullmq-bullboard-redis/README.md

Lines changed: 49 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,29 +2,66 @@
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-bullmq-bullboard-redis-template%26template_owner%3DDefangSamples)
44

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.
66

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)).
88

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.
1010

1111
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.
1212

1313
## Prerequisites
1414

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/)
1718

18-
## Deploying
19+
## Development
1920

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:
2422

25-
## Local Development
23+
```bash
24+
docker compose -f compose.dev.yaml up --build
25+
```
2626

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+
```
2865

2966
---
3067

samples/bullmq-bullboard-redis/api/Dockerfile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
# Use the slim version of Node.js v20 on Debian Bookworm as the base image
22
FROM node:20-bookworm-slim
33

4+
# Install tools for healthcheck
5+
RUN apt-get update && apt-get install -y \
6+
curl \
7+
&& rm -rf /var/lib/apt/lists/*
8+
49
# Set the working directory
510
WORKDIR /app
611

samples/bullmq-bullboard-redis/board/Dockerfile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
# Use the slim version of Node.js on Debian Bookworm as the base image
22
FROM node:20-bookworm-slim
33

4+
# Install tools for healthcheck
5+
RUN apt-get update && apt-get install -y \
6+
curl \
7+
&& rm -rf /var/lib/apt/lists/*
8+
49
# Set the working directory
510
WORKDIR /app
611

samples/bullmq-bullboard-redis/compose.yaml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ services:
1212
- REDIS=redis://redisx:6379
1313
- BOARD_PASSWORD
1414
- QUEUE
15+
healthcheck:
16+
test: ["CMD", "curl", "-f", "127.0.0.1:3000"]
1517
depends_on:
1618
- redisx
1719
#deploy:
@@ -31,6 +33,8 @@ services:
3133
environment:
3234
- REDIS=redis://redisx:6379
3335
- QUEUE
36+
healthcheck:
37+
test: ["CMD", "curl", "-f", "127.0.0.1:3001"]
3438
depends_on:
3539
- redisx
3640
#deploy:
@@ -41,15 +45,13 @@ services:
4145
worker:
4246
restart: unless-stopped
4347
deploy:
44-
replicas: 2
48+
replicas: 1
4549
build:
4650
context: ./worker
4751
dockerfile: Dockerfile
4852
environment:
4953
- REDIS=redis://redisx:6379
5054
- QUEUE
51-
healthcheck:
52-
test: ["CMD", "wget", "-q", "--spider", "127.0.0.1:3000"]
5355
depends_on:
5456
- redisx
5557
#deploy:

0 commit comments

Comments
 (0)