Skip to content

Commit 46d9f8b

Browse files
update readme to describe config
1 parent 28fea19 commit 46d9f8b

File tree

1 file changed

+26
-12
lines changed

1 file changed

+26
-12
lines changed

samples/golang-mongodb-atlas/README.md

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
1-
# Go & MongoDB Atlas
1+
# Go & MongoDB
22

3-
[![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-golang-mongodb-atlas-template%26template_owner%3DDefangSamples)
3+
[![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-golang-mongodb-template%26template_owner%3DDefangSamples)
44

5-
This sample is a task manager application that uses Go and MongoDB Atlas, deployed with Defang.
5+
This sample is a task manager application that uses Go and MongoDB, deployed with Defang.
66

77
HTML and JavaScript are used for the frontend to interact with the backend via API calls. There is a `go.mod` file that includes dependencies for the Dockerfile to install.
88

9-
There is a environment variable named `MONGO_URI` for the `MONGODB` connection string. In the `compose.yaml` file, be sure to put your MongoDB URI, i.e.
10-
`mongodb+srv://<username>:<pwd>@host`.
11-
129
## Prerequisites
1310

1411
1. Download [Defang CLI](https://github.com/DefangLabs/defang)
@@ -24,14 +21,31 @@ docker compose up --build
2421
```
2522

2623
## Configuration
27-
For this sample, you will need to provide the following [configuration](https://docs.defang.io/docs/concepts/configuration):
24+
For this sample, you will need to provide the following [configuration](https://docs.defang.io/docs/concepts/configuration):
2825

2926
> 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.
3027
31-
### `MONGODB_URI`
32-
A URI for MongoDB that should have a format of `mongodb+srv://<username>:<pwd>@host`.
28+
### `MONGO_INITDB_ROOT_USERNAME`
29+
The username for the MongoDB database.
30+
```bash
31+
defang config set MONGO_INITDB_ROOT_USERNAME
32+
```
33+
34+
### `MONGO_INITDB_ROOT_PASSWORD`
35+
The password for the MongoDB database.
3336
```bash
34-
defang config set MONGODB_URI
37+
defang config set MONGO_INITDB_ROOT_PASSWORD
38+
```
39+
40+
### Using MongoDB Atlas
41+
42+
If you want to use MongoDB Atlas, you can set the URI with `defang config set MONGO_URI` and remove the value from the `MONGO_URI` environment variable so that it is read from defang config. For example, in your `compose.yaml` file:
43+
44+
```yaml
45+
services:
46+
app:
47+
environment:
48+
- MONGO_URI # empty values are read from defang config
3549
```
3650
3751
## Deployment
@@ -58,9 +72,9 @@ If you want to deploy to your own cloud account, you can use Defang BYOC:
5872

5973
---
6074

61-
Title: Go & MongoDB Atlas
75+
Title: Go & MongoDB
6276

63-
Short Description: A simple Go application that manages tasks with MongoDB Atlas.
77+
Short Description: A simple Go application that manages tasks with MongoDB.
6478

6579
Tags: Go, MongoDB, Atlas, Task Manager
6680

0 commit comments

Comments
 (0)