# MongoDB ## Deploying a DBMS To deploy MongoDB, you will need to complete the following steps: ### 1. Create an application with a suitable tariff. ```{eval-rst} .. admonition:: Attention :class: attention Stable work is possible at tariffs not lower than “Initial”. ``` ### 2. At the "Data Upload" stage, select "Via Git" ![db_create](../img/db_create.png) ### 3. At the "Configuration" stage, select "db" and "mongodb" and click "Finish" ![db_create](../img/mongo.png) ```{eval-rst} .. admonition:: Important :class: warning Stable operation with MongoDB has been tested only with versions 5.0 and 6.0 ``` When deployed, the Docker image `mongo:${meta.toolchain.version}` is used. The `meta.toolchain.version` parameter is optional. If not specified, the latest `mongo:latest` image will be used. Since the value of the `meta.toolchain.version` parameter is a mongo image tag, you can use an arbitrary tag from [docker hub](https://hub.docker.com/_/mongo/tags) as its value. ### 4. Specify the required environment parameters. In the "Variables" section of the project, you must set the following [environment variables](../applications/configuration/variables.md): * To add a username, you must click on the "Create Variable" button. In the "Name" field, enter `MONGO_INITDB_ROOT_USERNAME`, and in the Value field, enter the desired user name. * To add a password and store it securely, you need to click on the “Create secret” button. In the "Name" field, enter `MONGO_INITDB_ROOT_PASSWORD`, and in the Value field, enter the desired password. ```{eval-rst} .. admonition:: Important :class: warning Come up with a sufficiently complex password for the database so that attackers cannot gain access to it. ``` If necessary, you can set other parameters supported by the image. More information about these parameters can be found on the [image page](https://hub.docker.com/_/mongo). ### 5. On the "Configuration" page of the application, click the "Build" button If the configuration is empty, you must select “db” and “mongodb” again and click “apply”, and then “build”. ## Connecting to the database ```{eval-rst} .. admonition:: Attention :class: attention Connecting to the database is only possible from other projects created in Amverum. ``` To connect to the database, you must use the `27017` port and internal domain name specified on the "Info" page in the format: `amverum--run-` ## Deploying mongo-express The procedure is the same as deploying the DBMS itself: ### 1. Create an application with a suitable tariff. ```{eval-rst} .. admonition:: Attention :class: attention For mongo-express to work, you need a container with a tariff of at least “Initial”. ``` ### 2. At the “Data Upload” stage, select “Via Git” ![db_create](../img/db_create.png) ### 3. At the "Configuration" stage, select "db" and "mongo-express" and click "Finish" When deploying, the [Docker image](https://hub.docker.com/_/mongo-express) `mongo-express:${meta.toolchain.version}` is used. To connect to MongoDB version 5 or 6, use version 1 or latest. ### 4. Specify the required environment parameters. In the "Variables" section of the project, you must set the following [environment variables](../applications/configuration/variables.md): * Variable `ME_CONFIG_BASICAUTH_USERNAME` - mongo-express administrator username * Secret `ME_CONFIG_BASICAUTH_PASSWORD` - password for accessing mongo-express (has nothing to do with the database password) * `ME_CONFIG_MONGODB_AUTH_USERNAME` - mongodb user name (what was specified in the `MONGO_INITDB_ROOT_USERNAME` variable) * Secret `ME_CONFIG_MONGODB_AUTH_PASSWORD` - password for accessing mongodb (what was specified in the secret `MONGO_INITDB_ROOT_PASSWORD`) * Variable `ME_CONFIG_MONGODB_SERVER` - internal domain name of the project with mongodb ### 5. On the "Configuration" page of the application, click the "Build" button If the configuration is empty, you must select “db” and “mongo-express” again and click “apply”, and then “build”. ### 6. In the "Settings" section of the application, activate [free domain name](../applications/configuration/network.md#free-domain-name-amverum) or [add your own](../applications/configuration/network.md#your-domain-name). ![db_create](../img/pgadmin_domain.png) ```{eval-rst} .. admonition:: Cunning :class: hint To save on consuming a project with mongo-express, we recommend pausing it after finishing work. ```