From 204af5df18d5e182f457bd7c3449da17025e145a Mon Sep 17 00:00:00 2001 From: Eric Liu Date: Mon, 21 Jul 2025 07:11:20 -0700 Subject: [PATCH 1/8] add GCP information for mongodb --- .../managed-storage/managed-mongodb.md | 30 ++++++++++++++++--- .../managed-storage/managed-storage.md | 2 +- 2 files changed, 27 insertions(+), 5 deletions(-) diff --git a/docs/concepts/managed-storage/managed-mongodb.md b/docs/concepts/managed-storage/managed-mongodb.md index c30d2f892d..2e266d419e 100644 --- a/docs/concepts/managed-storage/managed-mongodb.md +++ b/docs/concepts/managed-storage/managed-mongodb.md @@ -7,7 +7,7 @@ sidebar_position: 3000 # Managed MongoDB :::info -This feature was introduced in Defang v1.2.0 released on June 3, 2025. [Upgrade to the latest version](/docs/cli/defang_upgrade) +This feature was introduced in Defang v1.2.0 released on June 3, 2025 for AWS. [Upgrade to the latest version](/docs/cli/defang_upgrade) ::: Managed MongoDB is a service that allows you to store and retrieve large amounts of data in a document-oriented format. MongoDB is ideal for storing unstructured data like JSON documents, making it a popular choice for modern applications. @@ -19,7 +19,7 @@ Managed MongoDB is a service that allows you to store and retrieve large amounts | [Playground](/docs/providers/playground#managed-services) | ⚠️ Unmanaged | | [AWS](/docs/providers/aws#managed-storage) | ✅ DocumentDB | | [DigitalOcean](/docs/providers/digitalocean#future-improvements) | ⚠️ Unmanaged | -| [GCP](/docs/providers/gcp#future-improvements) | ⚠️ Unmanaged | +| [GCP](/docs/providers/gcp#future-improvements) | ✅ Firestore | ## How to use Managed MongoDB @@ -27,9 +27,31 @@ To use managed MongoDB, in your `compose.yaml` file, use the `x-defang-mongodb` ### Required Configuration -When using managed MongoDB, you **must** set a username and password for the database. By default, these are read from the `MONGO_INITDB_ROOT_USERNAME` and `MONGO_INITDB_ROOT_PASSWORD` config variables, conform [the official MongoDB container image](https://hub.docker.com/_/mongo). These can be set using the `defang config set MONGO_INITDB_ROOT_USERNAME` and `defang config set MONGO_INITDB_ROOT_PASSWORD` commands. If you do not provide these values, the deployment will fail. +### AWS +When using managed MongoDB on AWS, you **must** set a username and password for the database. By default, these are read from the `MONGO_INITDB_ROOT_USERNAME` and `MONGO_INITDB_ROOT_PASSWORD` config variables, following [the official MongoDB container image](https://hub.docker.com/_/mongo) convention. -### Example +You can set these using the following commands: + +```bash +defang config set MONGO_INITDB_ROOT_USERNAME +defang config set MONGO_INITDB_ROOT_PASSWORD +``` + +If you do not provide these values, the deployment will fail. + +### GCP + +When using managed MongoDB on GCP, you **must** set a `MONGO_INITDB_DATABASE` environment variable with the name of the database to create. + +```yaml +services: + db: + x-defang-mongodb: true + environment: + MONGO_INITDB_DATABASE: mydb +``` + +**Important:** It's recommended that you **DO NOT** set `MONGO_INITDB_ROOT_USERNAME` and `MONGO_INITDB_ROOT_PASSWORD` config variables when using GCP. This is because GCP Firestore does not create default user accounts when creating MongoDB databases, and setting these credentials may cause connection issues.### Example ```yaml services: diff --git a/docs/concepts/managed-storage/managed-storage.md b/docs/concepts/managed-storage/managed-storage.md index 1b5b0c23c0..8560a53d7f 100644 --- a/docs/concepts/managed-storage/managed-storage.md +++ b/docs/concepts/managed-storage/managed-storage.md @@ -6,4 +6,4 @@ sidebar_position: 000 # Managed Storage -Defang helps you provision the infrastructure you need to run your services. That infrastructure is designed to scale in and out without persistent storage, so you can build highly scalable services. But Defang can also help you provision managed services to store and persist your data, like [caches](./managed-redis.md), [databases](./managed-postgres.mdx), and [object storage](./managed-object-storage.md). +Defang helps you provision the infrastructure you need to run your services. That infrastructure is designed to scale in and out without persistent storage, so you can build highly scalable services. But Defang can also help you provision managed services to store and persist your data, like [caches](./managed-redis.md), [sql databases](./managed-postgres.mdx), [nosql databases](./managed-mongodb.md), and [object storage](./managed-object-storage.md). From e825bfb0bc6050034c1c91b1f23f6320ed4cf3b0 Mon Sep 17 00:00:00 2001 From: Eric Liu Date: Mon, 21 Jul 2025 07:18:46 -0700 Subject: [PATCH 2/8] add clearer text --- docs/concepts/managed-storage/managed-mongodb.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/concepts/managed-storage/managed-mongodb.md b/docs/concepts/managed-storage/managed-mongodb.md index 2e266d419e..b2ac1c9abf 100644 --- a/docs/concepts/managed-storage/managed-mongodb.md +++ b/docs/concepts/managed-storage/managed-mongodb.md @@ -51,7 +51,9 @@ services: MONGO_INITDB_DATABASE: mydb ``` -**Important:** It's recommended that you **DO NOT** set `MONGO_INITDB_ROOT_USERNAME` and `MONGO_INITDB_ROOT_PASSWORD` config variables when using GCP. This is because GCP Firestore does not create default user accounts when creating MongoDB databases, and setting these credentials may cause connection issues.### Example +**Important:** Do **NOT** set `MONGO_INITDB_ROOT_USERNAME` and `MONGO_INITDB_ROOT_PASSWORD` config variables when using GCP. GCP Firestore handles authentication automatically, and your services will have seamless access to the database without requiring explicit credentials. + +### Example ```yaml services: From 4e0b01facf3e19a72809ed016cbdffefc4465f49 Mon Sep 17 00:00:00 2001 From: Eric Liu Date: Mon, 21 Jul 2025 08:16:17 -0700 Subject: [PATCH 3/8] update to mention GCP does not take user/password into account --- docs/concepts/managed-storage/managed-mongodb.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/concepts/managed-storage/managed-mongodb.md b/docs/concepts/managed-storage/managed-mongodb.md index b2ac1c9abf..2075351453 100644 --- a/docs/concepts/managed-storage/managed-mongodb.md +++ b/docs/concepts/managed-storage/managed-mongodb.md @@ -51,7 +51,7 @@ services: MONGO_INITDB_DATABASE: mydb ``` -**Important:** Do **NOT** set `MONGO_INITDB_ROOT_USERNAME` and `MONGO_INITDB_ROOT_PASSWORD` config variables when using GCP. GCP Firestore handles authentication automatically, and your services will have seamless access to the database without requiring explicit credentials. +**Important:** GCP will ignore `MONGO_INITDB_ROOT_USERNAME` and `MONGO_INITDB_ROOT_PASSWORD` credentials since they are not needed. GCP automatically handles authentication and grants your service access to the MongoDB database. ### Example From 8889a11f7fb3b9821d1db8ea6f40fd5c4ee6a6c1 Mon Sep 17 00:00:00 2001 From: Eric Liu Date: Mon, 21 Jul 2025 10:25:53 -0700 Subject: [PATCH 4/8] info about deleting database --- docs/concepts/managed-storage/managed-mongodb.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/docs/concepts/managed-storage/managed-mongodb.md b/docs/concepts/managed-storage/managed-mongodb.md index 2075351453..dd5794be5b 100644 --- a/docs/concepts/managed-storage/managed-mongodb.md +++ b/docs/concepts/managed-storage/managed-mongodb.md @@ -69,6 +69,12 @@ services: x-defang-mongodb: true ``` +:::warning[Deleting a GCP Firestore Mongo Database ] +Please be aware GCP Firestore does not allow deleting of your database when you down your project use `defang compose down`. You must go to the [GCP Cloud Console for Firestore](https://console.cloud.google.com/firestore/databases/) to delete it. +::: + :::warning[Version] AWS DocumentDB is compatible with MongoDB 3.6, 4.0, and 5.0. The `mongo:5` image is compatible with DocumentDB 5.0, so we recommend using this version for your MongoDB service. Deployment will fail for versions higher than 5. + +GCP Firestore does now have a configurable version. ::: From 11a256b74c510625ec2cc7523099ddbbd4fac31f Mon Sep 17 00:00:00 2001 From: Eric Liu Date: Mon, 21 Jul 2025 10:28:53 -0700 Subject: [PATCH 5/8] fix spelling and consistencies --- docs/concepts/managed-storage/managed-mongodb.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/concepts/managed-storage/managed-mongodb.md b/docs/concepts/managed-storage/managed-mongodb.md index dd5794be5b..4aa6e22bd9 100644 --- a/docs/concepts/managed-storage/managed-mongodb.md +++ b/docs/concepts/managed-storage/managed-mongodb.md @@ -69,12 +69,12 @@ services: x-defang-mongodb: true ``` -:::warning[Deleting a GCP Firestore Mongo Database ] -Please be aware GCP Firestore does not allow deleting of your database when you down your project use `defang compose down`. You must go to the [GCP Cloud Console for Firestore](https://console.cloud.google.com/firestore/databases/) to delete it. +:::warning[Deleting a GCP Firestore MongoDB Database] +Please be aware that GCP Firestore does not allow deletion of your database when you bring down your project using `defang compose down`. You must go to the [GCP Cloud Console for Firestore](https://console.cloud.google.com/firestore/databases/) to delete it manually. ::: :::warning[Version] AWS DocumentDB is compatible with MongoDB 3.6, 4.0, and 5.0. The `mongo:5` image is compatible with DocumentDB 5.0, so we recommend using this version for your MongoDB service. Deployment will fail for versions higher than 5. -GCP Firestore does now have a configurable version. +GCP Firestore does not have a configurable version. ::: From ea2f78ef6a27b5d5e85a9ffb991ab4aa3c32e7fb Mon Sep 17 00:00:00 2001 From: Eric Liu Date: Mon, 21 Jul 2025 11:00:27 -0700 Subject: [PATCH 6/8] add information about connection string --- docs/concepts/managed-storage/managed-mongodb.md | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/docs/concepts/managed-storage/managed-mongodb.md b/docs/concepts/managed-storage/managed-mongodb.md index 4aa6e22bd9..0b030dcae1 100644 --- a/docs/concepts/managed-storage/managed-mongodb.md +++ b/docs/concepts/managed-storage/managed-mongodb.md @@ -43,13 +43,7 @@ If you do not provide these values, the deployment will fail. When using managed MongoDB on GCP, you **must** set a `MONGO_INITDB_DATABASE` environment variable with the name of the database to create. -```yaml -services: - db: - x-defang-mongodb: true - environment: - MONGO_INITDB_DATABASE: mydb -``` +Defang will automatically create a config variable named `_URL` that contains the connection string for your MongoDB database. For example, if your service is named `db`, the config variable will be `DB_URL`. **Important:** GCP will ignore `MONGO_INITDB_ROOT_USERNAME` and `MONGO_INITDB_ROOT_PASSWORD` credentials since they are not needed. GCP automatically handles authentication and grants your service access to the MongoDB database. @@ -60,7 +54,7 @@ services: app: # [...] environment: - MONGO_URI: mongodb://$MONGO_INITDB_ROOT_USERNAME:$MONGO_INITDB_ROOT_PASSWORD@db:27017/ + DB_URL: mongodb://$MONGO_INITDB_ROOT_USERNAME:$MONGO_INITDB_ROOT_PASSWORD@db:27017/ depends_on: - db From ab9534e806b5bd4f9846b32f1ba5abcfe826cb0b Mon Sep 17 00:00:00 2001 From: Eric Liu Date: Mon, 21 Jul 2025 11:42:59 -0700 Subject: [PATCH 7/8] update example --- docs/concepts/managed-storage/managed-mongodb.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/concepts/managed-storage/managed-mongodb.md b/docs/concepts/managed-storage/managed-mongodb.md index 0b030dcae1..59d370f7cd 100644 --- a/docs/concepts/managed-storage/managed-mongodb.md +++ b/docs/concepts/managed-storage/managed-mongodb.md @@ -61,6 +61,8 @@ services: db: image: mongo:5 x-defang-mongodb: true + environment: + MONGO_INITDB_DATABASE: mydb ``` :::warning[Deleting a GCP Firestore MongoDB Database] From 5172785f1e28dd8db583801368509fe63fb84b69 Mon Sep 17 00:00:00 2001 From: Eric Liu Date: Mon, 21 Jul 2025 11:46:37 -0700 Subject: [PATCH 8/8] review updates --- docs/concepts/managed-storage/managed-storage.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/concepts/managed-storage/managed-storage.md b/docs/concepts/managed-storage/managed-storage.md index 8560a53d7f..534c13cf2a 100644 --- a/docs/concepts/managed-storage/managed-storage.md +++ b/docs/concepts/managed-storage/managed-storage.md @@ -6,4 +6,4 @@ sidebar_position: 000 # Managed Storage -Defang helps you provision the infrastructure you need to run your services. That infrastructure is designed to scale in and out without persistent storage, so you can build highly scalable services. But Defang can also help you provision managed services to store and persist your data, like [caches](./managed-redis.md), [sql databases](./managed-postgres.mdx), [nosql databases](./managed-mongodb.md), and [object storage](./managed-object-storage.md). +Defang helps you provision the infrastructure you need to run your services. That infrastructure is designed to scale in and out without persistent storage, so you can build highly scalable services. Defang can also help you provision managed services to store and persist your data, like [caches](./managed-redis.md), [sql databases](./managed-postgres.mdx), [nosql databases](./managed-mongodb.md), and [object storage](./managed-object-storage.md).