Skip to content

Commit de3c436

Browse files
authored
Merge pull request #388 from DefangLabs/lio/x-defang-mongo
Add x-defang-mongodb to samples
2 parents 16c7711 + 1612e8a commit de3c436

File tree

2 files changed

+23
-5
lines changed

2 files changed

+23
-5
lines changed

README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,18 @@ services:
4848
- MONGO_URI # empty values are read from defang config
4949
```
5050
51+
### Using DocumentDB in AWS
52+
53+
If you want to use DocumentDB in AWS, you can add the `x-defang-mongodb` extension to your `compose.yaml` file:
54+
55+
```yaml
56+
services:
57+
db:
58+
x-defang-mongodb: true
59+
```
60+
61+
This will automatically provision a DocumentDB cluster in your AWS account.
62+
5163
## Deployment
5264

5365
> [!NOTE]

compose.yaml

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,8 @@ services:
99
target: 8080
1010
published: 8080
1111
environment:
12-
# If you want to use MongoDB Atlas, you can set the URI with `defang config set MONGO_URI`
13-
# and remove the value from the MONGO_URI environment variable so that it is read from defang
14-
# config. For example:
15-
# - MONGO_URI
12+
# If you want to use MongoDB Atlas, you can set the URI with `defang config set MONGO_URI`.
13+
# This will override any value set in the environment variable:
1614
- MONGO_URI=mongodb://$MONGO_INITDB_ROOT_USERNAME:$MONGO_INITDB_ROOT_PASSWORD@db:27017/
1715
#deploy:
1816
# resources:
@@ -24,11 +22,19 @@ services:
2422
- db
2523

2624
db:
27-
image: mongo:8.0.3
25+
image: mongo:5
2826
restart: unless-stopped
2927
ports:
3028
- mode: host
3129
target: 27017
3230
environment:
3331
- MONGO_INITDB_ROOT_USERNAME
3432
- MONGO_INITDB_ROOT_PASSWORD
33+
volumes:
34+
- db_data:/data/db
35+
# The following option will provision a managed MongoDB instance, eg. DocumentDB on AWS.
36+
x-defang-mongodb: true
37+
38+
volumes:
39+
db_data:
40+
driver: local

0 commit comments

Comments
 (0)