You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
6
6
7
7
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.
8
8
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.
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):
28
25
29
26
> 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.
30
27
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.
33
36
```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
35
49
```
36
50
37
51
## Deployment
@@ -58,9 +72,9 @@ If you want to deploy to your own cloud account, you can use Defang BYOC:
58
72
59
73
---
60
74
61
-
Title: Go & MongoDB Atlas
75
+
Title: Go & MongoDB
62
76
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.
0 commit comments